Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_quiz_external Class Reference

Quiz external functions. More...

Inheritance diagram for mod_quiz_external:

Static Public Member Functions

static get_attempt_access_information ($quizid, $attemptid=0)
 Return access information for a given attempt in a quiz.
 
static get_attempt_access_information_parameters ()
 Describes the parameters for get_attempt_access_information.
 
static get_attempt_access_information_returns ()
 Describes the get_attempt_access_information return value.
 
static get_attempt_data ($attemptid, $page, $preflightdata=[])
 Returns information for the given attempt page for a quiz attempt in progress.
 
static get_attempt_data_parameters ()
 Describes the parameters for get_attempt_data.
 
static get_attempt_data_returns ()
 Describes the get_attempt_data return value.
 
static get_attempt_review ($attemptid, $page=-1)
 Returns review information for the given finished attempt, can be used by users or teachers.
 
static get_attempt_review_parameters ()
 Describes the parameters for get_attempt_review.
 
static get_attempt_review_returns ()
 Describes the get_attempt_review return value.
 
static get_attempt_summary ($attemptid, $preflightdata=[])
 Returns a summary of a quiz attempt before it is submitted.
 
static get_attempt_summary_parameters ()
 Describes the parameters for get_attempt_summary.
 
static get_attempt_summary_returns ()
 Describes the get_attempt_summary return value.
 
static get_combined_review_options ($quizid, $userid=0)
 Combines the review options from a number of different quiz attempts.
 
static get_combined_review_options_parameters ()
 Describes the parameters for get_combined_review_options.
 
static get_combined_review_options_returns ()
 Describes the get_combined_review_options return value.
 
static get_quiz_access_information ($quizid)
 Return access information for a given quiz.
 
static get_quiz_access_information_parameters ()
 Describes the parameters for get_quiz_access_information.
 
static get_quiz_access_information_returns ()
 Describes the get_quiz_access_information return value.
 
static get_quiz_feedback_for_grade ($quizid, $grade)
 Get the feedback text that should be show to a student who got the given grade in the given quiz.
 
static get_quiz_feedback_for_grade_parameters ()
 Describes the parameters for view_quiz.
 
static get_quiz_feedback_for_grade_returns ()
 Describes the get_quiz_feedback_for_grade return value.
 
static get_quiz_required_qtypes ($quizid)
 Return the potential question types that would be required for a given quiz.
 
static get_quiz_required_qtypes_parameters ()
 Describes the parameters for get_quiz_required_qtypes.
 
static get_quiz_required_qtypes_returns ()
 Describes the get_quiz_required_qtypes return value.
 
static get_quizzes_by_courses ($courseids=[])
 Returns a list of quizzes in a provided list of courses, if no list is provided all quizzes that the user can view will be returned.
 
static get_quizzes_by_courses_parameters ()
 Describes the parameters for get_quizzes_by_courses.
 
static get_quizzes_by_courses_returns ()
 Describes the get_quizzes_by_courses return value.
 
static get_user_attempts ($quizid, $userid=0, $status='finished', $includepreviews=false)
 Return a list of attempts for the given quiz and user.
 
static get_user_attempts_parameters ()
 Describes the parameters for get_user_attempts.
 
static get_user_attempts_returns ()
 Describes the get_user_attempts return value.
 
static get_user_best_grade ($quizid, $userid=0)
 Get the best current grade for the given user on a quiz.
 
static get_user_best_grade_parameters ()
 Describes the parameters for get_user_best_grade.
 
static get_user_best_grade_returns ()
 Describes the get_user_best_grade return value.
 
static process_attempt ($attemptid, $data, $finishattempt=false, $timeup=false, $preflightdata=[])
 Process responses during an attempt at a quiz and also deals with attempts finishing.
 
static process_attempt_parameters ()
 Describes the parameters for process_attempt.
 
static process_attempt_returns ()
 Describes the process_attempt return value.
 
static save_attempt ($attemptid, $data, $preflightdata=[])
 Processes save requests during the quiz.
 
static save_attempt_parameters ()
 Describes the parameters for save_attempt.
 
static save_attempt_returns ()
 Describes the save_attempt return value.
 
static start_attempt ($quizid, $preflightdata=[], $forcenew=false)
 Starts a new attempt at a quiz.
 
static start_attempt_parameters ()
 Describes the parameters for start_attempt.
 
static start_attempt_returns ()
 Describes the start_attempt return value.
 
static view_attempt ($attemptid, $page, $preflightdata=[])
 Trigger the attempt viewed event.
 
static view_attempt_parameters ()
 Describes the parameters for view_attempt.
 
static view_attempt_returns ()
 Describes the view_attempt return value.
 
