Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
Back-end code for handling data about quizzes and the current user's attempt. There are classes for loading all the information about a quiz and attempts, and for displaying the navigation panel.
Copyright: | 2008 onwards Tim Hunt |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 2974 lines (113 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
moodle_quiz_exception:: (1 method):
__construct()
quiz:: (37 methods):
__construct()
create()
create_attempt_object()
preload_questions()
load_questions()
get_structure()
get_courseid()
get_course()
get_quizid()
get_quiz()
get_quiz_name()
get_navigation_method()
get_num_attempts_allowed()
get_cmid()
get_cm()
get_context()
is_preview_user()
is_participant()
show_only_active_users()
has_questions()
get_question()
get_questions()
get_sections()
get_access_manager()
has_capability()
require_capability()
view_url()
edit_url()
attempt_url()
start_attempt_url()
review_url()
summary_url()
confirm_start_attempt_message()
cannot_review_message()
navigation()
ensure_question_loaded()
get_all_question_types_used()
quiz_attempt:: (117 methods):
__construct()
create_helper()
create()
create_from_usage_id()
state_name()
load_questions()
preload_all_attempt_step_users()
link_sections_and_slots()
determine_layout()
number_questions()
force_page_number_into_range()
get_quiz()
get_quizobj()
get_courseid()
get_course()
get_quizid()
get_quiz_name()
get_navigation_method()
get_cm()
get_cmid()
is_preview_user()
get_num_attempts_allowed()
get_num_pages()
get_access_manager()
get_attemptid()
get_uniqueid()
get_attempt()
get_attempt_number()
get_state()
get_userid()
get_currentpage()
get_sum_marks()
is_finished()
is_preview()
is_own_attempt()
is_own_preview()
is_review_allowed()
has_response_to_at_least_one_graded_question()
requires_manual_grading()
get_additional_summary_data()
get_overall_feedback()
has_capability()
require_capability()
check_review_capability()
can_navigate_to()
get_attempt_state()
get_display_options()
get_display_options_with_edit_link()
is_last_page()
get_slots()
get_active_slots()
get_question_usage()
get_question_attempt()
all_question_attempts_originally_in_slot()
is_real_question()
is_question_flagged()
is_blocked_by_previous_question()
can_question_be_redone_now()
get_original_slot()
get_question_number()
get_heading_before_slot()
get_question_page()
get_question_name()
get_question_state()
get_question_status()
get_question_state_class()
get_question_mark()
get_question_action_time()
get_question_type_name()
get_time_left_display()
get_submitted_date()
get_due_date()
view_url()
start_attempt_url()
attempt_page_title()
attempt_url()
summary_page_title()
summary_url()
processattempt_url()
review_page_title()
review_url()
get_default_show_all()
cannot_review_message()
get_html_head_contributions()
get_question_html_head_contributions()
restart_preview_button()
render_question()
render_question_helper()
make_blocked_question_placeholder()
render_question_at_step()
render_question_for_commenting()
check_file_access()
get_navigation_panel()
links_to_other_attempts()
links_to_other_redos()
handle_if_time_expired()
process_submitted_actions()
process_redo_question()
process_auto_save()
save_question_flags()
process_finish()
update_timecheckstate()
process_going_overdue()
process_abandon()
fire_state_transition_event()
page_and_question_url()
process_attempt()
check_page_access()
set_currentpage()
fire_attempt_viewed_event()
fire_attempt_updated_event()
fire_attempt_autosaved_event()
fire_attempt_question_restarted_event()
fire_attempt_summary_viewed_event()
fire_attempt_reviewed_event()
fire_attempt_manual_grading_completed_event()
set_offline_modified_time()
quiz_nav_section_heading:: (1 method):
__construct()
quiz_nav_question_button:: (0 methods):
quiz_nav_panel_base:: (7 methods):
__construct()
get_question_buttons()
get_state_string()
render_before_button_bits()
render_restart_preview_link()
user_picture()
get_button_container_class()
quiz_attempt_nav_panel:: (3 methods):
get_question_url()
render_before_button_bits()
render_end_bits()
quiz_review_nav_panel:: (2 methods):
get_question_url()
render_end_bits()
Class: moodle_quiz_exception - X-Ref
Class for quiz exceptions. Just saves a couple of arguments on the__construct($quizobj, $errorcode, $a = null, $link = '', $debuginfo = null) X-Ref |
Constructor. param: quiz $quizobj the quiz the error relates to. param: string $errorcode The name of the string from error.php to print. param: mixed $a Extra words and phrases that might be required in the error string. param: string $link The url where the user will be prompted to continue. param: string|null $debuginfo optional debugging information. |
__construct($quiz, $cm, $course, $getcontext = true) X-Ref |
Constructor, assuming we already have the necessary data loaded. param: object $quiz the row from the quiz table. param: object $cm the course_module object for this quiz. param: object $course the row from the course table for the course we belong to. param: bool $getcontext intended for testing - stops the constructor getting the context. |
create($quizid, $userid = null) X-Ref |
Static function to create a new quiz object for a specific user. return: quiz the new quiz object. param: int $quizid the the quiz id. param: int|null $userid the the userid (optional). If passed, relevant overrides are applied. |
create_attempt_object($attemptdata) X-Ref |
Create a {@link quiz_attempt} for an attempt at this quiz. return: quiz_attempt the new quiz_attempt object. param: object $attemptdata row from the quiz_attempts table. |
preload_questions() X-Ref |
Load just basic information about all the questions in this quiz. |
load_questions($deprecated = null) X-Ref |
Fully load some or all of the questions for this quiz. You must call {@link preload_questions()} first. param: array|null $deprecated no longer supported (it was not used). |
get_structure() X-Ref |
Get an instance of the {@link \mod_quiz\structure} class for this quiz. return: \mod_quiz\structure describes the questions in the quiz. |
get_courseid() X-Ref |
Get the id of the course this quiz belongs to. return: int the course id. |
get_course() X-Ref |
Get the course settings object that this quiz belongs to. return: object the row of the course table. |
get_quizid() X-Ref |
Get this quiz's id (in the quiz table). return: int the quiz id. |
get_quiz() X-Ref |
Get the quiz settings object. return: stdClass the row of the quiz table. |
get_quiz_name() X-Ref |
Get the quiz name. return: string the name of this quiz. |
get_navigation_method() X-Ref |
Get the navigation method in use. return: int QUIZ_NAVMETHOD_FREE or QUIZ_NAVMETHOD_SEQ. |
get_num_attempts_allowed() X-Ref |
No description |
get_cmid() X-Ref |
Get the course-module id for this quiz. return: int the course_module id. |
get_cm() X-Ref |
Get the course-module object for this quiz. return: object the course_module object. |
get_context() X-Ref |
Get the quiz context. return: context_module the module context for this quiz. |
is_preview_user() X-Ref |
return: bool whether the current user is someone who previews the quiz, |
is_participant($userid) X-Ref |
Checks user enrollment in the current course. return: bool whether the user is enrolled. param: int $userid the id of the user to check. |
show_only_active_users() X-Ref |
Check is only active users in course should be shown. return: bool true if only active users should be shown. |
has_questions() X-Ref |
return: bool whether any questions have been added to this quiz. |
get_question($id) X-Ref |
return: stdClass the question object with that id. param: int $id the question id. |
get_questions($questionids = null) X-Ref |
return: stdClass[] the question data objects. param: array|null $questionids question ids of the questions to load. null for all. |
get_sections() X-Ref |
Get all the sections in this quiz. return: array 0, 1, 2, ... => quiz_sections row from the database. |
get_access_manager($timenow) X-Ref |
Return quiz_access_manager and instance of the quiz_access_manager class for this quiz at this time. return: quiz_access_manager and instance of the quiz_access_manager class param: int $timenow the current time as a unix timestamp. |
has_capability($capability, $userid = null, $doanything = true) X-Ref |
Wrapper round the has_capability funciton that automatically passes in the quiz context. return: boolean true if the user has this capability. Otherwise false. param: string $capability the name of the capability to check. For example mod/quiz:view. param: int|null $userid A user id. By default (null) checks the permissions of the current user. param: bool $doanything If false, ignore effect of admin role assignment. |
require_capability($capability, $userid = null, $doanything = true) X-Ref |
Wrapper round the require_capability function that automatically passes in the quiz context. param: string $capability the name of the capability to check. For example mod/quiz:view. param: int|null $userid A user id. By default (null) checks the permissions of the current user. param: bool $doanything If false, ignore effect of admin role assignment. |
view_url() X-Ref |
return: string the URL of this quiz's view page. |
edit_url() X-Ref |
return: string the URL of this quiz's edit page. |
attempt_url($attemptid, $page = 0) X-Ref |
return: string the URL of that attempt. param: int $attemptid the id of an attempt. param: int $page optional page number to go to in the attempt. |
start_attempt_url($page = 0) X-Ref |
Get the URL to start/continue an attempt. return: moodle_url the URL of this quiz's edit page. Needs to be POSTed to with a cmid parameter. param: int $page page in the attempt to start on (optional). |
review_url($attemptid) X-Ref |
return: string the URL of the review of that attempt. param: int $attemptid the id of an attempt. |
summary_url($attemptid) X-Ref |
return: string the URL of the review of that attempt. param: int $attemptid the id of an attempt. |
confirm_start_attempt_message($notused) X-Ref |
return: string an empty string. param: bool $notused not used. |
cannot_review_message($when, $short = false) X-Ref |
If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why. return: string an appropraite message. param: int $when One of the mod_quiz_display_options::DURING, param: bool $short if true, return a shorter string. |
navigation($title) X-Ref |
Probably not used any more, but left for backwards compatibility. return: string always returns ''. param: string $title the name of this particular quiz page. |
ensure_question_loaded($id) X-Ref |
Check that the definition of a particular question is loaded, and if not throw an exception. param: int $id a question id. |
get_all_question_types_used($includepotential = false) X-Ref |
Return all the question types used in this quiz. return: array a sorted array including the different question types. param: boolean $includepotential if the quiz include random questions, |
Class: quiz_attempt - X-Ref
This class extends the quiz class to hold data about the state of a particular attempt,__construct($attempt, $quiz, $cm, $course, $loadquestions = true) X-Ref |
Constructor assuming we already have the necessary data loaded. param: object $attempt the row of the quiz_attempts table. param: object $quiz the quiz object for this attempt and user. param: object $cm the course_module object for this quiz. param: object $course the row from the course table for the course we belong to. param: bool $loadquestions (optional) if true, the default, load all the details |
create_helper($conditions) X-Ref |
Used by {create()} and {create_from_usage_id()}. return: quiz_attempt the desired instance of this class. param: array $conditions passed to $DB->get_record('quiz_attempts', $conditions). |
create($attemptid) X-Ref |
Static function to create a new quiz_attempt object given an attemptid. return: quiz_attempt the new quiz_attempt object param: int $attemptid the attempt id. |
create_from_usage_id($usageid) X-Ref |
Static function to create a new quiz_attempt object given a usage id. return: quiz_attempt the new quiz_attempt object param: int $usageid the attempt usage id. |
state_name($state) X-Ref |
return: string the human-readable state name. param: string $state one of the state constants like IN_PROGRESS. |
load_questions() X-Ref |
This method can be called later if the object was constructed with $loadqusetions = false. |
preload_all_attempt_step_users() X-Ref |
Preload all attempt step users to show in Response history. |
link_sections_and_slots() X-Ref |
Let each slot know which section it is part of. |
determine_layout() X-Ref |
Parse attempt->layout to populate the other arrays the represent the layout. |
number_questions() X-Ref |
Work out the number to display for each question/slot. |
force_page_number_into_range($page) X-Ref |
If the given page number is out of range (before the first page, or after the last page, chnage it to be within range). return: int a safe page number to use. param: int $page the requested page number. |
get_quiz() X-Ref |
No description |
get_quizobj() X-Ref |
No description |
get_courseid() X-Ref |
No description |
get_course() X-Ref |
Get the course settings object. return: stdClass the course settings object. |
get_quizid() X-Ref |
No description |
get_quiz_name() X-Ref |
No description |
get_navigation_method() X-Ref |
No description |
get_cm() X-Ref |
No description |
get_cmid() X-Ref |
Get the course-module id. return: int the course_module id. |
is_preview_user() X-Ref |
return: bool whether the current user is someone who previews the quiz, |
get_num_attempts_allowed() X-Ref |
No description |
get_num_pages() X-Ref |
No description |
get_access_manager($timenow) X-Ref |
return: quiz_access_manager and instance of the quiz_access_manager class param: int $timenow the current time as a unix timestamp. |
get_attemptid() X-Ref |
No description |
get_uniqueid() X-Ref |
No description |
get_attempt() X-Ref |
No description |
get_attempt_number() X-Ref |
No description |
get_state() X-Ref |
No description |
get_userid() X-Ref |
No description |
get_currentpage() X-Ref |
No description |
get_sum_marks() X-Ref |
No description |
is_finished() X-Ref |
return: bool whether this attempt has been finished (true) or is still |
is_preview() X-Ref |
No description |
is_own_attempt() X-Ref |
Is this someone dealing with their own attempt or preview? return: bool true => own attempt/preview. false => reviewing someone else's. |
is_own_preview() X-Ref |
return: bool whether this attempt is a preview belonging to the current user. |
is_review_allowed() X-Ref |
Is the current user allowed to review this attempt. This applies when {@link is_own_attempt()} returns false. return: bool whether the review should be allowed. |
has_response_to_at_least_one_graded_question() X-Ref |
Has the student, in this attempt, engaged with the quiz in a non-trivial way? That is, is there any question worth a non-zero number of marks, where the student has made some response that we have saved? return: bool true if we have saved a response for at least one graded question. |
requires_manual_grading() X-Ref |
Do any questions in this attempt need to be graded manually? return: bool True if we have at least one question still needs manual grading. |
get_additional_summary_data(question_display_options $options) X-Ref |
Get extra summary information about this attempt. Some behaviours may be able to provide interesting summary information about the attempt as a whole, and this method provides access to that data. To see how this works, try setting a quiz to one of the CBM behaviours, and then look at the extra information displayed at the top of the quiz review page once you have sumitted an attempt. In the return value, the array keys are identifiers of the form qbehaviour_behaviourname_meaningfullkey. For qbehaviour_deferredcbm_highsummary. The values are arrays with two items, title and content. Each of these will be either a string, or a renderable. return: array as described above. param: question_display_options $options the display options for this quiz attempt at this time. |
get_overall_feedback($grade) X-Ref |
Get the overall feedback corresponding to a particular mark. return: string the feedback. param: number $grade a particular grade. |
has_capability($capability, $userid = null, $doanything = true) X-Ref |
Wrapper round the has_capability funciton that automatically passes in the quiz context. return: boolean true if the user has this capability. Otherwise false. param: string $capability the name of the capability to check. For example mod/forum:view. param: int|null $userid A user id. By default (null) checks the permissions of the current user. param: bool $doanything If false, ignore effect of admin role assignment. |
require_capability($capability, $userid = null, $doanything = true) X-Ref |
Wrapper round the require_capability function that automatically passes in the quiz context. param: string $capability the name of the capability to check. For example mod/forum:view. param: int|null $userid A user id. By default (null) checks the permissions of the current user. param: bool $doanything If false, ignore effect of admin role assignment. |
check_review_capability() X-Ref |
Check the appropriate capability to see whether this user may review their own attempt. If not, prints an error. |
can_navigate_to($slot) X-Ref |
Checks whether a user may navigate to a particular slot. return: bool true if the navigation should be allowed. param: int $slot the target slot (currently does not affect the answer). |
get_attempt_state() X-Ref |
return: int one of the mod_quiz_display_options::DURING, |
get_display_options($reviewing) X-Ref |
Wrapper that the correct mod_quiz_display_options for this quiz at the moment. return: question_display_options the render options for this user on this attempt. param: bool $reviewing true for options when reviewing, false for when attempting. |
get_display_options_with_edit_link($reviewing, $slot, $thispageurl) X-Ref |
Wrapper that the correct mod_quiz_display_options for this quiz at the moment. return: question_display_options the render options for this user on this param: bool $reviewing true for review page, else attempt page. param: int $slot which question is being displayed. param: moodle_url $thispageurl to return to after the editing form is |
is_last_page($page) X-Ref |
return: bool true if this is the last page of the quiz. param: int $page page number |
get_slots($page = 'all') X-Ref |
Return the list of slot numbers for either a given page of the quiz, or for the whole quiz. return: array the requested list of slot numbers. param: mixed $page string 'all' or integer page number. |
get_active_slots($page = 'all') X-Ref |
Return the list of slot numbers for either a given page of the quiz, or for the whole quiz. return: array the requested list of slot numbers. param: mixed $page string 'all' or integer page number. |
get_question_usage() X-Ref |
Helper method for unit tests. Get the underlying question usage object. return: question_usage_by_activity the usage. |
get_question_attempt($slot) X-Ref |
Get the question_attempt object for a particular question in this attempt. return: question_attempt the requested question_attempt. param: int $slot the number used to identify this question within this attempt. |
all_question_attempts_originally_in_slot($slot) X-Ref |
Get all the question_attempt objects that have ever appeared in a given slot. This relates to the 'Try another question like this one' feature. return: question_attempt[] the attempts. param: int $slot the number used to identify this question within this attempt. |
is_real_question($slot) X-Ref |
Is a particular question in this attempt a real question, or something like a description. return: int whether that question is a real question. Actually returns the param: int $slot the number used to identify this question within this attempt. |
is_question_flagged($slot) X-Ref |
Is a particular question in this attempt a real question, or something like a description. return: bool whether that question is a real question. param: int $slot the number used to identify this question within this attempt. |
is_blocked_by_previous_question($slot) X-Ref |
Checks whether the question in this slot requires the previous question to have been completed. return: bool whether the previous question must have been completed before param: int $slot the number used to identify this question within this attempt. |
can_question_be_redone_now($slot) X-Ref |
Is it possible for this question to be re-started within this attempt? return: bool whether the student should be given the option to restart this question now. param: int $slot the number used to identify this question within this attempt. |
get_original_slot($slot) X-Ref |
Given a slot in this attempt, which may or not be a redone question, return the original slot. return: int the slot where this question was originally. param: int $slot identifies a particular question in this attempt. |
get_question_number($slot) X-Ref |
Get the displayed question number for a slot. return: string the displayed question number for the question in this slot. param: int $slot the number used to identify this question within this attempt. |
get_heading_before_slot($slot) X-Ref |
If the section heading, if any, that should come just before this slot. return: string the required heading, or null if there is not one here. param: int $slot identifies a particular question in this attempt. |
get_question_page($slot) X-Ref |
Return the page of the quiz where this question appears. return: int the page of the quiz this question appears on. param: int $slot the number used to identify this question within this attempt. |
get_question_name($slot) X-Ref |
Return the grade obtained on a particular question, if the user is permitted to see it. You must previously have called load_question_states to load the state data about this question. return: string the formatted grade, to the number of decimal places specified param: int $slot the number used to identify this question within this attempt. |
get_question_state($slot) X-Ref |
Return the {@link question_state} that this question is in. return: question_state the state this question is in. param: int $slot the number used to identify this question within this attempt. |
get_question_status($slot, $showcorrectness) X-Ref |
Return the grade obtained on a particular question, if the user is permitted to see it. You must previously have called load_question_states to load the state data about this question. return: string the formatted grade, to the number of decimal places specified param: int $slot the number used to identify this question within this attempt. param: bool $showcorrectness Whether right/partial/wrong states should |
get_question_state_class($slot, $showcorrectness) X-Ref |
Return the grade obtained on a particular question, if the user is permitted to see it. You must previously have called load_question_states to load the state data about this question. return: string class name for this state. param: int $slot the number used to identify this question within this attempt. param: bool $showcorrectness Whether right/partial/wrong states should |
get_question_mark($slot) X-Ref |
Return the grade obtained on a particular question. You must previously have called load_question_states to load the state data about this question. return: string the formatted grade, to the number of decimal places specified by the quiz. param: int $slot the number used to identify this question within this attempt. |
get_question_action_time($slot) X-Ref |
Get the time of the most recent action performed on a question. return: int timestamp. param: int $slot the number used to identify this question within this usage. |
get_question_type_name($slot) X-Ref |
Return the question type name for a given slot within the current attempt. return: string the question type name. param: int $slot the number used to identify this question within this attempt. |
get_time_left_display($timenow) X-Ref |
Get the time remaining for an in-progress attempt, if the time is short enough that it would be worth showing a timer. return: int|false the number of seconds remaining for this attempt. param: int $timenow the time to consider as 'now'. |
get_submitted_date() X-Ref |
return: int the time when this attempt was submitted. 0 if it has not been |
get_due_date() X-Ref |
If the attempt is in an applicable state, work out the time by which the student should next do something. return: int timestamp by which the student needs to do something. |
view_url() X-Ref |
return: string quiz view url. |
start_attempt_url($slot = null, $page = -1) X-Ref |
Get the URL to start or continue an attempt. return: string the URL of this quiz's edit page. Needs to be POSTed to with a cmid parameter. param: int|null $slot which question in the attempt to go to after starting (optional). param: int $page which page in the attempt to go to after starting. |
attempt_page_title(int $page) X-Ref |
Generates the title of the attempt page. return: string attempt page title. param: int $page the page number (starting with 0) in the attempt. |
attempt_url($slot = null, $page = -1, $thispage = -1) X-Ref |
return: string the URL to continue this attempt. param: int|null $slot if specified, the slot number of a specific question to link to. param: int $page if specified, a particular page to link to. If not given deduced param: int $thispage if not -1, the current page. Will cause links to other things on |
summary_page_title() X-Ref |
Generates the title of the summary page. return: string summary page title. |
summary_url() X-Ref |
return: moodle_url the URL of this quiz's summary page. |
processattempt_url() X-Ref |
return: moodle_url the URL of this quiz's summary page. |
review_page_title(int $page, bool $showall = false) X-Ref |
Generates the title of the review page. return: string title of the review page. param: int $page the page number (starting with 0) in the attempt. param: bool $showall whether the review page contains the entire attempt on one page. |
review_url($slot = null, $page = -1, $showall = null, $thispage = -1) X-Ref |
return: string the URL to review this attempt. param: int|null $slot indicates which question to link to. param: int $page if specified, the URL of this particular page of the attempt, otherwise param: bool|null $showall if true, the URL will be to review the entire attempt on one page, param: int $thispage if not -1, the current page. Will cause links to other things on |
get_default_show_all($script) X-Ref |
By default, should this script show all questions on one page for this attempt? return: bool whether show all on one page should be on by default. param: string $script the script name, e.g. 'attempt', 'summary', 'review'. |
cannot_review_message($short = false) X-Ref |
If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why. return: string an appropriate message. param: bool $short if true, return a shorter string. |
get_html_head_contributions($page = 'all', $showall = false) X-Ref |
Initialise the JS etc. required all the questions on a page. return: string HTML to output - mostly obsolete, will probably be an empty string. param: int|string $page a page number, or 'all'. param: bool $showall if true forces page number to all. |
get_question_html_head_contributions($slot) X-Ref |
Initialise the JS etc. required by one question. return: string HTML to output - but this is mostly obsolete. Will probably be an empty string. param: int $slot the question slot number. |
restart_preview_button() X-Ref |
Print the HTML for the start new preview button, if the current user is allowed to see one. return: string HTML for the button. |
render_question($slot, $reviewing, mod_quiz_renderer $renderer, $thispageurl = null) X-Ref |
Generate the HTML that displayes the question in its current state, with the appropriate display options. return: string HTML for the question in its current state. param: int $slot identifies the question in the attempt. param: bool $reviewing is the being printed on an attempt or a review page. param: mod_quiz_renderer $renderer the quiz renderer. param: moodle_url $thispageurl the URL of the page this question is being printed on. |
render_question_helper($slot, $reviewing, $thispageurl,mod_quiz_renderer $renderer, $seq) X-Ref |
Helper used by {@link render_question()} and {@link render_question_at_step()}. return: string HTML fragment. param: int $slot identifies the question in the attempt. param: bool $reviewing is the being printed on an attempt or a review page. param: moodle_url $thispageurl the URL of the page this question is being printed on. param: mod_quiz_renderer $renderer the quiz renderer. param: int|null $seq the seq number of the past state to display. |
make_blocked_question_placeholder($slot) X-Ref |
Create a fake question to be displayed in place of a question that is blocked until the previous question has been answered. return: question_attempt the placeholder question attempt. param: int $slot int slot number of the question to replace. |
render_question_at_step($slot, $seq, $reviewing,mod_quiz_renderer $renderer, $thispageurl = null) X-Ref |
Like {@link render_question()} but displays the question at the past step indicated by $seq, rather than showing the latest step. return: string HTML for the question in its current state. param: int $slot the slot number of a question in this quiz attempt. param: int $seq the seq number of the past state to display. param: bool $reviewing is the being printed on an attempt or a review page. param: mod_quiz_renderer $renderer the quiz renderer. param: moodle_url $thispageurl the URL of the page this question is being printed on. |
render_question_for_commenting($slot) X-Ref |
Wrapper round print_question from lib/questionlib.php. return: string HTML of the question. param: int $slot the id of a question in this quiz attempt. |
check_file_access($slot, $reviewing, $contextid, $component,$filearea, $args, $forcedownload) X-Ref |
Check wheter access should be allowed to a particular file. return: string HTML for the question in its current state. param: int $slot the slot of a question in this quiz attempt. param: bool $reviewing is the being printed on an attempt or a review page. param: int $contextid the file context id from the request. param: string $component the file component from the request. param: string $filearea the file area from the request. param: array $args extra part components from the request. param: bool $forcedownload whether to force download. |
get_navigation_panel(mod_quiz_renderer $output,$panelclass, $page, $showall = false) X-Ref |
Get the navigation panel object for this attempt. return: block_contents the requested object. param: mod_quiz_renderer $output the quiz renderer to use to output things. param: string $panelclass The type of panel, quiz_attempt_nav_panel or quiz_review_nav_panel param: int $page the current page number. param: bool $showall whether we are showing the whole quiz on one page. (Used by review.php.) |
links_to_other_attempts(moodle_url $url) X-Ref |
Return an array of variant URLs to other attempts at this quiz. The $url passed in must contain an attempt parameter. The {@link mod_quiz_links_to_other_attempts} object returned contains an array with keys that are the attempt number, 1, 2, 3. The array values are either a {@link moodle_url} with the attempt parameter updated to point to the attempt id of the other attempt, or null corresponding to the current attempt number. return: mod_quiz_links_to_other_attempts|bool containing array int => null|moodle_url. param: moodle_url $url a URL. |
links_to_other_redos($slot, moodle_url $baseurl) X-Ref |
Return an array of variant URLs to other redos of the question in a particular slot. The $url passed in must contain a slot parameter. The {@link mod_quiz_links_to_other_attempts} object returned contains an array with keys that are the redo number, 1, 2, 3. The array values are either a {@link moodle_url} with the slot parameter updated to point to the slot that has that redo of this question; or null corresponding to the redo identified by $slot. return: mod_quiz_links_to_other_attempts|null containing array int => null|moodle_url, param: int $slot identifies a question in this attempt. param: moodle_url $baseurl the base URL to modify to generate each link. |
handle_if_time_expired($timestamp, $studentisonline) X-Ref |
Check this attempt, to see if there are any state transitions that should happen automatically. This function will update the attempt checkstatetime. param: int $timestamp the timestamp that should be stored as the modified param: bool $studentisonline is the student currently interacting with Moodle? |
process_submitted_actions($timestamp, $becomingoverdue = false, $simulatedresponses = null) X-Ref |
Process all the actions that were submitted as part of the current request. param: int $timestamp the timestamp that should be stored as the modified. param: bool $becomingoverdue param: array|null $simulatedresponses If not null, then we are testing, and this is an array of simulated data. |
process_redo_question($slot, $timestamp) X-Ref |
Replace a question in an attempt with a new attempt at the same question. Well, for randomised questions, it won't be the same question, it will be a different randomised selection. param: int $slot the question to restart. param: int $timestamp the timestamp to record for this action. |
process_auto_save($timestamp) X-Ref |
Process all the autosaved data that was part of the current request. param: int $timestamp the timestamp that should be stored as the modified. |
save_question_flags() X-Ref |
Update the flagged state for all question_attempts in this usage, if their flagged state was changed in the request. |
process_finish($timestamp, $processsubmitted, $timefinish = null, $studentisonline = false) X-Ref |
Submit the attempt. The separate $timefinish argument should be used when the quiz attempt is being processed asynchronously (for example when cron is submitting attempts where the time has expired). param: int $timestamp the time to record as last modified time. param: bool $processsubmitted if true, and question responses in the current param: ?int $timefinish if set, use this as the finish time for the attempt. param: bool $studentisonline is the student currently interacting with Moodle? |
update_timecheckstate($time) X-Ref |
Update this attempt timecheckstate if necessary. param: int|null $time the timestamp to set. |
process_going_overdue($timestamp, $studentisonline) X-Ref |
Mark this attempt as now overdue. param: int $timestamp the time to deem as now. param: bool $studentisonline is the student currently interacting with Moodle? |
process_abandon($timestamp, $studentisonline) X-Ref |
Mark this attempt as abandoned. param: int $timestamp the time to deem as now. param: bool $studentisonline is the student currently interacting with Moodle? |
fire_state_transition_event($eventclass, $timestamp, $studentisonline) X-Ref |
Fire a state transition event. param: string $eventclass the event class name. param: int $timestamp the timestamp to include in the event. param: bool $studentisonline is the student currently interacting with Moodle? |
page_and_question_url($script, $slot, $page, $showall, $thispage) X-Ref |
Get a URL for a particular question on a particular page of the quiz. Used by {@link attempt_url()} and {@link review_url()}. return: moodle_url The requested URL. param: string $script. Used in the URL like /mod/quiz/$script.php. param: int $slot identifies the specific question on the page to jump to. param: int $page -1 to look up the page number from the slot, otherwise param: bool|null $showall if true, return a URL with showall=1, and not page number. param: int $thispage the page we are currently on. Links to questions on this |
process_attempt($timenow, $finishattempt, $timeup, $thispage) X-Ref |
Process responses during an attempt at a quiz. return: string the attempt state once the data has been processed. param: int $timenow time when the processing started. param: bool $finishattempt whether to finish the attempt or not. param: bool $timeup true if form was submitted by timer. param: int $thispage current page number. |
check_page_access(int $page, bool $allownext = true) X-Ref |
Check a page read access to see if is an out of sequence access. If allownext is set then we also check whether access to the page after the current one should be permitted. return: boolean false is an out of sequence access, true otherwise. param: int $page page number. param: bool $allownext in case of a sequential navigation, can we go to next page ? |
set_currentpage($page) X-Ref |
Update attempt page. return: boolean true if everything was ok, false otherwise (out of sequence access). param: int $page page number. |
fire_attempt_viewed_event() X-Ref |
Trigger the attempt_viewed event. |
fire_attempt_updated_event() X-Ref |
Trigger the attempt_updated event. return: void |
fire_attempt_autosaved_event() X-Ref |
Trigger the attempt_autosaved event. return: void |
fire_attempt_question_restarted_event(int $slot, int $newquestionid) X-Ref |
Trigger the attempt_question_restarted event. return: void param: int $slot Slot number param: int $newquestionid New question id. |
fire_attempt_summary_viewed_event() X-Ref |
Trigger the attempt_summary_viewed event. |
fire_attempt_reviewed_event() X-Ref |
Trigger the attempt_reviewed event. |
fire_attempt_manual_grading_completed_event() X-Ref |
Trigger the attempt manual grading completed event. |
set_offline_modified_time($time) X-Ref |
Update the timemodifiedoffline attempt field. This function should be used only when web services are being used. return: boolean false if the field is not updated because web services aren't being used. param: int $time time stamp. |
Class: quiz_nav_section_heading - X-Ref
Represents a heading in the navigation panel.__construct($heading) X-Ref |
Constructor. param: string $heading the heading text |
Class: quiz_nav_panel_base - X-Ref
Represents the navigation panel, and builds a {@link block_contents} to allow__construct(quiz_attempt $attemptobj,question_display_options $options, $page, $showall) X-Ref |
No description |
get_question_buttons() X-Ref |
Get the buttons and section headings to go in the quiz navigation block. return: renderable[] the buttons, possibly interleaved with section headings. |
get_state_string(question_attempt $qa, $showcorrectness) X-Ref |
No description |
render_before_button_bits(mod_quiz_renderer $output) X-Ref |
Hook for subclasses to override. return: string HTML to output. param: mod_quiz_renderer $output the quiz renderer to use. |
render_restart_preview_link($output) X-Ref |
Render the restart preview button. return: string HTML to output. param: mod_quiz_renderer $output the quiz renderer to use. |
user_picture() X-Ref |
No description |
get_button_container_class() X-Ref |
Return 'allquestionsononepage' as CSS class name when $showall is set, otherwise, return 'multipages' as CSS class name. return: string, CSS class name |
Class: quiz_attempt_nav_panel - X-Ref
Specialisation of {@link quiz_nav_panel_base} for the attempt quiz page.get_question_url($slot) X-Ref |
No description |
render_before_button_bits(mod_quiz_renderer $output) X-Ref |
No description |
render_end_bits(mod_quiz_renderer $output) X-Ref |
No description |
Class: quiz_review_nav_panel - X-Ref
Specialisation of {@link quiz_nav_panel_base} for the review quiz page.get_question_url($slot) X-Ref |
No description |
render_end_bits(mod_quiz_renderer $output) X-Ref |
No description |