Documentation Index
Fetch the complete documentation index at: https://mintlify.com/exelearning/mod_exelearning/llms.txt
Use this file to discover all available pages before exploring further.
mod_exelearning_get_user_grades returns the real gradebook grades for a user on a mod_exelearning activity. The response reflects the actual grade columns as stored in the Moodle gradebook via grade_get_grades(), enriched with each iDevice’s type and display name from the exelearning_grade_item table. In per-iDevice grade model (grademodel = 1) there is one entry per iDevice; in overall mode (grademodel = 0) there is a single overall entry (itemnumber = 0).
Function details
| Field | Value |
|---|---|
| Function name | mod_exelearning_get_user_grades |
| Class::method | mod_exelearning\external\get_user_grades::execute |
| Type | read |
| Service | MOODLE_OFFICIAL_MOBILE_SERVICE |
| Capability | mod/exelearning:view (own); additionally mod/exelearning:viewreport for another user |
Parameters
The ID of the
exelearning activity instance (the id column in the exelearning table, returned as id by get_exelearnings_by_courses). This is not the course-module ID.The Moodle user ID whose grades to retrieve. Pass
0 (or omit the parameter) to read the authenticated user’s own grades. Passing another user’s ID requires mod/exelearning:viewreport and that user must be an active account.Returns
Array of grade objects, one per gradebook column. In per-iDevice mode there is one object per iDevice; in overall mode there is exactly one object with
itemnumber = 0.Empty on success. Present for forward compatibility.
Security model
The security checks applied in order are:validate_parameters()— sanitises inputs.validate_context()— establishes the module context.require_capability('mod/exelearning:view', $context)— base access check.core_user::require_active_user($user)— target user must be active.- If
userid != $USER->id:require_capability('mod/exelearning:viewreport', $context).
Relationship to get_user_attempts
get_user_grades reads from the gradebook (the grade_grades table via grade_get_grades()), which reflects the aggregated grade calculated from all attempts according to the grademethod setting. get_user_attempts reads from the attempt log (exelearning_attempt table), which contains every individual submission. Use get_user_grades to show the final grade; use get_user_attempts to show the attempt history.
Example request — own grades
Example response — per-iDevice mode
The second iDevice (
itemnumber: 2) has no grade or percent field because the user has not yet been graded on that column. Always check for the presence of grade before displaying a score.