Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
mod_lesson_external Class Reference

Lesson external functions. More...

Inheritance diagram for mod_lesson_external:

Static Public Member Functions

static finish_attempt ($lessonid, $password='', $outoftime=false, $review=false)
 Finishes the current attempt.
 
static finish_attempt_parameters ()
 Describes the parameters for finish_attempt.
 
static finish_attempt_returns ()
 Describes the finish_attempt return value.
 
static get_attempts_overview ($lessonid, $groupid=0)
 Get a list of all the attempts made by users in a lesson.
 
static get_attempts_overview_parameters ()
 Describes the parameters for get_attempts_overview.
 
static get_attempts_overview_returns ()
 Describes the get_attempts_overview return value.
 
static get_content_pages_viewed ($lessonid, $lessonattempt, $userid=null)
 Return the list of content pages viewed by a user during a lesson attempt.
 
static get_content_pages_viewed_parameters ()
 Describes the parameters for get_content_pages_viewed.
 
static get_content_pages_viewed_returns ()
 Describes the get_content_pages_viewed return value.
 
static get_lesson ($lessonid, $password='')
 Return information of a given lesson.
 
static get_lesson_access_information ($lessonid)
 Return access information for a given lesson.
 
static get_lesson_access_information_parameters ()
 Describes the parameters for get_lesson_access_information.
 
static get_lesson_access_information_returns ()
 Describes the get_lesson_access_information return value.
 
static get_lesson_parameters ()
 Describes the parameters for get_lesson.
 
static get_lesson_returns ()
 Describes the get_lesson return value.
 
static get_lessons_by_courses ($courseids=array())
 Returns a list of lessons in a provided list of courses, if no list is provided all lessons that the user can view will be returned.
 
static get_lessons_by_courses_parameters ()
 Describes the parameters for get_lessons_by_courses.
 
static get_lessons_by_courses_returns ()
 Describes the get_lessons_by_courses return value.
 
static get_page_data ($lessonid, $pageid, $password='', $review=false, $returncontents=false)
 Return information of a given page, including its contents.
 
static get_page_data_parameters ()
 Describes the parameters for get_page_data.
 
static get_page_data_returns ()
 Describes the get_page_data return value.
 
static get_pages ($lessonid, $password='')
 Return the list of pages in a lesson (based on the user permissions).
 
static get_pages_parameters ()
 Describes the parameters for get_pages.
 
static get_pages_possible_jumps ($lessonid)
 Return all the possible jumps for the pages in a given lesson.
 
static get_pages_possible_jumps_parameters ()
 Describes the parameters for get_pages_possible_jumps.
 
static get_pages_possible_jumps_returns ()
 Describes the get_pages_possible_jumps return value.
 
static get_pages_returns ()
 Describes the get_pages return value.
 
static get_questions_attempts ($lessonid, $attempt, $correct=false, $pageid=null, $userid=null)
 Return the list of page question attempts in a given lesson.
 
static get_questions_attempts_parameters ()
 Describes the parameters for get_questions_attempts.
 
static get_questions_attempts_returns ()
 Describes the get_questions_attempts return value.
 
static get_user_attempt ($lessonid, $userid, $lessonattempt)
 Return information about the given user attempt (including answers).
 
static get_user_attempt_grade ($lessonid, $lessonattempt, $userid=null)
 Return grade information in the attempt for a given user.
 
static get_user_attempt_grade_parameters ()
 Describes the parameters for get_user_attempt_grade.
 
static get_user_attempt_grade_returns ()
 Describes the get_user_attempt_grade return value.
 
static get_user_attempt_parameters ()
 Describes the parameters for get_user_attempt.
 
static get_user_attempt_returns ()
 Describes the get_user_attempt return value.
 
static get_user_grade ($lessonid, $userid=null)
 Return the final grade in the lesson for the given user.
 
static get_user_grade_parameters ()
 Describes the parameters for get_user_grade.
 
