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_attempts returns the list of recorded attempts for a user on a mod_exelearning activity. Each entry represents one overall attempt (itemnumber = 0) with its status and score percentage. A student can read their own attempts with only mod/exelearning:view; reading another user’s attempts additionally requires mod/exelearning:viewreport (typically a teacher or admin role).
Function details
| Field | Value |
|---|---|
| Function name | mod_exelearning_get_user_attempts |
| Class::method | mod_exelearning\external\get_user_attempts::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 attempts to retrieve. Pass
0 (or omit the parameter) to read the authenticated user’s own attempts. Passing another user’s ID requires mod/exelearning:viewreport and that user must be an active (non-deleted, non-suspended) account.Returns
Array of attempt objects ordered ascending by attempt number.
The attempt aggregation method configured for this activity instance (e.g. highest, average, first, last). Useful for presenting grade calculation context to the user.
The maximum number of attempts allowed (
0 = unlimited). Compare attempts.length against this value to know whether the user can still submit.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).