Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Static Public Member Functions | |
static | call_external_function ($function, $args, $ajaxonly=false) |
Call an external function validating all params/returns correctly. More... | |
static | clean_returnvalue (external_description $description, $response) |
Clean response If a response attribute is unknown from the description, we just ignore the attribute. More... | |
static | external_function_info ($function, $strictness=MUST_EXIST) |
Returns detailed function information. More... | |
static | get_attempt_access_information ($quizid, $attemptid=0) |
Return access information for a given attempt in a quiz. More... | |
static | get_attempt_access_information_parameters () |
Describes the parameters for get_attempt_access_information. More... | |
static | get_attempt_access_information_returns () |
Describes the get_attempt_access_information return value. More... | |
static | get_attempt_data ($attemptid, $page, $preflightdata=array()) |
Returns information for the given attempt page for a quiz attempt in progress. More... | |
static | get_attempt_data_parameters () |
Describes the parameters for get_attempt_data. More... | |
static | get_attempt_data_returns () |
Describes the get_attempt_data return value. More... | |
static | get_attempt_review ($attemptid, $page=-1) |
Returns review information for the given finished attempt, can be used by users or teachers. More... | |
static | get_attempt_review_parameters () |
Describes the parameters for get_attempt_review. More... | |
static | get_attempt_review_returns () |
Describes the get_attempt_review return value. More... | |
static | get_attempt_summary ($attemptid, $preflightdata=array()) |
Returns a summary of a quiz attempt before it is submitted. More... | |
static | get_attempt_summary_parameters () |
Describes the parameters for get_attempt_summary. More... | |
static | get_attempt_summary_returns () |
Describes the get_attempt_summary return value. More... | |
static | get_combined_review_options ($quizid, $userid=0) |
Combines the review options from a number of different quiz attempts. More... | |
static | get_combined_review_options_parameters () |
Describes the parameters for get_combined_review_options. More... | |
static | get_combined_review_options_returns () |
Describes the get_combined_review_options return value. More... | |
static | get_quiz_access_information ($quizid) |
Return access information for a given quiz. More... | |
static | get_quiz_access_information_parameters () |
Describes the parameters for get_quiz_access_information. More... | |
static | get_quiz_access_information_returns () |
Describes the get_quiz_access_information return value. More... | |
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. More... | |
static | get_quiz_feedback_for_grade_parameters () |
Describes the parameters for view_quiz. More... | |
static | get_quiz_feedback_for_grade_returns () |
Describes the get_quiz_feedback_for_grade return value. More... | |
static | get_quiz_required_qtypes ($quizid) |
Return the potential question types that would be required for a given quiz. More... | |
static | get_quiz_required_qtypes_parameters () |
Describes the parameters for get_quiz_required_qtypes. More... | |
static | get_quiz_required_qtypes_returns () |
Describes the get_quiz_required_qtypes return value. More... | |
static | get_quizzes_by_courses ($courseids=array()) |
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. More... | |
static | get_quizzes_by_courses_parameters () |
Describes the parameters for get_quizzes_by_courses. More... | |
static | get_quizzes_by_courses_returns () |
Describes the get_quizzes_by_courses return value. More... | |
static | get_user_attempts ($quizid, $userid=0, $status='finished', $includepreviews=false) |
Return a list of attempts for the given quiz and user. More... | |
static | get_user_attempts_parameters () |
Describes the parameters for get_user_attempts. More... | |
static | get_user_attempts_returns () |
Describes the get_user_attempts return value. More... | |
static | get_user_best_grade ($quizid, $userid=0) |
Get the best current grade for the given user on a quiz. More... | |
static | get_user_best_grade_parameters () |
Describes the parameters for get_user_best_grade. More... | |
static | get_user_best_grade_returns () |
Describes the get_user_best_grade return value. More... | |
static | process_attempt ($attemptid, $data, $finishattempt=false, $timeup=false, $preflightdata=array()) |
Process responses during an attempt at a quiz and also deals with attempts finishing. More... | |
static | process_attempt_parameters () |
Describes the parameters for process_attempt. More... | |
static | process_attempt_returns () |
Describes the process_attempt return value. More... | |
static | save_attempt ($attemptid, $data, $preflightdata=array()) |
Processes save requests during the quiz. More... | |
static | save_attempt_parameters () |
Describes the parameters for save_attempt. More... | |
static | save_attempt_returns () |
Describes the save_attempt return value. More... | |
static | set_context_restriction ($context) |
Set context restriction for all following subsequent function calls. More... | |
static | set_timeout ($seconds=360) |
This method has to be called before every operation that takes a longer time to finish! More... | |
static | start_attempt ($quizid, $preflightdata=array(), $forcenew=false) |
Starts a new attempt at a quiz. More... | |
static | start_attempt_parameters () |
Describes the parameters for start_attempt. More... | |
static | start_attempt_returns () |
Describes the start_attempt return value. More... | |
static | validate_context ($context) |
Makes sure user may execute functions in this context. More... | |
static | validate_parameters (external_description $description, $params) |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. More... | |
static | view_attempt ($attemptid, $page, $preflightdata=array()) |
Trigger the attempt viewed event. More... | |
static | view_attempt_parameters () |
Describes the parameters for view_attempt. More... | |
static | view_attempt_returns () |
Describes the view_attempt return value. More... | |
static | view_attempt_review ($attemptid) |
Trigger the attempt reviewed event. More... | |
static | view_attempt_review_parameters () |
Describes the parameters for view_attempt_review. More... | |
static | view_attempt_review_returns () |
Describes the view_attempt_review return value. More... | |
static | view_attempt_summary ($attemptid, $preflightdata=array()) |
Trigger the attempt summary viewed event. More... | |
static | view_attempt_summary_parameters () |
Describes the parameters for view_attempt_summary. More... | |
static | view_attempt_summary_returns () |
Describes the view_attempt_summary return value. More... | |
static | view_quiz ($quizid) |
Trigger the course module viewed event and update the module completion status. More... | |
static | view_quiz_parameters () |
Describes the parameters for view_quiz. More... | |
static | view_quiz_returns () |
Describes the view_quiz return value. More... | |
Static Protected Member Functions | |
static | get_context_from_params ($param) |
Get context from passed parameters. More... | |
static | get_context_parameters () |
Returns a prepared structure to use a context parameters. More... | |
static | validate_attempt ($params, $checkaccessrules=true, $failifoverdue=true) |
Utility function for validating a given attempt. More... | |
static | validate_attempt_review ($params) |
Validate an attempt finished for review. More... | |
static | validate_quiz ($quizid) |
Utility function for validating a quiz. More... | |
|
staticinherited |
Call an external function validating all params/returns correctly.
Note that an external function may modify the state of the current page, so this wrapper saves and restores tha PAGE and COURSE global variables before/after calling the external function.
string | $function | A webservice function name. |
array | $args | Params array (named params) |
boolean | $ajaxonly | If true, an extra check will be peformed to see if ajax is required. |
array | containing keys for error (bool), exception and data. |
|
staticinherited |
Clean response If a response attribute is unknown from the description, we just ignore the attribute.
If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values.
external_description | $description | description of the return values |
mixed | $response | the actual response |
mixed | response with added defaults for optional items, invalid_response_exception thrown if any problem found |
|
staticinherited |
Returns detailed function information.
string | object | $function | name of external function or record from external_function |
int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record or multiple records found |
stdClass | description or false if not found or exception thrown |
|
static |
Return access information for a given attempt in a quiz.
int | $quizid | quiz instance id |
int | $attemptid | attempt id, 0 for the user last attempt if exists |
array | of warnings and the access information |
moodle_quiz_exception |
|
static |
Describes the parameters for get_attempt_access_information.
external_function_parameters |
|
static |
Describes the get_attempt_access_information return value.
external_single_structure |
|
static |
Returns information for the given attempt page for a quiz attempt in progress.
int | $attemptid | attempt id |
int | $page | page number |
array | $preflightdata | preflight required data (like passwords) |
array | of warnings and the attempt data, next page, message and questions |
moodle_quiz_exceptions |
|
static |
Describes the parameters for get_attempt_data.
external_function_parameters |
|
static |
Describes the get_attempt_data return value.
external_single_structure |
|
static |
Returns review information for the given finished attempt, can be used by users or teachers.
int | $attemptid | attempt id |
int | $page | page number, empty for all the questions in all the pages |
array | of warnings and the attempt data, feedback and questions |
moodle_exception | |
moodle_quiz_exception |
|
static |
Describes the parameters for get_attempt_review.
external_function_parameters |
|
static |
Describes the get_attempt_review return value.
external_single_structure |
|
static |
Returns a summary of a quiz attempt before it is submitted.
int | $attemptid | attempt id |
int | $preflightdata | preflight required data (like passwords) |
array | of warnings and the attempt summary data for each question |
|
static |
Describes the parameters for get_attempt_summary.
external_function_parameters |
|
static |
Describes the get_attempt_summary return value.
external_single_structure |
|
static |
Combines the review options from a number of different quiz attempts.
int | $quizid | quiz instance id |
int | $userid | user id (empty for current user) |
array | of warnings and the review options |
|
static |
Describes the parameters for get_combined_review_options.
external_function_parameters |
|
static |
Describes the get_combined_review_options return value.
external_single_structure |
|
staticprotectedinherited |
Get context from passed parameters.
The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid.
See context_helper::get_all_levels() for a list of valid context levels.
array | $param |
invalid_parameter_exception |
context |
|
staticprotectedinherited |
Returns a prepared structure to use a context parameters.
external_single_structure |
Reimplemented in core_competency\external, and tool_lp\external.
|
static |
Return access information for a given quiz.
int | $quizid | quiz instance id |
array | of warnings and the access information |
moodle_quiz_exception |
|
static |
Describes the parameters for get_quiz_access_information.
external_function_parameters |
|
static |
Describes the get_quiz_access_information return value.
external_single_structure |
|
static |
Get the feedback text that should be show to a student who got the given grade in the given quiz.
int | $quizid | quiz instance id |
float | $grade | the grade to check |
array | of warnings and status result |
moodle_exception |
|
static |
|
static |
Describes the get_quiz_feedback_for_grade return value.
external_single_structure |
|
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.
int | $quizid | quiz instance id |
array | of warnings and the access information |
moodle_quiz_exception |
|
static |
Describes the parameters for get_quiz_required_qtypes.
external_function_parameters |
|
static |
Describes the get_quiz_required_qtypes return value.
external_single_structure |
|
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.
array | $courseids | Array of course ids |
array | of quizzes details |
|
static |
Describes the parameters for get_quizzes_by_courses.
external_function_parameters |
|
static |
Describes the get_quizzes_by_courses return value.
external_single_structure |
|
static |
Return a list of attempts for the given quiz and user.
int | $quizid | quiz instance id |
int | $userid | user id |
string | $status | quiz status: all, finished or unfinished |
bool | $includepreviews | whether to include previews or not |
array | of warnings and the list of attempts |
invalid_parameter_exception |
|
static |
Describes the parameters for get_user_attempts.
external_function_parameters |
|
static |
Describes the get_user_attempts return value.
external_single_structure |
|
static |
Get the best current grade for the given user on a quiz.
int | $quizid | quiz instance id |
int | $userid | user id |
array | of warnings and the grade information |
|
static |
Describes the parameters for get_user_best_grade.
external_function_parameters |
|
static |
Describes the get_user_best_grade return value.
external_single_structure |
|
static |
Process responses during an attempt at a quiz and also deals with attempts finishing.
int | $attemptid | attempt id |
array | $data | the data to be saved |
bool | $finishattempt | whether to finish or not the attempt |
bool | $timeup | whether the WS was called by a timer when the time is up |
array | $preflightdata | preflight required data (like passwords) |
array | of warnings and the attempt state after the processing |
|
static |
Describes the parameters for process_attempt.
external_function_parameters |
|
static |
|
static |
Processes save requests during the quiz.
This function is intended for the quiz auto-save feature.
int | $attemptid | attempt id |
array | $data | the data to be saved |
array | $preflightdata | preflight required data (like passwords) |
array | of warnings and execution result |
|
static |
Describes the parameters for save_attempt.
external_function_parameters |
|
static |
|
staticinherited |
Set context restriction for all following subsequent function calls.
stdClass | $context | the context restriction |
|
staticinherited |
This method has to be called before every operation that takes a longer time to finish!
int | $seconds | max expected time the next operation needs |
|
static |
Starts a new attempt at a quiz.
int | $quizid | quiz instance id |
array | $preflightdata | preflight required data (like passwords) |
bool | $forcenew | Whether to force a new attempt or not. |
array | of warnings and the attempt basic data |
moodle_quiz_exception |
|
static |
Describes the parameters for start_attempt.
external_function_parameters |
|
static |
|
staticprotected |
Utility function for validating a given attempt.
array | $params | array of parameters including the attemptid and preflight data |
bool | $checkaccessrules | whether to check the quiz access rules or not |
bool | $failifoverdue | whether to return error if the attempt is overdue |
array | containing the attempt object and access messages |
moodle_quiz_exception |
|
staticprotected |
Validate an attempt finished for review.
The attempt would be reviewed by a user or a teacher.
array | $params | Array of parameters including the attemptid |
array | containing the attempt object and display options |
moodle_exception | |
moodle_quiz_exception |
|
staticinherited |
Makes sure user may execute functions in this context.
stdClass | $context |
|
staticinherited |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown.
This is a simple recursive method which is intended to be called from each implementation method of external API.
external_description | $description | description of parameters |
mixed | $params | the actual parameters |
mixed | params with added defaults for optional items, invalid_parameters_exception thrown if any problem found |
|
staticprotected |
Utility function for validating a quiz.
int | $quizid | quiz instance id |
array | array containing the quiz, course, context and course module objects |
|
static |
Trigger the attempt viewed event.
int | $attemptid | attempt id |
int | $page | page number |
array | $preflightdata | preflight required data (like passwords) |
array | of warnings and status result |
|
static |
Describes the parameters for view_attempt.
external_function_parameters |
|
static |
|
static |
Trigger the attempt reviewed event.
int | $attemptid | attempt id |
array | of warnings and status result |
|
static |
Describes the parameters for view_attempt_review.
external_function_parameters |
|
static |
Describes the view_attempt_review return value.
external_single_structure |
|
static |
Trigger the attempt summary viewed event.
int | $attemptid | attempt id |
array | $preflightdata | preflight required data (like passwords) |
array | of warnings and status result |
|
static |
Describes the parameters for view_attempt_summary.
external_function_parameters |
|
static |
Describes the view_attempt_summary return value.
external_single_structure |
|
static |
Trigger the course module viewed event and update the module completion status.
int | $quizid | quiz instance id |
array | of warnings and status result |
moodle_exception |
|
static |
|
static |