static get_user_grade_returns ()
 Describes the get_user_grade return value.
 
static get_user_timers ($lessonid, $userid=null)
 Return the timers in the current lesson for the given user.
 
static get_user_timers_parameters ()
 Describes the parameters for get_user_timers.
 
static get_user_timers_returns ()
 Describes the get_user_timers return value.
 
static launch_attempt ($lessonid, $password='', $pageid=0, $review=false)
 Starts a new attempt or continues an existing one.
 
static launch_attempt_parameters ()
 Describes the parameters for launch_attempt.
 
static launch_attempt_returns ()
 Describes the launch_attempt return value.
 
static process_page ($lessonid, $pageid, $data, $password='', $review=false)
 Processes page responses.
 
static process_page_parameters ()
 Describes the parameters for process_page.
 
static process_page_returns ()
 Describes the process_page return value.
 
static view_lesson ($lessonid, $password='')
 Trigger the course module viewed event and update the module completion status.
 
static view_lesson_parameters ()
 Describes the parameters for view_lesson.
 
static view_lesson_returns ()
 Describes the view_lesson return value.
 

Static Protected Member Functions

static check_can_view_user_data ($userid, $course, $cm, $context)
 Check if the current user can retrieve lesson information (grades, attempts) about the given user.
 
static external_messages ()
 Return a external structure representing messages.
 
static format_lesson_messages ($lesson)
 Return lesson messages formatted according the external_messages structure.
 
static get_lesson_summary_for_exporter ($lessonrecord, $password='')
 Return a lesson record ready for being exported.
 
static get_page_fields (lesson_page $page, $returncontents=false)
 Returns the fields of a page object.
 
static get_page_structure ($required=VALUE_REQUIRED)
 Describes the external structure for a lesson page.
 
static get_user_attempt_grade_structure ($required=VALUE_REQUIRED)
 Describes an attempt grade structure.
 
static validate_attempt (lesson $lesson, $params, $return=false)
 Validates a new attempt.
 
static validate_lesson ($lessonid)
 Utility function for validating a lesson.
 

Detailed Description

Lesson external functions.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 3.3

Member Function Documentation

◆ check_can_view_user_data()

static mod_lesson_external::check_can_view_user_data ( $userid,
$course,
$cm,
$context )
staticprotected

Check if the current user can retrieve lesson information (grades, attempts) about the given user.

Parameters
int$useridthe user to check
stdClass$coursecourse object
stdClass$cmcm object
stdClass$contextcontext object
Exceptions
moodle_exception
Since
Moodle 3.3

◆ external_messages()

static mod_lesson_external::external_messages ( )
staticprotected

Return a external structure representing messages.

Return values
external_multiple_structuremessages structure
Since
Moodle 3.3

◆ finish_attempt()

static mod_lesson_external::finish_attempt ( $lessonid,
$password = '',
$outoftime = false,
$review = false )
static

Finishes the current attempt.

Parameters
int$lessonidlesson instance id
string$passwordoptional password (the lesson may be protected)
bool$outoftimeoptional if the user run out of time
bool$reviewif we want to review just after finishing (1 hour margin)
Return values
arrayof warnings and information about the finished attempt
Since
Moodle 3.3
Exceptions
moodle_exception

◆ finish_attempt_parameters()

static mod_lesson_external::finish_attempt_parameters ( )
static

Describes the parameters for finish_attempt.

Return values
external_function_parameters
Since
Moodle 3.3

◆ finish_attempt_returns()

static mod_lesson_external::finish_attempt_returns ( )
static

Describes the finish_attempt return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ format_lesson_messages()

static mod_lesson_external::format_lesson_messages ( $lesson)
staticprotected

Return lesson messages formatted according the external_messages structure.

Parameters
lesson$lessonlesson instance
Return values
arraymessages formatted
Since
Moodle 3.3

◆ get_attempts_overview()

static mod_lesson_external::get_attempts_overview ( $lessonid,
$groupid = 0 )
static

