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_view_exelearning simulates a student opening the activity’s view.php page. Calling it fires the course_module_viewed event and recalculates completion for the activity, so the Moodle App and other external clients can correctly register a view without loading the full HTML page. It mirrors the behaviour of mod_scorm_view_scorm and mod_exeweb_view_exeweb.
Function details
| Field | Value |
|---|---|
| Function name | mod_exelearning_view_exelearning |
| Class::method | mod_exelearning\external\view_exelearning::execute |
| Type | write |
| Service | MOODLE_OFFICIAL_MOBILE_SERVICE |
| Capability | mod/exelearning:view |
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 — use the id field, not coursemodule.Returns
true when the view event was recorded and completion recalculated successfully. The function raises an exception rather than returning false on failure, so in practice this field is always true on a successful call.Empty on success. The function currently produces no warnings; the field is present for forward compatibility with the standard Moodle external API contract.
Behaviour
Calling this function is equivalent to a student navigating toview.php?id=<cmid> in a browser:
validate_parameters()sanitises the input.- The activity record and course-module are loaded from the database.
validate_context()is called against the module context.require_capability('mod/exelearning:view', $context)is enforced.exelearning_view()is called, which fires the\mod_exelearning\event\course_module_viewedevent and callscompletion_info::set_module_viewed()to update activity completion.
Call this function once per page load when the Moodle App or an external client first presents the activity to the user. Calling it multiple times is harmless — Moodle deduplicates view-based completion — but unnecessary repeated calls add database load.
Example request
Example response
Error cases
| Condition | Result |
|---|---|
Invalid exelearningid | Exception: record not found |
Caller lacks mod/exelearning:view | Exception: require_capability failure |
| Activity context is not accessible | Exception: validate_context failure |