| Moodle APIs 4.3
    Moodle 4.3.6 (Build: 20240812) | 
A class encapsulating the settings for a quiz. More...
| Public Member Functions | |
| __construct ($quiz, $cm, $course, $getcontext=true) | |
| Constructor, assuming we already have the necessary data loaded. | |
| attempt_url ($attemptid, $page=0) | |
| Get the URL of a particular page within an attempt. | |
| cannot_review_message ($when, $short=false, int $attemptsubmittime=null) | |
| If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why. | |
| create_attempt_object ($attemptdata) | |
| Create a {. | |
| edit_url () | |
| Get the URL of this quiz's edit questions page. | |
| get_access_manager ($timenow) | |
| Return access_manager and instance of the access_manager class for this quiz at this time. | |
| get_all_question_types_used ($includepotential=false) | |
| Return all the question types used in this quiz. | |
| get_cm () | |
| Get the course-module object for this quiz. | |
| get_cmid () | |
| Get the course-module id for this quiz. | |
| get_context () | |
| Get the quiz context. | |
| get_course () | |
| Get the course settings object that this quiz belongs to. | |
| get_courseid () | |
| Get the id of the course this quiz belongs to. | |
| get_grade_calculator () | |
| Return the grade_calculator object for this quiz. | |
| get_navigation_method () | |
| Get the navigation method in use. | |
| get_num_attempts_allowed () | |
| How many attepts is the user allowed at this quiz? | |
| get_question ($id) | |
| Get a particular question in this quiz, by its id. | |
| get_questions (?array $questionids=null, bool $requirequestionfullyloaded=true) | |
| Get some of the question in this quiz. | |
| get_quiz () | |
| Get the quiz settings object. | |
| get_quiz_name () | |
| Get the quiz name. | |
| get_quizid () | |
| Get this quiz's id (in the quiz table). | |
| get_sections () | |
| Get all the sections in this quiz. | |
| get_structure () | |
| Get an instance of the {. | |
| has_capability ($capability, $userid=null, $doanything=true) | |
| Wrapper round the has_capability funciton that automatically passes in the quiz context. | |
| has_questions () | |
| Have any questions been added to this quiz yet? | |
| is_participant ($userid) | |
| Checks user enrollment in the current course. | |
| is_preview_user () | |
| Is the current user is someone who previews the quiz, rather than attempting it? | |
| load_questions ($deprecated=null) | |
| Fully load some or all of the questions for this quiz. | |
| navigation ($title) | |
| Probably not used any more, but left for backwards compatibility. | |
| preload_questions () | |
| Load just basic information about all the questions in this quiz. | |
| require_capability ($capability, $userid=null, $doanything=true) | |
| Wrapper round the require_capability function that automatically passes in the quiz context. | |
| review_url ($attemptid) | |
| Get the URL to review a particular quiz attempt. | |
| show_only_active_users () | |
| Check is only active users in course should be shown. | |
| start_attempt_url ($page=0) | |
| Get the URL to start/continue an attempt. | |
| summary_url ($attemptid) | |
| Get the URL for the summary page for a particular attempt. | |
| view_url () | |
| Get the URL of this quiz's view.php page. | |
| Static Public Member Functions | |
| static | create (int $quizid, int $userid=null) | 
| Static function to create a new quiz settings object from a quiz id, for a specific user. | |
| static | create_for_cmid (int $cmid, int $userid=null) | 
| Static function to create a new quiz settings object from a cmid, for a specific user. | |
| Protected Member Functions | |
| ensure_question_loaded ($id) | |
| Check that the definition of a particular question is loaded, and if not throw an exception. | |
| Static Protected Member Functions | |
| static | create_helper (stdClass $quiz, cm_info $cm, stdClass $course, ?int $userid) | 
| Helper used by the other factory methods. | |
| Protected Attributes | |
| access_manager | $accessmanager = null | 
| the access manager for this quiz. | |
| cm_info | $cm | 
| the course_module settings from the database. | |
| context | $context | 
| the quiz context. | |
| stdClass | $course | 
| the course settings from the database. | |
| bool | $ispreviewuser = null | 
| whether the current user has capability mod/quiz:preview. | |
| stdClass[] | $questions = null | 
| of questions augmented with slot information. | |
| stdClass | $quiz | 
| the quiz settings from the database. | |
| stdClass[] | $sections = null | 
| of quiz_section rows. | |
A class encapsulating the settings for a quiz.
When this class is initialised, it may have the settings adjusted to account for the overrides for a particular user. See the create methods.
Initially, it only loads a minimal amount of information about each question - loading extra information only when necessary or when asked. The class tracks which questions are loaded.
| mod_quiz\quiz_settings::__construct | ( | $quiz, | |
| $cm, | |||
| $course, | |||
| $getcontext = true ) | 
Constructor, assuming we already have the necessary data loaded.
| stdClass | $quiz | the row from the quiz table. | 
| stdClass | $cm | the course_module object for this quiz. | 
| stdClass | $course | the row from the course table for the course we belong to. | 
| bool | $getcontext | intended for testing - stops the constructor getting the context. | 
| mod_quiz\quiz_settings::attempt_url | ( | $attemptid, | |
| $page = 0 ) | 
Get the URL of a particular page within an attempt.
| int | $attemptid | the id of an attempt. | 
| int | $page | optional page number to go to in the attempt. | 
| moodle_url | the URL of that attempt. | 
| mod_quiz\quiz_settings::cannot_review_message | ( | $when, | |
| $short = false, | |||
| int | $attemptsubmittime = null ) | 
If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why.
| int | $when | One of the display_options\DURING, IMMEDIATELY_AFTER, LATER_WHILE_OPEN or AFTER_CLOSE constants. | 
| bool | $short | if true, return a shorter string. | 
| int | null | $attemptsubmittime | time this attempt was submitted. (Optional, but should be given.) | 
| string | an appropraite message. | 
| 
 | static | 
Static function to create a new quiz settings object from a quiz id, for a specific user.
| int | $quizid | the quiz id. | 
| int | null | $userid | the the userid (optional). If passed, relevant overrides are applied. | 
| quiz_settings | the new quiz settings object. | 
| mod_quiz\quiz_settings::create_attempt_object | ( | $attemptdata | ) | 
Create a {.
| stdClass | $attemptdata | row from the quiz_attempts table. | 
| quiz_attempt | the new quiz_attempt object. | 
| 
 | static | 
Static function to create a new quiz settings object from a cmid, for a specific user.
| int | $cmid | the course-module id. | 
| int | null | $userid | the the userid (optional). If passed, relevant overrides are applied. | 
| quiz_settings | the new quiz settings object. | 
| 
 | staticprotected | 
Helper used by the other factory methods.
| stdClass | $quiz | |
| cm_info | $cm | |
| stdClass | $course | |
| int | null | $userid | the the userid (optional). If passed, relevant overrides are applied. | 
| quiz_settings | the new quiz settings object. | 
| mod_quiz\quiz_settings::edit_url | ( | ) | 
Get the URL of this quiz's edit questions page.
| moodle_url | the URL of this quiz's edit page. | 
| 
 | protected | 
Check that the definition of a particular question is loaded, and if not throw an exception.
| int | $id | a question id. | 
| mod_quiz\quiz_settings::get_access_manager | ( | $timenow | ) | 
Return access_manager and instance of the access_manager class for this quiz at this time.
| int | $timenow | the current time as a unix timestamp. | 
| access_manager | an instance of the access_manager class for this quiz at this time. | 
| mod_quiz\quiz_settings::get_all_question_types_used | ( | $includepotential = false | ) | 
Return all the question types used in this quiz.
| boolean | $includepotential | if the quiz include random questions, setting this flag to true will make the function to return all the possible question types in the random questions category. | 
| array | a sorted array including the different question types. | 
| mod_quiz\quiz_settings::get_cm | ( | ) | 
Get the course-module object for this quiz.
| cm_info | the course_module object. | 
| mod_quiz\quiz_settings::get_cmid | ( | ) | 
Get the course-module id for this quiz.
| int | the course_module id. | 
| mod_quiz\quiz_settings::get_context | ( | ) | 
Get the quiz context.
| context_module | the module context for this quiz. | 
| mod_quiz\quiz_settings::get_course | ( | ) | 
Get the course settings object that this quiz belongs to.
| stdClass | the row of the course table. | 
| mod_quiz\quiz_settings::get_courseid | ( | ) | 
Get the id of the course this quiz belongs to.
| int | the course id. | 
| mod_quiz\quiz_settings::get_grade_calculator | ( | ) | 
Return the grade_calculator object for this quiz.
| grade_calculator | 
| mod_quiz\quiz_settings::get_navigation_method | ( | ) | 
Get the navigation method in use.
| int | QUIZ_NAVMETHOD_FREE or QUIZ_NAVMETHOD_SEQ. | 
| mod_quiz\quiz_settings::get_num_attempts_allowed | ( | ) | 
How many attepts is the user allowed at this quiz?
| int | the number of attempts allowed at this quiz (0 = infinite). | 
| mod_quiz\quiz_settings::get_question | ( | $id | ) | 
Get a particular question in this quiz, by its id.
| int | $id | the question id. | 
| stdClass | the question object with that id. | 
| mod_quiz\quiz_settings::get_questions | ( | ?array | $questionids = null, | 
| bool | $requirequestionfullyloaded = true ) | 
Get some of the question in this quiz.
| array | null | $questionids | question ids of the questions to load. null for all. | 
| bool | $requirequestionfullyloaded | Whether to require that a particular question is fully loaded. | 
| stdClass[] | the question data objects. | 
| mod_quiz\quiz_settings::get_quiz | ( | ) | 
Get the quiz settings object.
| stdClass | the row of the quiz table. | 
| mod_quiz\quiz_settings::get_quiz_name | ( | ) | 
Get the quiz name.
| string | the name of this quiz. | 
| mod_quiz\quiz_settings::get_quizid | ( | ) | 
Get this quiz's id (in the quiz table).
| int | the quiz id. | 
| mod_quiz\quiz_settings::get_sections | ( | ) | 
Get all the sections in this quiz.
| array | 0, 1, 2, ... => quiz_sections row from the database. | 
| mod_quiz\quiz_settings::get_structure | ( | ) | 
Get an instance of the {.
| structure | describes the questions in the quiz. | 
| mod_quiz\quiz_settings::has_capability | ( | $capability, | |
| $userid = null, | |||
| $doanything = true ) | 
Wrapper round the has_capability funciton that automatically passes in the quiz context.
| string | $capability | the name of the capability to check. For example mod/quiz:view. | 
| int | null | $userid | A user id. By default (null) checks the permissions of the current user. | 
| bool | $doanything | If false, ignore effect of admin role assignment. | 
| boolean | true if the user has this capability. Otherwise false. | 
| mod_quiz\quiz_settings::has_questions | ( | ) | 
Have any questions been added to this quiz yet?
| bool | whether any questions have been added to this quiz. | 
| mod_quiz\quiz_settings::is_participant | ( | $userid | ) | 
Checks user enrollment in the current course.
| int | $userid | the id of the user to check. | 
| bool | whether the user is enrolled. | 
| mod_quiz\quiz_settings::is_preview_user | ( | ) | 
Is the current user is someone who previews the quiz, rather than attempting it?
| bool | true user is a preview user. False, if they can do real attempts. | 
| mod_quiz\quiz_settings::load_questions | ( | $deprecated = null | ) | 
Fully load some or all of the questions for this quiz.
You must call {
| array | null | $deprecated | no longer supported (it was not used). | 
| mod_quiz\quiz_settings::navigation | ( | $title | ) | 
Probably not used any more, but left for backwards compatibility.
| string | $title | the name of this particular quiz page. | 
| string | always returns ''. | 
| mod_quiz\quiz_settings::require_capability | ( | $capability, | |
| $userid = null, | |||
| $doanything = true ) | 
Wrapper round the require_capability function that automatically passes in the quiz context.
| string | $capability | the name of the capability to check. For example mod/quiz:view. | 
| int | null | $userid | A user id. By default (null) checks the permissions of the current user. | 
| bool | $doanything | If false, ignore effect of admin role assignment. | 
| mod_quiz\quiz_settings::review_url | ( | $attemptid | ) | 
Get the URL to review a particular quiz attempt.
| int | $attemptid | the id of an attempt. | 
| string | the URL of the review of that attempt. | 
| mod_quiz\quiz_settings::show_only_active_users | ( | ) | 
Check is only active users in course should be shown.
| bool | true if only active users should be shown. | 
| mod_quiz\quiz_settings::start_attempt_url | ( | $page = 0 | ) | 
Get the URL to start/continue an attempt.
| int | $page | page in the attempt to start on (optional). | 
| moodle_url | the URL of this quiz's edit page. Needs to be POSTed to with a cmid parameter. | 
| mod_quiz\quiz_settings::summary_url | ( | $attemptid | ) | 
Get the URL for the summary page for a particular attempt.
| int | $attemptid | the id of an attempt. | 
| string | the URL of the review of that attempt. | 
| mod_quiz\quiz_settings::view_url | ( | ) | 
Get the URL of this quiz's view.php page.
| moodle_url | the URL of this quiz's view page. | 
| 
 | protected | 
of questions augmented with slot information.
For non-random questions, the array key is question id. For random quesions it is 's' . $slotid. probalby best to use ->questionid field of the object instead.