Skip to main content

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

FieldValue
Function namemod_exelearning_view_exelearning
Class::methodmod_exelearning\external\view_exelearning::execute
Typewrite
ServiceMOODLE_OFFICIAL_MOBILE_SERVICE
Capabilitymod/exelearning:view

Parameters

exelearningid
int
required
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

status
bool
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.
warnings
array
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 to view.php?id=<cmid> in a browser:
  1. validate_parameters() sanitises the input.
  2. The activity record and course-module are loaded from the database.
  3. validate_context() is called against the module context.
  4. require_capability('mod/exelearning:view', $context) is enforced.
  5. exelearning_view() is called, which fires the \mod_exelearning\event\course_module_viewed event and calls completion_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

POST {wwwroot}/webservice/rest/server.php
Content-Type: application/x-www-form-urlencoded

wstoken=<token>
&wsfunction=mod_exelearning_view_exelearning
&moodlewsrestformat=json
&exelearningid=12

Example response

{
  "status": true,
  "warnings": []
}

Error cases

ConditionResult
Invalid exelearningidException: record not found
Caller lacks mod/exelearning:viewException: require_capability failure
Activity context is not accessibleException: validate_context failure

Build docs developers (and LLMs) love