Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
This class extends the quiz class to hold data about the state of a particular attempt, in addition to the data about the quiz. More...
Public Member Functions | |
__construct ($attempt, $quiz, $cm, $course, $loadquestions=true) | |
Constructor assuming we already have the necessary data loaded. More... | |
all_question_attempts_originally_in_slot ($slot) | |
Get all the question_attempt objects that have ever appeared in a given slot. More... | |
attempt_page_title (int $page) | |
Generates the title of the attempt page. More... | |
attempt_url ($slot=null, $page=-1, $thispage=-1) | |
can_navigate_to ($slot) | |
Checks whether a user may navigate to a particular slot. More... | |
can_question_be_redone_now ($slot) | |
Is it possible for this question to be re-started within this attempt? More... | |
cannot_review_message ($short=false) | |
If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why. More... | |
check_file_access ($slot, $reviewing, $contextid, $component, $filearea, $args, $forcedownload) | |
Check wheter access should be allowed to a particular file. More... | |
check_page_access ($page) | |
Check a page access to see if is an out of sequence access. More... | |
check_review_capability () | |
Check the appropriate capability to see whether this user may review their own attempt. More... | |
fire_attempt_reviewed_event () | |
Trigger the attempt_reviewed event. More... | |
fire_attempt_summary_viewed_event () | |
Trigger the attempt_summary_viewed event. More... | |
fire_attempt_viewed_event () | |
Trigger the attempt_viewed event. More... | |
force_page_number_into_range ($page) | |
If the given page number is out of range (before the first page, or after the last page, chnage it to be within range). More... | |
get_access_manager ($timenow) | |
get_active_slots ($page='all') | |
Return the list of slot numbers for either a given page of the quiz, or for the whole quiz. More... | |
get_additional_summary_data (question_display_options $options) | |
Get extra summary information about this attempt. More... | |
get_attempt () | |
get_attempt_number () | |
get_attempt_state () | |
get_attemptid () | |
get_cm () | |
get_cmid () | |
Get the course-module id. More... | |
get_course () | |
Get the course settings object. More... | |
get_courseid () | |
get_currentpage () | |
get_default_show_all ($script) | |
By default, should this script show all questions on one page for this attempt? More... | |
get_display_options ($reviewing) | |
Wrapper that the correct mod_quiz_display_options for this quiz at the moment. More... | |
get_display_options_with_edit_link ($reviewing, $slot, $thispageurl) | |
Wrapper that the correct mod_quiz_display_options for this quiz at the moment. More... | |
get_due_date () | |
If the attempt is in an applicable state, work out the time by which the student should next do something. More... | |
get_heading_before_slot ($slot) | |
If the section heading, if any, that should come just before this slot. More... | |
get_html_head_contributions ($page='all', $showall=false) | |
Initialise the JS etc. More... | |
get_navigation_method () | |
get_navigation_panel (mod_quiz_renderer $output, $panelclass, $page, $showall=false) | |
Get the navigation panel object for this attempt. More... | |
get_num_attempts_allowed () | |
get_num_pages () | |
get_original_slot ($slot) | |
Given a slot in this attempt, which may or not be a redone question, return the original slot. More... | |
get_overall_feedback ($grade) | |
Get the overall feedback corresponding to a particular mark. More... | |
get_question_action_time ($slot) | |
Get the time of the most recent action performed on a question. More... | |
get_question_attempt ($slot) | |
Get the question_attempt object for a particular question in this attempt. More... | |
get_question_html_head_contributions ($slot) | |
Initialise the JS etc. More... | |
get_question_mark ($slot) | |
Return the grade obtained on a particular question. More... | |
get_question_name ($slot) | |
Return the grade obtained on a particular question, if the user is permitted to see it. More... | |
get_question_number ($slot) | |
Get the displayed question number for a slot. More... | |
get_question_page ($slot) | |
Return the page of the quiz where this question appears. More... | |
get_question_state ($slot) | |
Return the question_state that this question is in. More... | |
get_question_state_class ($slot, $showcorrectness) | |
Return the grade obtained on a particular question, if the user is permitted to see it. More... | |
get_question_status ($slot, $showcorrectness) | |
Return the grade obtained on a particular question, if the user is permitted to see it. More... | |
get_question_type_name ($slot) | |
Return the question type name for a given slot within the current attempt. More... | |
get_question_usage () | |
Helper method for unit tests. More... | |
get_quiz () | |
get_quiz_name () | |
get_quizid () | |
get_quizobj () | |
get_slots ($page='all') | |
Return the list of slot numbers for either a given page of the quiz, or for the whole quiz. More... | |
get_state () | |
get_submitted_date () | |
get_sum_marks () | |
get_time_left_display ($timenow) | |
Get the time remaining for an in-progress attempt, if the time is short enough that it would be worth showing a timer. More... | |
get_uniqueid () | |
get_userid () | |
handle_if_time_expired ($timestamp, $studentisonline) | |
Check this attempt, to see if there are any state transitions that should happen automatically. More... | |
has_capability ($capability, $userid=null, $doanything=true) | |
Wrapper round the has_capability funciton that automatically passes in the quiz context. More... | |
has_response_to_at_least_one_graded_question () | |
Has the student, in this attempt, engaged with the quiz in a non-trivial way? More... | |
is_blocked_by_previous_question ($slot) | |
Checks whether the question in this slot requires the previous question to have been completed. More... | |
is_finished () | |
is_last_page ($page) | |
is_own_attempt () | |
Is this someone dealing with their own attempt or preview? More... | |
is_own_preview () | |
is_preview () | |
is_preview_user () | |
is_question_flagged ($slot) | |
Is a particular question in this attempt a real question, or something like a description. More... | |
is_real_question ($slot) | |
Is a particular question in this attempt a real question, or something like a description. More... | |
is_review_allowed () | |
Is the current user allowed to review this attempt. More... | |
links_to_other_attempts (moodle_url $url) | |
Return an array of variant URLs to other attempts at this quiz. More... | |
links_to_other_redos ($slot, moodle_url $baseurl) | |
Return an array of variant URLs to other redos of the question in a particular slot. More... | |
load_questions () | |
This method can be called later if the object was constructed with $loadqusetions = false. | |
process_abandon ($timestamp, $studentisonline) | |
Mark this attempt as abandoned. More... | |
process_attempt ($timenow, $finishattempt, $timeup, $thispage) | |
Process responses during an attempt at a quiz. More... | |
process_auto_save ($timestamp) | |
Process all the autosaved data that was part of the current request. More... | |
process_finish ($timestamp, $processsubmitted, $timefinish=null) | |
Submit the attempt. More... | |
process_going_overdue ($timestamp, $studentisonline) | |
Mark this attempt as now overdue. More... | |
process_redo_question ($slot, $timestamp) | |
Replace a question in an attempt with a new attempt at the same question. More... | |
process_submitted_actions ($timestamp, $becomingoverdue=false, $simulatedresponses=null) | |
Process all the actions that were submitted as part of the current request. More... | |
processattempt_url () | |
render_question ($slot, $reviewing, mod_quiz_renderer $renderer, $thispageurl=null) | |
Generate the HTML that displayes the question in its current state, with the appropriate display options. More... | |
render_question_at_step ($slot, $seq, $reviewing, mod_quiz_renderer $renderer, $thispageurl=null) | |
Like render_question() but displays the question at the past step indicated by $seq, rather than showing the latest step. More... | |
render_question_for_commenting ($slot) | |
Wrapper round print_question from lib/questionlib.php. More... | |
require_capability ($capability, $userid=null, $doanything=true) | |
Wrapper round the require_capability function that automatically passes in the quiz context. More... | |
restart_preview_button () | |
Print the HTML for the start new preview button, if the current user is allowed to see one. More... | |
review_page_title (int $page, bool $showall=false) | |
Generates the title of the review page. More... | |
review_url ($slot=null, $page=-1, $showall=null, $thispage=-1) | |
save_question_flags () | |
Update the flagged state for all question_attempts in this usage, if their flagged state was changed in the request. | |
set_currentpage ($page) | |
Update attempt page. More... | |
set_offline_modified_time ($time) | |
Update the timemodifiedoffline attempt field. More... | |
start_attempt_url ($slot=null, $page=-1) | |
Get the URL to start or continue an attempt. More... | |
summary_page_title () | |
Generates the title of the summary page. More... | |
summary_url () | |
update_timecheckstate ($time) | |
Update this attempt timecheckstate if necessary. More... | |
view_url () | |
Static Public Member Functions | |
static | create ($attemptid) |
Static function to create a new quiz_attempt object given an attemptid. More... | |
static | create_from_usage_id ($usageid) |
Static function to create a new quiz_attempt object given a usage id. More... | |
static | state_name ($state) |
Protected Member Functions | |
determine_layout () | |
Parse attempt->layout to populate the other arrays the represent the layout. | |
fire_state_transition_event ($eventclass, $timestamp) | |
Fire a state transition event. More... | |
link_sections_and_slots () | |
Let each slot know which section it is part of. | |
make_blocked_question_placeholder ($slot) | |
Create a fake question to be displayed in place of a question that is blocked until the previous question has been answered. More... | |
number_questions () | |
Work out the number to display for each question/slot. | |
page_and_question_url ($script, $slot, $page, $showall, $thispage) | |
Get a URL for a particular question on a particular page of the quiz. More... | |
render_question_helper ($slot, $reviewing, $thispageurl, mod_quiz_renderer $renderer, $seq) | |
Helper used by render_question() and render_question_at_step(). More... | |
Static Protected Member Functions | |
static | create_helper ($conditions) |
Used by {create()} and {create_from_usage_id()}. More... | |
Protected Attributes | |
stdClass | $attempt |
the quiz_attempts row. | |
array | $pagelayout |
page no => array of slot numbers on the page in order. | |
question_usage_by_activity | $quba |
the question usage for this quiz attempt. | |
array | $questionnumbers |
slot => displayed question number for this slot. More... | |
array | $questionpages |
slot => page number for this slot. | |
quiz | $quizobj |
object containing the quiz settings. | |
mod_quiz_display_options | $reviewoptions = null |
cache for the appropriate review options. | |
array | $sections |
of quiz_sections rows, with a ->lastslot field added. | |
array | $slots |
of slot information. More... | |
This class extends the quiz class to hold data about the state of a particular attempt, in addition to the data about the quiz.
quiz_attempt::__construct | ( | $attempt, | |
$quiz, | |||
$cm, | |||
$course, | |||
$loadquestions = true |
|||
) |
Constructor assuming we already have the necessary data loaded.
object | $attempt | the row of the quiz_attempts table. |
object | $quiz | the quiz object for this attempt and user. |
object | $cm | the course_module object for this quiz. |
object | $course | the row from the course table for the course we belong to. |
bool | $loadquestions | (optional) if true, the default, load all the details of the state of each question. Else just set up the basic details of the attempt. |
quiz_attempt::all_question_attempts_originally_in_slot | ( | $slot | ) |
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.
int | $slot | the number used to identify this question within this attempt. |
question_attempt[] | the attempts. |
quiz_attempt::attempt_page_title | ( | int | $page | ) |
Generates the title of the attempt page.
int | $page | the page number (starting with 0) in the attempt. |
string | attempt page title. |
quiz_attempt::attempt_url | ( | $slot = null , |
|
$page = -1 , |
|||
$thispage = -1 |
|||
) |
int | null | $slot | if specified, the slot number of a specific question to link to. |
int | $page | if specified, a particular page to link to. If not given deduced from $slot, or goes to the first page. |
int | $thispage | if not -1, the current page. Will cause links to other things on this page to be output as only a fragment. |
string | the URL to continue this attempt. |
quiz_attempt::can_navigate_to | ( | $slot | ) |
Checks whether a user may navigate to a particular slot.
int | $slot | the target slot (currently does not affect the answer). |
bool | true if the navigation should be allowed. |
quiz_attempt::can_question_be_redone_now | ( | $slot | ) |
Is it possible for this question to be re-started within this attempt?
int | $slot | the number used to identify this question within this attempt. |
bool | whether the student should be given the option to restart this question now. |
quiz_attempt::cannot_review_message | ( | $short = false | ) |
If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why.
bool | $short | if true, return a shorter string. |
string | an appropriate message. |
quiz_attempt::check_file_access | ( | $slot, | |
$reviewing, | |||
$contextid, | |||
$component, | |||
$filearea, | |||
$args, | |||
$forcedownload | |||
) |
Check wheter access should be allowed to a particular file.
int | $slot | the slot of a question in this quiz attempt. |
bool | $reviewing | is the being printed on an attempt or a review page. |
int | $contextid | the file context id from the request. |
string | $component | the file component from the request. |
string | $filearea | the file area from the request. |
array | $args | extra part components from the request. |
bool | $forcedownload | whether to force download. |
string | HTML for the question in its current state. |
quiz_attempt::check_page_access | ( | $page | ) |
Check a page access to see if is an out of sequence access.
int | $page | page number. |
boolean | false is is an out of sequence access, true otherwise. |
quiz_attempt::check_review_capability | ( | ) |
Check the appropriate capability to see whether this user may review their own attempt.
If not, prints an error.
|
static |
Static function to create a new quiz_attempt object given an attemptid.
int | $attemptid | the attempt id. |
quiz_attempt | the new quiz_attempt object |
|
static |
Static function to create a new quiz_attempt object given a usage id.
int | $usageid | the attempt usage id. |
quiz_attempt | the new quiz_attempt object |
|
staticprotected |
Used by {create()} and {create_from_usage_id()}.
array | $conditions | passed to $DB->get_record('quiz_attempts', $conditions). |
quiz_attempt | the desired instance of this class. |
quiz_attempt::fire_attempt_reviewed_event | ( | ) |
Trigger the attempt_reviewed event.
quiz_attempt::fire_attempt_summary_viewed_event | ( | ) |
Trigger the attempt_summary_viewed event.
quiz_attempt::fire_attempt_viewed_event | ( | ) |
Trigger the attempt_viewed event.
|
protected |
Fire a state transition event.
string | $eventclass | the event class name. |
int | $timestamp | the timestamp to include in the event. |
quiz_attempt::force_page_number_into_range | ( | $page | ) |
If the given page number is out of range (before the first page, or after the last page, chnage it to be within range).
int | $page | the requested page number. |
int | a safe page number to use. |
quiz_attempt::get_access_manager | ( | $timenow | ) |
int | $timenow | the current time as a unix timestamp. |
quiz_access_manager | and instance of the quiz_access_manager class for this quiz at this time. |
quiz_attempt::get_active_slots | ( | $page = 'all' | ) |
Return the list of slot numbers for either a given page of the quiz, or for the whole quiz.
mixed | $page | string 'all' or integer page number. |
array | the requested list of slot numbers. |
quiz_attempt::get_additional_summary_data | ( | question_display_options | $options | ) |
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.
question_display_options | $options | the display options for this quiz attempt at this time. |
array | as described above. |
quiz_attempt::get_attempt | ( | ) |
object | the row from the quiz_attempts table. |
quiz_attempt::get_attempt_number | ( | ) |
int | the number of this attemp (is it this user's first, second, ... attempt). |
quiz_attempt::get_attempt_state | ( | ) |
int | one of the mod_quiz_display_options::DURING, IMMEDIATELY_AFTER, LATER_WHILE_OPEN or AFTER_CLOSE constants. |
quiz_attempt::get_attemptid | ( | ) |
int | the attempt id. |
quiz_attempt::get_cm | ( | ) |
object | the course_module object. |
quiz_attempt::get_cmid | ( | ) |
Get the course-module id.
int | the course_module id. |
quiz_attempt::get_course | ( | ) |
Get the course settings object.
stdClass | the course settings object. |
quiz_attempt::get_courseid | ( | ) |
int | the course id. |
quiz_attempt::get_currentpage | ( | ) |
int | the current page of the attempt. |
quiz_attempt::get_default_show_all | ( | $script | ) |
By default, should this script show all questions on one page for this attempt?
string | $script | the script name, e.g. 'attempt', 'summary', 'review'. |
bool | whether show all on one page should be on by default. |
quiz_attempt::get_display_options | ( | $reviewing | ) |
Wrapper that the correct mod_quiz_display_options for this quiz at the moment.
bool | $reviewing | true for options when reviewing, false for when attempting. |
question_display_options | the render options for this user on this attempt. |
quiz_attempt::get_display_options_with_edit_link | ( | $reviewing, | |
$slot, | |||
$thispageurl | |||
) |
Wrapper that the correct mod_quiz_display_options for this quiz at the moment.
bool | $reviewing | true for review page, else attempt page. |
int | $slot | which question is being displayed. |
moodle_url | $thispageurl | to return to after the editing form is submitted or cancelled. If null, no edit link will be generated. |
question_display_options | the render options for this user on this attempt, with extra info to generate an edit link, if applicable. |
quiz_attempt::get_due_date | ( | ) |
If the attempt is in an applicable state, work out the time by which the student should next do something.
int | timestamp by which the student needs to do something. |
quiz_attempt::get_heading_before_slot | ( | $slot | ) |
If the section heading, if any, that should come just before this slot.
int | $slot | identifies a particular question in this attempt. |
string | the required heading, or null if there is not one here. |
quiz_attempt::get_html_head_contributions | ( | $page = 'all' , |
|
$showall = false |
|||
) |
Initialise the JS etc.
required all the questions on a page.
int | string | $page | a page number, or 'all'. |
bool | $showall | if true forces page number to all. |
string | HTML to output - mostly obsolete, will probably be an empty string. |
quiz_attempt::get_navigation_method | ( | ) |
int | the quiz navigation method. |
quiz_attempt::get_navigation_panel | ( | mod_quiz_renderer | $output, |
$panelclass, | |||
$page, | |||
$showall = false |
|||
) |
Get the navigation panel object for this attempt.
mod_quiz_renderer | $output | the quiz renderer to use to output things. |
string | $panelclass | The type of panel, quiz_attempt_nav_panel or quiz_review_nav_panel |
int | $page | the current page number. |
bool | $showall | whether we are showing the whole quiz on one page. (Used by review.php.) |
block_contents | the requested object. |
quiz_attempt::get_num_attempts_allowed | ( | ) |
int | the number of attempts allowed at this quiz (0 = infinite). |
quiz_attempt::get_num_pages | ( | ) |
int | number fo pages in this quiz. |
quiz_attempt::get_original_slot | ( | $slot | ) |
Given a slot in this attempt, which may or not be a redone question, return the original slot.
int | $slot | identifies a particular question in this attempt. |
int | the slot where this question was originally. |
quiz_attempt::get_overall_feedback | ( | $grade | ) |
Get the overall feedback corresponding to a particular mark.
number | $grade | a particular grade. |
string | the feedback. |
quiz_attempt::get_question_action_time | ( | $slot | ) |
Get the time of the most recent action performed on a question.
int | $slot | the number used to identify this question within this usage. |
int | timestamp. |
quiz_attempt::get_question_attempt | ( | $slot | ) |
Get the question_attempt object for a particular question in this attempt.
int | $slot | the number used to identify this question within this attempt. |
question_attempt | the requested question_attempt. |
quiz_attempt::get_question_html_head_contributions | ( | $slot | ) |
Initialise the JS etc.
required by one question.
int | $slot | the question slot number. |
string | HTML to output - but this is mostly obsolete. Will probably be an empty string. |
quiz_attempt::get_question_mark | ( | $slot | ) |
Return the grade obtained on a particular question.
You must previously have called load_question_states to load the state data about this question.
int | $slot | the number used to identify this question within this attempt. |
string | the formatted grade, to the number of decimal places specified by the quiz. |
quiz_attempt::get_question_name | ( | $slot | ) |
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.
int | $slot | the number used to identify this question within this attempt. |
string | the formatted grade, to the number of decimal places specified by the quiz. |
quiz_attempt::get_question_number | ( | $slot | ) |
Get the displayed question number for a slot.
int | $slot | the number used to identify this question within this attempt. |
string | the displayed question number for the question in this slot. For example '1', '2', '3' or 'i'. |
quiz_attempt::get_question_page | ( | $slot | ) |
Return the page of the quiz where this question appears.
int | $slot | the number used to identify this question within this attempt. |
int | the page of the quiz this question appears on. |
quiz_attempt::get_question_state | ( | $slot | ) |
Return the question_state that this question is in.
int | $slot | the number used to identify this question within this attempt. |
question_state | the state this question is in. |
quiz_attempt::get_question_state_class | ( | $slot, | |
$showcorrectness | |||
) |
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.
int | $slot | the number used to identify this question within this attempt. |
bool | $showcorrectness | Whether right/partial/wrong states should be distinguished. |
string | class name for this state. |
quiz_attempt::get_question_status | ( | $slot, | |
$showcorrectness | |||
) |
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.
int | $slot | the number used to identify this question within this attempt. |
bool | $showcorrectness | Whether right/partial/wrong states should be distinguished. |
string | the formatted grade, to the number of decimal places specified by the quiz. |
quiz_attempt::get_question_type_name | ( | $slot | ) |
Return the question type name for a given slot within the current attempt.
int | $slot | the number used to identify this question within this attempt. |
string | the question type name. |
quiz_attempt::get_question_usage | ( | ) |
Helper method for unit tests.
Get the underlying question usage object.
question_usage_by_activity | the usage. |
quiz_attempt::get_quiz_name | ( | ) |
string | the name of this quiz. |
quiz_attempt::get_quizid | ( | ) |
int | the quiz id. |
quiz_attempt::get_slots | ( | $page = 'all' | ) |
Return the list of slot numbers for either a given page of the quiz, or for the whole quiz.
mixed | $page | string 'all' or integer page number. |
array | the requested list of slot numbers. |
quiz_attempt::get_state | ( | ) |
string | one of the quiz_attempt::IN_PROGRESS, FINISHED, OVERDUE or ABANDONED constants. |
quiz_attempt::get_submitted_date | ( | ) |
int | the time when this attempt was submitted. 0 if it has not been submitted yet. |
quiz_attempt::get_time_left_display | ( | $timenow | ) |
Get the time remaining for an in-progress attempt, if the time is short enough that it would be worth showing a timer.
int | $timenow | the time to consider as 'now'. |
int|false | the number of seconds remaining for this attempt. False if there is no limit. |
quiz_attempt::get_uniqueid | ( | ) |
int | the attempt unique id. |
quiz_attempt::get_userid | ( | ) |
int | the id of the user this attempt belongs to. |
quiz_attempt::handle_if_time_expired | ( | $timestamp, | |
$studentisonline | |||
) |
Check this attempt, to see if there are any state transitions that should happen automatically.
This function will update the attempt checkstatetime.
int | $timestamp | the timestamp that should be stored as the modified |
bool | $studentisonline | is the student currently interacting with Moodle? |
quiz_attempt::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/forum: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. |
quiz_attempt::has_response_to_at_least_one_graded_question | ( | ) |
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?
bool | true if we have saved a response for at least one graded question. |
quiz_attempt::is_blocked_by_previous_question | ( | $slot | ) |
Checks whether the question in this slot requires the previous question to have been completed.
int | $slot | the number used to identify this question within this attempt. |
bool | whether the previous question must have been completed before this one can be seen. |
quiz_attempt::is_finished | ( | ) |
bool | whether this attempt has been finished (true) or is still in progress (false). Be warned that this is not just state == self::FINISHED, it also includes self::ABANDONED. |
quiz_attempt::is_last_page | ( | $page | ) |
int | $page | page number |
bool | true if this is the last page of the quiz. |
quiz_attempt::is_own_attempt | ( | ) |
Is this someone dealing with their own attempt or preview?
bool | true => own attempt/preview. false => reviewing someone else's. |
quiz_attempt::is_own_preview | ( | ) |
bool | whether this attempt is a preview belonging to the current user. |
quiz_attempt::is_preview | ( | ) |
bool | whether this attempt is a preview attempt. |
quiz_attempt::is_preview_user | ( | ) |
bool | whether the current user is someone who previews the quiz, rather than attempting it. |
quiz_attempt::is_question_flagged | ( | $slot | ) |
Is a particular question in this attempt a real question, or something like a description.
int | $slot | the number used to identify this question within this attempt. |
bool | whether that question is a real question. |
quiz_attempt::is_real_question | ( | $slot | ) |
Is a particular question in this attempt a real question, or something like a description.
int | $slot | the number used to identify this question within this attempt. |
int | whether that question is a real question. Actually returns the question length, which could theoretically be greater than one. |
quiz_attempt::is_review_allowed | ( | ) |
Is the current user allowed to review this attempt.
This applies when is_own_attempt() returns false.
bool | whether the review should be allowed. |
quiz_attempt::links_to_other_attempts | ( | moodle_url | $url | ) |
Return an array of variant URLs to other attempts at this quiz.
The $url passed in must contain an attempt parameter.
The 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 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.
moodle_url | $url | a URL. |
mod_quiz_links_to_other_attempts|bool | containing array int => null|moodle_url. False if none. |
quiz_attempt::links_to_other_redos | ( | $slot, | |
moodle_url | $baseurl | ||
) |
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 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 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.
int | $slot | identifies a question in this attempt. |
moodle_url | $baseurl | the base URL to modify to generate each link. |
mod_quiz_links_to_other_attempts|null | containing array int => null|moodle_url, or null if the question in this slot has not been redone. |
|
protected |
Create a fake question to be displayed in place of a question that is blocked until the previous question has been answered.
int | $slot | int slot number of the question to replace. |
question_attempt | the placeholder question attempt. |
|
protected |
Get a URL for a particular question on a particular page of the quiz.
Used by attempt_url() and review_url().
string | $script,. | Used in the URL like /mod/quiz/$script.php. |
int | $slot | identifies the specific question on the page to jump to. 0 to just use the $page parameter. |
int | $page | -1 to look up the page number from the slot, otherwise the page number to go to. |
bool | null | $showall | if true, return a URL with showall=1, and not page number. if null, then an intelligent default will be chosen. |
int | $thispage | the page we are currently on. Links to questions on this page will just be a fragment #q123. -1 to disable this. |
moodle_url | The requested URL. |
quiz_attempt::process_abandon | ( | $timestamp, | |
$studentisonline | |||
) |
Mark this attempt as abandoned.
int | $timestamp | the time to deem as now. |
bool | $studentisonline | is the student currently interacting with Moodle? |
quiz_attempt::process_attempt | ( | $timenow, | |
$finishattempt, | |||
$timeup, | |||
$thispage | |||
) |
Process responses during an attempt at a quiz.
int | $timenow | time when the processing started. |
bool | $finishattempt | whether to finish the attempt or not. |
bool | $timeup | true if form was submitted by timer. |
int | $thispage | current page number. |
string | the attempt state once the data has been processed. |
quiz_attempt::process_auto_save | ( | $timestamp | ) |
Process all the autosaved data that was part of the current request.
int | $timestamp | the timestamp that should be stored as the modified. time in the database for these actions. If null, will use the current time. |
quiz_attempt::process_finish | ( | $timestamp, | |
$processsubmitted, | |||
$timefinish = null |
|||
) |
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).
int | $timestamp | the time to record as last modified time. |
bool | $processsubmitted | if true, and question responses in the current POST request are stored to be graded, before the attempt is finished. |
?int | $timefinish if set, use this as the finish time for the attempt. (otherwise use $timestamp as the finish time as well). |
quiz_attempt::process_going_overdue | ( | $timestamp, | |
$studentisonline | |||
) |
Mark this attempt as now overdue.
int | $timestamp | the time to deem as now. |
bool | $studentisonline | is the student currently interacting with Moodle? |
quiz_attempt::process_redo_question | ( | $slot, | |
$timestamp | |||
) |
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.
int | $slot | the question to restart. |
int | $timestamp | the timestamp to record for this action. |
quiz_attempt::process_submitted_actions | ( | $timestamp, | |
$becomingoverdue = false , |
|||
$simulatedresponses = null |
|||
) |
Process all the actions that were submitted as part of the current request.
int | $timestamp | the timestamp that should be stored as the modified. time in the database for these actions. If null, will use the current time. |
bool | $becomingoverdue | |
array | null | $simulatedresponses | If not null, then we are testing, and this is an array of simulated data. There are two formats supported here, for historical reasons. The newer approach is to pass an array created by core_question_generator::get_simulated_post_data_for_questions_in_usage(). the second is to pass an array slot no => contains arrays representing student responses which will be passed to question_definition::prepare_simulated_post_data(). This second method will probably get deprecated one day. |
quiz_attempt::processattempt_url | ( | ) |
moodle_url | the URL of this quiz's summary page. |
quiz_attempt::render_question | ( | $slot, | |
$reviewing, | |||
mod_quiz_renderer | $renderer, | ||
$thispageurl = null |
|||
) |
Generate the HTML that displayes the question in its current state, with the appropriate display options.
int | $slot | identifies the question in the attempt. |
bool | $reviewing | is the being printed on an attempt or a review page. |
mod_quiz_renderer | $renderer | the quiz renderer. |
moodle_url | $thispageurl | the URL of the page this question is being printed on. |
string | HTML for the question in its current state. |
quiz_attempt::render_question_at_step | ( | $slot, | |
$seq, | |||
$reviewing, | |||
mod_quiz_renderer | $renderer, | ||
$thispageurl = null |
|||
) |
Like render_question() but displays the question at the past step indicated by $seq, rather than showing the latest step.
int | $slot | the slot number of a question in this quiz attempt. |
int | $seq | the seq number of the past state to display. |
bool | $reviewing | is the being printed on an attempt or a review page. |
mod_quiz_renderer | $renderer | the quiz renderer. |
moodle_url | $thispageurl | the URL of the page this question is being printed on. |
string | HTML for the question in its current state. |
quiz_attempt::render_question_for_commenting | ( | $slot | ) |
Wrapper round print_question from lib/questionlib.php.
int | $slot | the id of a question in this quiz attempt. |
string | HTML of the question. |
|
protected |
Helper used by render_question() and render_question_at_step().
int | $slot | identifies the question in the attempt. |
bool | $reviewing | is the being printed on an attempt or a review page. |
moodle_url | $thispageurl | the URL of the page this question is being printed on. |
mod_quiz_renderer | $renderer | the quiz renderer. |
int | null | $seq | the seq number of the past state to display. |
string | HTML fragment. |
quiz_attempt::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/forum: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. |
quiz_attempt::restart_preview_button | ( | ) |
Print the HTML for the start new preview button, if the current user is allowed to see one.
string | HTML for the button. |
quiz_attempt::review_page_title | ( | int | $page, |
bool | $showall = false |
||
) |
Generates the title of the review page.
int | $page | the page number (starting with 0) in the attempt. |
bool | $showall | whether the review page contains the entire attempt on one page. |
string | title of the review page. |
quiz_attempt::review_url | ( | $slot = null , |
|
$page = -1 , |
|||
$showall = null , |
|||
$thispage = -1 |
|||
) |
int | null | $slot | indicates which question to link to. |
int | $page | if specified, the URL of this particular page of the attempt, otherwise the URL will go to the first page. If -1, deduce $page from $slot. |
bool | null | $showall | if true, the URL will be to review the entire attempt on one page, and $page will be ignored. If null, a sensible default will be chosen. |
int | $thispage | if not -1, the current page. Will cause links to other things on this page to be output as only a fragment. |
string | the URL to review this attempt. |
quiz_attempt::set_currentpage | ( | $page | ) |
Update attempt page.
int | $page | page number. |
boolean | true if everything was ok, false otherwise (out of sequence access). |
quiz_attempt::set_offline_modified_time | ( | $time | ) |
Update the timemodifiedoffline attempt field.
This function should be used only when web services are being used.
int | $time | time stamp. |
boolean | false if the field is not updated because web services aren't being used. |
quiz_attempt::start_attempt_url | ( | $slot = null , |
|
$page = -1 |
|||
) |
Get the URL to start or continue an attempt.
int | null | $slot | which question in the attempt to go to after starting (optional). |
int | $page | which page in the attempt to go to after starting. |
string | the URL of this quiz's edit page. Needs to be POSTed to with a cmid parameter. |
|
static |
string | $state | one of the state constants like IN_PROGRESS. |
string | the human-readable state name. |
quiz_attempt::summary_page_title | ( | ) |
Generates the title of the summary page.
string | summary page title. |
quiz_attempt::summary_url | ( | ) |
moodle_url | the URL of this quiz's summary page. |
quiz_attempt::update_timecheckstate | ( | $time | ) |
Update this attempt timecheckstate if necessary.
int | null | $time | the timestamp to set. |
quiz_attempt::view_url | ( | ) |
string | quiz view url. |
|
protected |
slot => displayed question number for this slot.
(E.g. 1, 2, 3 or 'i'.)
|
protected |
of slot information.
These objects contain ->slot (int), ->requireprevious (bool), ->questionids (int) the original question for random questions, ->firstinsection (bool), ->section (stdClass from $this->sections). This does not contain page - get that from get_question_page() - or maxmark - get that from $this->quba.