Get a list of all the attempts made by users in a lesson.

Parameters
int$lessonidlesson instance id
int$groupidgroup id, 0 means that the function will determine the user group
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_attempts_overview_parameters()

static mod_lesson_external::get_attempts_overview_parameters ( )
static

Describes the parameters for get_attempts_overview.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_attempts_overview_returns()

static mod_lesson_external::get_attempts_overview_returns ( )
static

Describes the get_attempts_overview return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_content_pages_viewed()

static mod_lesson_external::get_content_pages_viewed ( $lessonid,
$lessonattempt,
$userid = null )
static

Return the list of content pages viewed by a user during a lesson attempt.

Parameters
int$lessonidlesson instance id
int$lessonattemptlesson attempt number
int$useridonly fetch attempts of the given user
Return values
arrayof warnings and page attempts
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_content_pages_viewed_parameters()

static mod_lesson_external::get_content_pages_viewed_parameters ( )
static

Describes the parameters for get_content_pages_viewed.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_content_pages_viewed_returns()

static mod_lesson_external::get_content_pages_viewed_returns ( )
static

Describes the get_content_pages_viewed return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_lesson()

static mod_lesson_external::get_lesson ( $lessonid,
$password = '' )
static

Return information of a given lesson.

Parameters
int$lessonidlesson instance id
string$passwordoptional password (the lesson may be protected)
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_lesson_access_information()

static mod_lesson_external::get_lesson_access_information ( $lessonid)
static

Return access information for a given lesson.

Parameters
int$lessonidlesson instance id
Return values
arrayof warnings and the access information
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_lesson_access_information_parameters()

static mod_lesson_external::get_lesson_access_information_parameters ( )
static

Describes the parameters for get_lesson_access_information.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_lesson_access_information_returns()

static mod_lesson_external::get_lesson_access_information_returns ( )
static

Describes the get_lesson_access_information return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_lesson_parameters()

static mod_lesson_external::get_lesson_parameters ( )
static

Describes the parameters for get_lesson.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_lesson_returns()

static mod_lesson_external::get_lesson_returns ( )
static

Describes the get_lesson return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_lesson_summary_for_exporter()

static mod_lesson_external::get_lesson_summary_for_exporter ( $lessonrecord,
$password = '' )
staticprotected

Return a lesson record ready for being exported.

Parameters
stdClass$lessonrecordlesson record
string$passwordlesson password
Return values
stdClassthe lesson record ready for exporting.

◆ get_lessons_by_courses()

static mod_lesson_external::get_lessons_by_courses ( $courseids = array())
static

Returns a list of lessons in a provided list of courses, if no list is provided all lessons that the user can view will be returned.

Parameters
array$courseidsArray of course ids
Return values
arrayof lessons details
Since
Moodle 3.3

◆ get_lessons_by_courses_parameters()

static mod_lesson_external::get_lessons_by_courses_parameters ( )
static

Describes the parameters for get_lessons_by_courses.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_lessons_by_courses_returns()

static mod_lesson_external::get_lessons_by_courses_returns ( )
static

Describes the get_lessons_by_courses return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_page_data()

static mod_lesson_external::get_page_data ( $lessonid,
$pageid,
$password = '',
$review = false,
$returncontents = false )
static

Return information of a given page, including its contents.

Parameters
int$lessonidlesson instance id
int$pageidpage id
string$passwordoptional password (the lesson may be protected)
bool$reviewif we want to review just after finishing (1 hour margin)
bool$returncontentsif we must return the complete page contents once rendered
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_page_data_parameters()

static mod_lesson_external::get_page_data_parameters ( )
static

Describes the parameters for get_page_data.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_page_data_returns()

static mod_lesson_external::get_page_data_returns ( )
static

Describes the get_page_data return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_page_fields()

static mod_lesson_external::get_page_fields ( lesson_page $page,
$returncontents = false )
staticprotected

Returns the fields of a page object.