static view_attempt_review ($attemptid)
 Trigger the attempt reviewed event.
 
static view_attempt_review_parameters ()
 Describes the parameters for view_attempt_review.
 
static view_attempt_review_returns ()
 Describes the view_attempt_review return value.
 
static view_attempt_summary ($attemptid, $preflightdata=[])
 Trigger the attempt summary viewed event.
 
static view_attempt_summary_parameters ()
 Describes the parameters for view_attempt_summary.
 
static view_attempt_summary_returns ()
 Describes the view_attempt_summary return value.
 
static view_quiz ($quizid)
 Trigger the course module viewed event and update the module completion status.
 
static view_quiz_parameters ()
 Describes the parameters for view_quiz.
 
static view_quiz_returns ()
 Describes the view_quiz return value.
 

Static Protected Member Functions

static validate_attempt ($params, $checkaccessrules=true, $failifoverdue=true)
 Utility function for validating a given attempt.
 
static validate_attempt_review ($params)
 Validate an attempt finished for review.
 
static validate_quiz ($quizid)
 Utility function for validating a quiz.
 

Detailed Description

Quiz external functions.

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

Member Function Documentation

◆ get_attempt_access_information()

static mod_quiz_external::get_attempt_access_information ( $quizid,
$attemptid = 0 )
static

Return access information for a given attempt in a quiz.

Parameters
int$quizidquiz instance id
int$attemptidattempt id, 0 for the user last attempt if exists
Return values
arrayof warnings and the access information
Since
Moodle 3.1

◆ get_attempt_access_information_parameters()

static mod_quiz_external::get_attempt_access_information_parameters ( )
static

Describes the parameters for get_attempt_access_information.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_attempt_access_information_returns()

static mod_quiz_external::get_attempt_access_information_returns ( )
static

Describes the get_attempt_access_information return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_attempt_data()

static mod_quiz_external::get_attempt_data ( $attemptid,
$page,
$preflightdata = [] )
static

Returns information for the given attempt page for a quiz attempt in progress.

Parameters
int$attemptidattempt id
int$pagepage number
array$preflightdatapreflight required data (like passwords)
Return values
arrayof warnings and the attempt data, next page, message and questions
Since
Moodle 3.1

◆ get_attempt_data_parameters()

static mod_quiz_external::get_attempt_data_parameters ( )
static

Describes the parameters for get_attempt_data.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_attempt_data_returns()

static mod_quiz_external::get_attempt_data_returns ( )
static

Describes the get_attempt_data return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_attempt_review()

static mod_quiz_external::get_attempt_review ( $attemptid,
$page = -1 )
static

Returns review information for the given finished attempt, can be used by users or teachers.

Parameters
int$attemptidattempt id
int$pagepage number, empty for all the questions in all the pages
Return values
arrayof warnings and the attempt data, feedback and questions
Since
Moodle 3.1

◆ get_attempt_review_parameters()

static mod_quiz_external::get_attempt_review_parameters ( )
static

Describes the parameters for get_attempt_review.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_attempt_review_returns()

static mod_quiz_external::get_attempt_review_returns ( )
static

Describes the get_attempt_review return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_attempt_summary()

static mod_quiz_external::get_attempt_summary ( $attemptid,
$preflightdata = [] )
static

Returns a summary of a quiz attempt before it is submitted.

Parameters
int$attemptidattempt id
int$preflightdatapreflight required data (like passwords)
Return values
arrayof warnings and the attempt summary data for each question
Since
Moodle 3.1

◆ get_attempt_summary_parameters()

static mod_quiz_external::get_attempt_summary_parameters ( )
static

Describes the parameters for get_attempt_summary.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_attempt_summary_returns()

static mod_quiz_external::get_attempt_summary_returns ( )
static

Describes the get_attempt_summary return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_combined_review_options()

static mod_quiz_external::get_combined_review_options ( $quizid,
$userid = 0 )
static

Combines the review options from a number of different quiz attempts.

Parameters
int$quizidquiz instance id
int$useriduser id (empty for current user)
Return values
arrayof warnings and the review options
Since
Moodle 3.1

◆ get_combined_review_options_parameters()

static mod_quiz_external::get_combined_review_options_parameters ( )
static

Describes the parameters for get_combined_review_options.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_combined_review_options_returns()

static mod_quiz_external::get_combined_review_options_returns ( )
static

Describes the get_combined_review_options return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_quiz_access_information()

static mod_quiz_external::get_quiz_access_information ( $quizid)
static

Return access information for a given quiz.

Parameters
int$quizidquiz instance id
Return values
arrayof warnings and the access information
Since
Moodle 3.1

◆ get_quiz_access_information_parameters()

static mod_quiz_external::get_quiz_access_information_parameters ( )
static

Describes the parameters for get_quiz_access_information.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_quiz_access_information_returns()

static mod_quiz_external::get_quiz_access_information_returns ( )
static

Describes the get_quiz_access_information return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_quiz_feedback_for_grade()

static mod_quiz_external::get_quiz_feedback_for_grade ( $quizid,
$grade )
static

Get the feedback text that should be show to a student who got the given grade in the given quiz.

Parameters
int$quizidquiz instance id
float$gradethe grade to check
Return values
arrayof warnings and status result
Since
Moodle 3.1

◆ get_quiz_feedback_for_grade_parameters()

static mod_quiz_external::get_quiz_feedback_for_grade_parameters ( )
static

Describes the parameters for view_quiz.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_quiz_feedback_for_grade_returns()

static mod_quiz_external::get_quiz_feedback_for_grade_returns ( )
static

Describes the get_quiz_feedback_for_grade return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_quiz_required_qtypes()

static mod_quiz_external::get_quiz_required_qtypes ( $quizid)
static

Return the potential question types that would be required for a given quiz.

Please note that for random question types we return the potential question types in the category choosen.

Parameters
int$quizidquiz instance id
Return values
arrayof warnings and the access information
Since
Moodle 3.1

◆ get_quiz_required_qtypes_parameters()

static mod_quiz_external::get_quiz_required_qtypes_parameters ( )
static

Describes the parameters for get_quiz_required_qtypes.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_quiz_required_qtypes_returns()

static mod_quiz_external::get_quiz_required_qtypes_returns ( )
static

Describes the get_quiz_required_qtypes return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_quizzes_by_courses()

static mod_quiz_external::get_quizzes_by_courses ( $courseids = [])
static

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

Parameters
array$courseidsArray of course ids
Return values
arrayof quizzes details
Since
Moodle 3.1

◆ get_quizzes_by_courses_parameters()

static mod_quiz_external::get_quizzes_by_courses_parameters ( )
static

Describes the parameters for get_quizzes_by_courses.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_quizzes_by_courses_returns()

static mod_quiz_external::get_quizzes_by_courses_returns ( )
static

Describes the get_quizzes_by_courses return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_user_attempts()

static mod_quiz_external::get_user_attempts ( $quizid,
$userid = 0,
$status = 'finished',
$includepreviews = false )
static

Return a list of attempts for the given quiz and user.

Parameters
int$quizidquiz instance id
int$useriduser id
string$statusquiz status: all, finished or unfinished
bool$includepreviewswhether to include previews or not
Return values
arrayof warnings and the list of attempts
Since
Moodle 3.1

◆ get_user_attempts_parameters()

static mod_quiz_external::get_user_attempts_parameters ( )
static

Describes the parameters for get_user_attempts.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_user_attempts_returns()

static mod_quiz_external::get_user_attempts_returns ( )
static

Describes the get_user_attempts return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ get_user_best_grade()

static mod_quiz_external::get_user_best_grade ( $quizid,
$userid = 0 )
static

Get the best current grade for the given user on a quiz.

Parameters
int$quizidquiz instance id
int$useriduser id
Return values
arrayof warnings and the grade information
Since
Moodle 3.1

◆ get_user_best_grade_parameters()

static mod_quiz_external::get_user_best_grade_parameters ( )
static

Describes the parameters for get_user_best_grade.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_user_best_grade_returns()

static mod_quiz_external::get_user_best_grade_returns ( )
static

Describes the get_user_best_grade return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ process_attempt()

static mod_quiz_external::process_attempt ( $attemptid,
$data,
$finishattempt = false,
$timeup = false,
$preflightdata = [] )
static

Process responses during an attempt at a quiz and also deals with attempts finishing.

Parameters
int$attemptidattempt id
array$datathe data to be saved
bool$finishattemptwhether to finish or not the attempt
bool$timeupwhether the WS was called by a timer when the time is up
array$preflightdatapreflight required data (like passwords)
Return values
arrayof warnings and the attempt state after the processing
Since
Moodle 3.1

◆ process_attempt_parameters()

static mod_quiz_external::process_attempt_parameters ( )
static

Describes the parameters for process_attempt.

Return values
external_function_parameters
Since
Moodle 3.1

◆ process_attempt_returns()

static mod_quiz_external::process_attempt_returns ( )
static

Describes the process_attempt return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ save_attempt()

static mod_quiz_external::save_attempt ( $attemptid,
$data,
$preflightdata = [] )
static

Processes save requests during the quiz.

This function is intended for the quiz auto-save feature.

Parameters
int$attemptidattempt id
array$datathe data to be saved
array$preflightdatapreflight required data (like passwords)
Return values
arrayof warnings and execution result
Since
Moodle 3.1

◆ save_attempt_parameters()

static mod_quiz_external::save_attempt_parameters ( )
static

Describes the parameters for save_attempt.

Return values
external_function_parameters
Since
Moodle 3.1

◆ save_attempt_returns()

static mod_quiz_external::save_attempt_returns ( )
static

Describes the save_attempt return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ start_attempt()

static mod_quiz_external::start_attempt ( $quizid,
$preflightdata = [],
$forcenew = false )
static

Starts a new attempt at a quiz.

Parameters
int$quizidquiz instance id
array$preflightdatapreflight required data (like passwords)
bool$forcenewWhether to force a new attempt or not.
Return values
arrayof warnings and the attempt basic data
Since
Moodle 3.1

◆ start_attempt_parameters()

static mod_quiz_external::start_attempt_parameters ( )
static

Describes the parameters for start_attempt.

Return values
external_function_parameters
Since
Moodle 3.1

◆ start_attempt_returns()

static mod_quiz_external::start_attempt_returns ( )
static

Describes the start_attempt return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ validate_attempt()

static mod_quiz_external::validate_attempt ( $params,
$checkaccessrules = true,
$failifoverdue = true )
staticprotected

Utility function for validating a given attempt.

Parameters
array$paramsarray of parameters including the attemptid and preflight data
bool$checkaccessruleswhether to check the quiz access rules or not
bool$failifoverduewhether to return error if the attempt is overdue
Return values
arraycontaining the attempt object and access messages
Since
Moodle 3.1

◆ validate_attempt_review()

static mod_quiz_external::validate_attempt_review ( $params)
staticprotected

Validate an attempt finished for review.

The attempt would be reviewed by a user or a teacher.

Parameters
array$paramsArray of parameters including the attemptid
Return values
arraycontaining the attempt object and display options
Since
Moodle 3.1

◆ validate_quiz()

static mod_quiz_external::validate_quiz ( $quizid)
staticprotected

Utility function for validating a quiz.

Parameters
int$quizidquiz instance id
Return values
arrayarray containing the quiz, course, context and course module objects
Since
Moodle 3.1

◆ view_attempt()

static mod_quiz_external::view_attempt ( $attemptid,
$page,
$preflightdata = [] )
static

Trigger the attempt viewed event.

Parameters
int$attemptidattempt id
int$pagepage number
array$preflightdatapreflight required data (like passwords)
Return values
arrayof warnings and status result
Since
Moodle 3.1

◆ view_attempt_parameters()

static mod_quiz_external::view_attempt_parameters ( )
static

Describes the parameters for view_attempt.

Return values
external_function_parameters
Since
Moodle 3.1

◆ view_attempt_returns()

static mod_quiz_external::view_attempt_returns ( )
static

Describes the view_attempt return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ view_attempt_review()

static mod_quiz_external::view_attempt_review ( $attemptid)
static

Trigger the attempt reviewed event.

Parameters
int$attemptidattempt id
Return values
arrayof warnings and status result
Since
Moodle 3.1

◆ view_attempt_review_parameters()

static mod_quiz_external::view_attempt_review_parameters ( )
static

Describes the parameters for view_attempt_review.

Return values
external_function_parameters
Since
Moodle 3.1

◆ view_attempt_review_returns()

static mod_quiz_external::view_attempt_review_returns ( )
static

Describes the view_attempt_review return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ view_attempt_summary()

static mod_quiz_external::view_attempt_summary ( $attemptid,
$preflightdata = [] )
static

Trigger the attempt summary viewed event.

Parameters
int$attemptidattempt id
array$preflightdatapreflight required data (like passwords)
Return values
arrayof warnings and status result
Since
Moodle 3.1

◆ view_attempt_summary_parameters()

static mod_quiz_external::view_attempt_summary_parameters ( )
static

Describes the parameters for view_attempt_summary.

Return values
external_function_parameters
Since
Moodle 3.1

◆ view_attempt_summary_returns()

static mod_quiz_external::view_attempt_summary_returns ( )
static

Describes the view_attempt_summary return value.

Return values
external_single_structure
Since
Moodle 3.1

◆ view_quiz()

static mod_quiz_external::view_quiz ( $quizid)
static

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

Parameters
int$quizidquiz instance id
Return values
arrayof warnings and status result
Since
Moodle 3.1

◆ view_quiz_parameters()

static mod_quiz_external::view_quiz_parameters ( )
static

Describes the parameters for view_quiz.

Return values
external_function_parameters
Since
Moodle 3.1

◆ view_quiz_returns()

static mod_quiz_external::view_quiz_returns ( )
static

Describes the view_quiz return value.

Return values
external_single_structure
Since
Moodle 3.1

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