Parameters
lesson_page$pagethe lesson page
bool$returncontentswhether to return the page title and contents
Return values
stdClassthe fields matching the external page structure
Since
Moodle 3.3

◆ get_page_structure()

static mod_lesson_external::get_page_structure ( $required = VALUE_REQUIRED)
staticprotected

Describes the external structure for a lesson page.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_pages()

static mod_lesson_external::get_pages ( $lessonid,
$password = '' )
static

Return the list of pages in a lesson (based on the user permissions).

Parameters
int$lessonidlesson instance id
string$passwordoptional password (the lesson may be protected)
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_pages_parameters()

static mod_lesson_external::get_pages_parameters ( )
static

Describes the parameters for get_pages.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_pages_possible_jumps()

static mod_lesson_external::get_pages_possible_jumps ( $lessonid)
static

Return all the possible jumps for the pages in a given lesson.

You may expect different results on consecutive executions due to the random nature of the lesson module.

Parameters
int$lessonidlesson instance id
Return values
arrayof warnings and possible jumps
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_pages_possible_jumps_parameters()

static mod_lesson_external::get_pages_possible_jumps_parameters ( )
static

Describes the parameters for get_pages_possible_jumps.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_pages_possible_jumps_returns()

static mod_lesson_external::get_pages_possible_jumps_returns ( )
static

Describes the get_pages_possible_jumps return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_pages_returns()

static mod_lesson_external::get_pages_returns ( )
static

Describes the get_pages return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_questions_attempts()

static mod_lesson_external::get_questions_attempts ( $lessonid,
$attempt,
$correct = false,
$pageid = null,
$userid = null )
static

Return the list of page question attempts in a given lesson.

Parameters
int$lessonidlesson instance id
int$attemptthe lesson attempt number
bool$correctonly fetch correct attempts
int$pageidonly fetch attempts at the given page
int$useridonly fetch attempts of the given user
Return values
arrayof warnings and page attempts
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_questions_attempts_parameters()

static mod_lesson_external::get_questions_attempts_parameters ( )
static

Describes the parameters for get_questions_attempts.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_questions_attempts_returns()

static mod_lesson_external::get_questions_attempts_returns ( )
static

Describes the get_questions_attempts return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_user_attempt()

static mod_lesson_external::get_user_attempt ( $lessonid,
$userid,
$lessonattempt )
static

Return information about the given user attempt (including answers).

Parameters
int$lessonidlesson instance id
int$useridthe user id
int$lessonattemptthe attempt number
Return values
arrayof warnings and page attempts
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_user_attempt_grade()

static mod_lesson_external::get_user_attempt_grade ( $lessonid,
$lessonattempt,
$userid = null )
static

Return grade information in the attempt for a given user.

Parameters
int$lessonidlesson instance id
int$lessonattemptlesson attempt number
int$useridonly fetch attempts of the given user
Return values
arrayof warnings and page attempts
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_user_attempt_grade_parameters()

static mod_lesson_external::get_user_attempt_grade_parameters ( )
static

Describes the parameters for get_user_attempt_grade.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_user_attempt_grade_returns()

static mod_lesson_external::get_user_attempt_grade_returns ( )
static

Describes the get_user_attempt_grade return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_user_attempt_grade_structure()

static mod_lesson_external::get_user_attempt_grade_structure ( $required = VALUE_REQUIRED)
staticprotected

Describes an attempt grade structure.

Parameters
int$requiredif the structure is required or optional
Return values
external_single_structurethe structure
Since
Moodle 3.3

◆ get_user_attempt_parameters()

static mod_lesson_external::get_user_attempt_parameters ( )
static

Describes the parameters for get_user_attempt.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_user_attempt_returns()

static mod_lesson_external::get_user_attempt_returns ( )
static

Describes the get_user_attempt return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_user_grade()

static mod_lesson_external::get_user_grade ( $lessonid,
$userid = null )
static

Return the final grade in the lesson for the given user.

Parameters
int$lessonidlesson instance id
int$useridonly fetch grades of this user
Return values
arrayof warnings and page attempts
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_user_grade_parameters()

static mod_lesson_external::get_user_grade_parameters ( )
static

Describes the parameters for get_user_grade.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_user_grade_returns()

static mod_lesson_external::get_user_grade_returns ( )
static

Describes the get_user_grade return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ get_user_timers()

static mod_lesson_external::get_user_timers ( $lessonid,
$userid = null )
static

Return the timers in the current lesson for the given user.

Parameters
int$lessonidlesson instance id
int$useridonly fetch timers of the given user
Return values
arrayof warnings and timers
Since
Moodle 3.3
Exceptions
moodle_exception

◆ get_user_timers_parameters()

static mod_lesson_external::get_user_timers_parameters ( )
static

Describes the parameters for get_user_timers.

Return values
external_function_parameters
Since
Moodle 3.3

◆ get_user_timers_returns()

static mod_lesson_external::get_user_timers_returns ( )
static

Describes the get_user_timers return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ launch_attempt()

static mod_lesson_external::launch_attempt ( $lessonid,
$password = '',
$pageid = 0,
$review = false )
static

Starts a new attempt or continues an existing one.

Parameters
int$lessonidlesson instance id
string$passwordoptional password (the lesson may be protected)
int$pageidpage id to continue from (only when continuing an attempt)
bool$reviewif we want to review just after finishing
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ launch_attempt_parameters()

static mod_lesson_external::launch_attempt_parameters ( )
static

Describes the parameters for launch_attempt.

Return values
external_function_parameters
Since
Moodle 3.3

◆ launch_attempt_returns()

static mod_lesson_external::launch_attempt_returns ( )
static

Describes the launch_attempt return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ process_page()

static mod_lesson_external::process_page ( $lessonid,
$pageid,
$data,
$password = '',
$review = false )
static

Processes page responses.

Parameters
int$lessonidlesson instance id
int$pageidpage id
array$datathe data to be saved
string$passwordoptional password (the lesson may be protected)
bool$reviewif we want to review just after finishing (1 hour margin)
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ process_page_parameters()

static mod_lesson_external::process_page_parameters ( )
static

Describes the parameters for process_page.

Return values
external_function_parameters
Since
Moodle 3.3

◆ process_page_returns()

static mod_lesson_external::process_page_returns ( )
static

Describes the process_page return value.

Return values
external_single_structure
Since
Moodle 3.3

◆ validate_attempt()

static mod_lesson_external::validate_attempt ( lesson $lesson,
$params,
$return = false )
staticprotected

Validates a new attempt.

Parameters
lesson$lessonlesson instance
array$paramsrequest parameters
boolean$returnwhether to return the errors or throw exceptions
Return values
arraythe errors (if return set to true)
Since
Moodle 3.3

◆ validate_lesson()

static mod_lesson_external::validate_lesson ( $lessonid)
staticprotected

Utility function for validating a lesson.

Parameters
int$lessonidlesson instance id
Return values
arrayarray containing the lesson, course, context and course module objects
Since
Moodle 3.3

◆ view_lesson()

static mod_lesson_external::view_lesson ( $lessonid,
$password = '' )
static

Trigger the course module viewed event and update the module completion status.

Parameters
int$lessonidlesson instance id
string$passwordoptional password (the lesson may be protected)
Return values
arrayof warnings and status result
Since
Moodle 3.3
Exceptions
moodle_exception

◆ view_lesson_parameters()

static mod_lesson_external::view_lesson_parameters ( )
static

Describes the parameters for view_lesson.

Return values
external_function_parameters
Since
Moodle 3.3

◆ view_lesson_returns()

static mod_lesson_external::view_lesson_returns ( )
static

Describes the view_lesson return value.

Return values
external_single_structure
Since
Moodle 3.3

The documentation for this class was generated from the following file: