Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
This class keeps track of a group of questions that are being attempted, and which state, and so on, each one is currently in. More...
Public Member Functions | |
__construct ($component, $context) | |
Create a new instance. | |
add_question (question_definition $question, $maxmark=null) | |
Add another question to this usage. | |
add_question_in_place_of_other ( $slot, question_definition $question, $maxmark=null, bool $keepoldquestionattempt=true,) | |
Add another question to this usage, in the place of an existing slot. | |
can_question_finish_during_attempt ($slot) | |
Whether this attempt at a given question could be completed just by the student interacting with the question, before finish_question() is called. | |
check_file_access ($slot, $options, $component, $filearea, $args, $forcedownload) | |
Checks whether the users is allow to be served a particular file. | |
extract_responses ($slot, $postdata=null) | |
Get the submitted data from the current request that belongs to this particular question. | |
finish_all_questions ($timestamp=null) | |
Finish the active phase of an attempt at a question. | |
finish_question ($slot, $timestamp=null) | |
Finish the active phase of an attempt at a question. | |
get_attempt_iterator () | |
Note the part of the question_usage_by_activity comment that explains that question_attempt objects should be considered part of the inner workings of the question engine, and should not, if possible, be accessed directly. | |
get_correct_response ($slot) | |
Get the correct response to a particular question. | |
get_field_prefix ($slot) | |
You should probably not use this method in code outside the question engine. | |
get_first_question_number () | |
get_id () | |
get_num_variants ($slot) | |
Get the number of variants available for the question in this slot. | |
get_observer () | |
get_owning_component () | |
get_owning_context () | |
get_preferred_behaviour () | |
get_question ($slot, $requirequestioninitialised=true) | |
Get the question_definition for a question in this attempt. | |
get_question_action_time ($slot) | |
Get the time of the most recent action performed on a question. | |
get_question_attempt ($slot) | |
Note the part of the question_usage_by_activity comment that explains that question_attempt objects should be considered part of the inner workings of the question engine, and should not, if possible, be accessed directly. | |
get_question_attempt_metadata ($slot, $name) | |
Return one of the bits of metadata for a particular question attempt in this usage. | |
get_question_fraction ($slot) | |
Get the current fraction awarded for the attempt at a question. | |
get_question_mark ($slot) | |
Get the current mark awarded for the attempt at a question. | |
get_question_max_mark ($slot) | |
Get the maximum mark possible for the attempt at a question. | |
get_question_state ($slot) | |
Get the current state of the attempt at a question. | |
get_question_state_class ($slot, $showcorrectness) | |
get_question_state_string ($slot, $showcorrectness) | |
get_question_summary ($slot) | |
Get a simple textual summary of the question that was asked. | |
get_response_summary ($slot) | |
Get a simple textual summary of response given. | |
get_right_answer_summary ($slot) | |
Get a simple textual summary of the correct response to a question. | |
get_slots () | |
get_summary_information (question_display_options $options) | |
Get summary information about this usage. | |
get_total_mark () | |
Get the total mark for all questions in this usage. | |
get_variant ($slot) | |
Get the variant of the question being used in a given slot. | |
is_autosave_required ($slot, $postdata=null) | |
Check, based on the sequence number, whether this auto-save is still required. | |
manual_grade ($slot, $comment, $mark, $commentformat=null) | |
Perform a manual grading action on a question attempt. | |
next_slot_number () | |
The slot number that will be allotted to the next question added. | |
preload_all_step_users () | |
Preload users of all question attempt steps. | |
prepare_simulated_post_data ($simulatedresponses) | |
Transform an array of response data for slots to an array of post data as you would get from quiz attempt form. | |
process_action ($slot, $submitteddata, $timestamp=null) | |
Process a specific action on a specific question. | |
process_all_actions ($timestamp=null, $postdata=null) | |
Process all the question actions in the current request. | |
process_all_autosaves ($timestamp=null, $postdata=null) | |
Process all the question autosave data in the current request. | |
process_autosave ($slot, $submitteddata, $timestamp=null) | |
Process an autosave action on a specific question. | |
question_count () | |
regrade_all_questions ($finished=false) | |
Regrade all the questions in this usage (without changing their max mark). | |
regrade_question ($slot, $finished=false, $newmaxmark=null, question_definition $otherversion=null) | |
Regrade a question in this usage. | |
render_question ($slot, $options, $number=null) | |
Get the core_question_renderer, in collaboration with appropriate qbehaviour_renderer and qtype_renderer subclasses, to generate the HTML to display this question. | |
render_question_at_step ($slot, $seq, $options, $number=null) | |
Like render_question() but displays the question at the past step indicated by $seq, rather than showing the latest step. | |
render_question_head_html ($slot) | |
Generate any bits of HTML that needs to go in the <head> tag when this question is displayed in the body. | |
replace_loaded_question_attempt_info ($slot, $qa) | |
Replace a particular question_attempt with a different one. | |
set_id_from_database ($id) | |
For internal use only. | |
set_max_mark ($slot, $maxmark) | |
Change the max mark for this question_attempt. | |
set_observer ($observer) | |
You should almost certainly not call this method from your code. | |
set_preferred_behaviour ($behaviour) | |
set_question_attempt_metadata ($slot, $name, $value) | |
Set some metadata for a particular question attempt in this usage. | |
start_all_questions (question_variant_selection_strategy $variantstrategy=null, $timestamp=null, $userid=null) | |
Start the attempt at all questions that has been added to this usage. | |
start_question ($slot, $variant=null, $timenow=null) | |
Start the attempt at a question that has been added to this usage. | |
start_question_based_on ($slot, question_attempt $oldqa) | |
Start the attempt at a question, starting from the point where the previous question_attempt $oldqa had reached. | |
update_question_flags ($postdata=null) | |
Update the flagged state for all question_attempts in this usage, if their flagged state was changed in the request. | |
validate_can_regrade_with_other_version (int $slot, question_definition $otherversion) | |
Verify if the question_attempt in the given slot can be regraded with that other question version. | |
validate_sequence_number ($slot, $postdata=null) | |
Check that the sequence number, that detects weird things like the student clicking back, is OK. | |
Static Public Member Functions | |
static | load_from_records ($records, $qubaid) |
Create a question_usage_by_activity from records loaded from the database. | |
Protected Member Functions | |
check_slot ($slot) | |
Check whether $number actually corresponds to a question attempt that is part of this usage. | |
get_slots_in_request ($postdata=null) | |
Get the list of slot numbers that should be processed as part of processing the current request. | |
Protected Attributes | |
context | $context |
the context this usage belongs to. | |
integer string | $id = null |
the id for this usage. | |
question_usage_observer | $observer |
that tracks changes to this usage. | |
string | $owningcomponent |
plugin name of the plugin this usage belongs to. | |
string | $preferredbehaviour = null |
name of an archetypal behaviour, that should be used by questions in this usage if possible. | |
question_attempt[] | $questionattempts = array() |
that make up this usage. | |
This class keeps track of a group of questions that are being attempted, and which state, and so on, each one is currently in.
A quiz attempt or a lesson attempt could use an instance of this class to keep track of all the questions in the attempt and process student submissions. It is basically a collection of {@question_attempt} objects.
The questions being attempted as part of this usage are identified by an integer that is passed into many of the methods as $slot. ($question->id is not used so that the same question can be used more than once in an attempt.)
Normally, calling code should be able to do everything it needs to be calling methods of this class. You should not normally need to get individual {@question_attempt} objects and play around with their inner workind, in code that it outside the quetsion engine.
Instances of this class correspond to rows in the question_usages table.
question_usage_by_activity::__construct | ( | $component, | |
$context ) |
Create a new instance.
Normally, calling code should use question_engine::make_questions_usage_by_activity() or question_engine::load_questions_usage_by_activity() rather than calling this constructor directly.
string | $component | the plugin creating this attempt. For example mod_quiz. |
object | $context | the context this usage belongs to. |
question_usage_by_activity::add_question | ( | question_definition | $question, |
$maxmark = null ) |
Add another question to this usage.
The added question is not started until you call start_question() on it.
question_definition | $question | the question to add. |
number | $maxmark | the maximum this question will be marked out of in this attempt (optional). If not given, $question->defaultmark is used. |
int | the number used to identify this question within this usage. |
question_usage_by_activity::add_question_in_place_of_other | ( | $slot, | |
question_definition | $question, | ||
$maxmark = null, | |||
bool | $keepoldquestionattempt = true ) |
Add another question to this usage, in the place of an existing slot.
Depending on $keepoldquestionattempt, the question_attempt that was in that slot is moved to the end at a new slot number, which is returned. Otherwise the existing attempt is completely removed and replaced.
The added question is not started until you call start_question() on it.
int | $slot | the slot-number of the question to replace. |
question_definition | $question | the question to add. |
number | $maxmark | the maximum this question will be marked out of in this attempt (optional). If not given, the max mark from the $qa we are replacing is used. |
bool | $keepoldquestionattempt | if true (the default) we keep the existing question_attempt, moving it to a new slot |
int | the new slot number of the question that was displaced. |
question_usage_by_activity::can_question_finish_during_attempt | ( | $slot | ) |
Whether this attempt at a given question could be completed just by the student interacting with the question, before finish_question() is called.
int | $slot | the number used to identify this question within this usage. |
boolean | whether the attempt at the given question can finish naturally. |
question_usage_by_activity::check_file_access | ( | $slot, | |
$options, | |||
$component, | |||
$filearea, | |||
$args, | |||
$forcedownload ) |
Checks whether the users is allow to be served a particular file.
int | $slot | the number used to identify this question within this usage. |
question_display_options | $options | the options that control display of the question. |
string | $component | the name of the component we are serving files for. |
string | $filearea | the name of the file area. |
array | $args | the remaining bits of the file path. |
bool | $forcedownload | whether the user must be forced to download the file. |
bool | true if the user can access this file. |
|
protected |
Check whether $number actually corresponds to a question attempt that is part of this usage.
Throws an exception if not.
int | $slot | a number allegedly identifying a question within this usage. |
question_usage_by_activity::extract_responses | ( | $slot, | |
$postdata = null ) |
Get the submitted data from the current request that belongs to this particular question.
int | $slot | the number used to identify this question within this usage. |
array | null | $postdata | optional, only intended for testing. Use this data instead of the data from $_POST. |
array | submitted data specific to this question. |
question_usage_by_activity::finish_all_questions | ( | $timestamp = null | ) |
Finish the active phase of an attempt at a question.
See finish_question() for a fuller description of what 'finish' means.
int | null | $timestamp | (optional) the timestamp to consider 'now'. |
question_usage_by_activity::finish_question | ( | $slot, | |
$timestamp = null ) |
Finish the active phase of an attempt at a question.
This is an external act of finishing the attempt. Think, for example, of the 'Submit all and finish' button in the quiz. Some behaviours, (for example, immediatefeedback) give a way of finishing the active phase of a question attempt as part of a process_action() call.
After the active phase is over, the only changes possible are things like manual grading, or changing the flag state.
int | $slot | the number used to identify this question within this usage. |
int | null | $timestamp | (optional) the timestamp to consider 'now'. |
question_usage_by_activity::get_attempt_iterator | ( | ) |
Note the part of the question_usage_by_activity comment that explains that question_attempt objects should be considered part of the inner workings of the question engine, and should not, if possible, be accessed directly.
question_attempt_iterator | for iterating over all the questions being attempted. as part of this usage. |
question_usage_by_activity::get_correct_response | ( | $slot | ) |
Get the correct response to a particular question.
Passing the results of this method to process_action() will probably result in full marks. If it is not possible to compute a correct response, this method should return null.
int | $slot | the number used to identify this question within this usage. |
array | that constitutes a correct response to this question. |
question_usage_by_activity::get_field_prefix | ( | $slot | ) |
You should probably not use this method in code outside the question engine.
The main reason for exposing it was for the benefit of unit tests.
int | $slot | the number used to identify this question within this usage. |
string | return the prefix that is pre-pended to field names in the HTML that is output. |
question_usage_by_activity::get_first_question_number | ( | ) |
int | the identifying number of the first question that was added to this usage. |
question_usage_by_activity::get_id | ( | ) |
int|string | If this usage came from the database, then the id from the question_usages table is returned. Otherwise a random string is returned. |
question_usage_by_activity::get_num_variants | ( | $slot | ) |
Get the number of variants available for the question in this slot.
int | $slot | the number used to identify this question within this usage. |
int | the number of variants available. |
question_usage_by_activity::get_observer | ( | ) |
question_usage_observer | that is tracking changes made to this usage. |
question_usage_by_activity::get_owning_component | ( | ) |
string | the name of the plugin that owns this attempt. |
question_usage_by_activity::get_owning_context | ( | ) |
context | the context this usage belongs to. |
question_usage_by_activity::get_preferred_behaviour | ( | ) |
string | the name of the preferred behaviour. |
question_usage_by_activity::get_question | ( | $slot, | |
$requirequestioninitialised = true ) |
Get the question_definition for a question in this attempt.
int | $slot | the number used to identify this question within this usage. |
bool | $requirequestioninitialised | set this to false if you don't need the behaviour initialised, which may improve performance. |
question_definition | the requested question object. |
question_usage_by_activity::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. |
question_usage_by_activity::get_question_attempt | ( | $slot | ) |
Note the part of the question_usage_by_activity comment that explains that question_attempt objects should be considered part of the inner workings of the question engine, and should not, if possible, be accessed directly.
int | $slot | the number used to identify this question within this usage. |
question_attempt | the corresponding question_attempt object. |
question_usage_by_activity::get_question_attempt_metadata | ( | $slot, | |
$name ) |
Return one of the bits of metadata for a particular question attempt in this usage.
int | $slot | the slot number of the question of inereest. |
string | $name | the name of the metadata variable to return. |
string | the value of that metadata variable. |
question_usage_by_activity::get_question_fraction | ( | $slot | ) |
Get the current fraction awarded for the attempt at a question.
int | $slot | the number used to identify this question within this usage. |
number|null | The current fraction for this question, or null if one has not been assigned yet. |
question_usage_by_activity::get_question_mark | ( | $slot | ) |
Get the current mark awarded for the attempt at a question.
int | $slot | the number used to identify this question within this usage. |
number|null | The current mark for this question, or null if one has not been assigned yet. |
question_usage_by_activity::get_question_max_mark | ( | $slot | ) |
Get the maximum mark possible for the attempt at a question.
int | $slot | the number used to identify this question within this usage. |
number | the available marks for this question. |
question_usage_by_activity::get_question_state | ( | $slot | ) |
Get the current state of the attempt at a question.
int | $slot | the number used to identify this question within this usage. |
question_state. |
question_usage_by_activity::get_question_state_class | ( | $slot, | |
$showcorrectness ) |
int | $slot | the number used to identify this question within this usage. |
bool | $showcorrectness | Whether right/partial/wrong states should be distinguised. |
string | a CSS class name for the current state. |
question_usage_by_activity::get_question_state_string | ( | $slot, | |
$showcorrectness ) |
int | $slot | the number used to identify this question within this usage. |
bool | $showcorrectness | Whether right/partial/wrong states should be distinguised. |
string | A brief textual description of the current state. |
question_usage_by_activity::get_question_summary | ( | $slot | ) |
Get a simple textual summary of the question that was asked.
int | $slot | the slot number of the question to summarise. |
string | the question summary. |
question_usage_by_activity::get_response_summary | ( | $slot | ) |
Get a simple textual summary of response given.
int | $slot | the slot number of the question to get the response summary for. |
string | the response summary. |
question_usage_by_activity::get_right_answer_summary | ( | $slot | ) |
Get a simple textual summary of the correct response to a question.
int | $slot | the slot number of the question to get the right answer summary for. |
string | the right answer summary. |
question_usage_by_activity::get_slots | ( | ) |
array | all the identifying numbers of all the questions in this usage. |
|
protected |
Get the list of slot numbers that should be processed as part of processing the current request.
array | $postdata | optional, only intended for testing. Use this data instead of the data from $_POST. |
array | of slot numbers. |
question_usage_by_activity::get_summary_information | ( | question_display_options | $options | ) |
Get summary information about this usage.
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 | display options to apply. |
array | as described above. |
question_usage_by_activity::get_total_mark | ( | ) |
Get the total mark for all questions in this usage.
number | The sum of marks of all the question_attempts in this usage. |
question_usage_by_activity::get_variant | ( | $slot | ) |
Get the variant of the question being used in a given slot.
int | $slot | the number used to identify this question within this usage. |
int | the variant of this question that is being used. |
question_usage_by_activity::is_autosave_required | ( | $slot, | |
$postdata = null ) |
Check, based on the sequence number, whether this auto-save is still required.
int | $slot | the number used to identify this question within this usage. |
array | null | $postdata | the submitted data that constitutes the action. |
bool | true if the check variable is present and correct, otherwise false. |
|
static |
Create a question_usage_by_activity from records loaded from the database.
For internal use only.
Iterator | $records | Raw records loaded from the database. |
int | $qubaid | The id of the question usage we are loading. |
question_usage_by_activity | The newly constructed usage. |
question_usage_by_activity::manual_grade | ( | $slot, | |
$comment, | |||
$mark, | |||
$commentformat = null ) |
Perform a manual grading action on a question attempt.
int | $slot | the number used to identify this question within this usage. |
string | $comment | the comment being added to the question attempt. |
number | $mark | the mark that is being assigned. Can be null to just add a comment. |
int | $commentformat | one of the FORMAT_... constants. The format of $comment. |
question_usage_by_activity::preload_all_step_users | ( | ) |
Preload users of all question attempt steps.
dml_exception |
question_usage_by_activity::prepare_simulated_post_data | ( | $simulatedresponses | ) |
Transform an array of response data for slots to an array of post data as you would get from quiz attempt form.
$simulatedresponses | array keys are slot nos => contains arrays representing student responses which will be passed to question_definition\prepare_simulated_post_data method and then have the appropriate prefix added. |
array | simulated post data |
question_usage_by_activity::process_action | ( | $slot, | |
$submitteddata, | |||
$timestamp = null ) |
Process a specific action on a specific question.
int | $slot | the number used to identify this question within this usage. |
array | $submitteddata | the submitted data that constitutes the action. |
int | null | $timestamp | (optional) the timestamp to consider 'now'. |
question_usage_by_activity::process_all_actions | ( | $timestamp = null, | |
$postdata = null ) |
Process all the question actions in the current request.
If there is a parameter slots included in the post data, then only those question numbers will be processed, otherwise all questions in this useage will be.
This function also does update_question_flags().
int | $timestamp | optional, use this timestamp as 'now'. |
array | $postdata | optional, only intended for testing. Use this data instead of the data from $_POST. |
question_usage_by_activity::process_all_autosaves | ( | $timestamp = null, | |
$postdata = null ) |
Process all the question autosave data in the current request.
If there is a parameter slots included in the post data, then only those question numbers will be processed, otherwise all questions in this useage will be.
This function also does update_question_flags().
int | $timestamp | optional, use this timestamp as 'now'. |
array | $postdata | optional, only intended for testing. Use this data instead of the data from $_POST. |
question_usage_by_activity::process_autosave | ( | $slot, | |
$submitteddata, | |||
$timestamp = null ) |
Process an autosave action on a specific question.
int | $slot | the number used to identify this question within this usage. |
array | $submitteddata | the submitted data that constitutes the action. |
int | null | $timestamp | (optional) the timestamp to consider 'now'. |
question_usage_by_activity::question_count | ( | ) |
int | the number of questions that are currently in this usage. |
question_usage_by_activity::regrade_all_questions | ( | $finished = false | ) |
Regrade all the questions in this usage (without changing their max mark).
bool | $finished | whether each question should be forced to be finished after the regrade, or whether it may still be in progress (default false). |
question_usage_by_activity::regrade_question | ( | $slot, | |
$finished = false, | |||
$newmaxmark = null, | |||
question_definition | $otherversion = null ) |
Regrade a question in this usage.
This replays the sequence of submitted actions to recompute the outcomes.
int | $slot | the number used to identify this question within this usage. |
bool | $finished | whether the question attempt should be forced to be finished after the regrade, or whether it may still be in progress (default false). |
number | $newmaxmark | (optional) if given, will change the max mark while regrading. |
question_definition | null | $otherversion | a different version of the question to use in the regrade. (By default, the regrode will use exactly the same question version.) |
question_usage_by_activity::render_question | ( | $slot, | |
$options, | |||
$number = null ) |
Get the core_question_renderer, in collaboration with appropriate qbehaviour_renderer and qtype_renderer subclasses, to generate the HTML to display this question.
int | $slot | the number used to identify this question within this usage. |
question_display_options | $options | controls how the question is rendered. |
string | null | $number | The question number to display. 'i' is a special value that gets displayed as Information. Null means no number is displayed. |
string | HTML fragment representing the question. |
question_usage_by_activity::render_question_at_step | ( | $slot, | |
$seq, | |||
$options, | |||
$number = null ) |
Like render_question() but displays the question at the past step indicated by $seq, rather than showing the latest step.
int | $slot | the number used to identify this question within this usage. |
int | $seq | the seq number of the past state to display. |
question_display_options | $options | controls how the question is rendered. |
string | null | $number | The question number to display. 'i' is a special value that gets displayed as Information. Null means no number is displayed. |
string | HTML fragment representing the question. |
question_usage_by_activity::render_question_head_html | ( | $slot | ) |
Generate any bits of HTML that needs to go in the <head> tag when this question is displayed in the body.
int | $slot | the number used to identify this question within this usage. |
string | HTML fragment. |
question_usage_by_activity::replace_loaded_question_attempt_info | ( | $slot, | |
$qa ) |
Replace a particular question_attempt with a different one.
For internal use only. Used when reloading the state of a question from the database.
int | $slot | the slot number of the question to replace. |
question_attempt | $qa | the question attempt to put in that place. |
question_usage_by_activity::set_id_from_database | ( | $id | ) |
For internal use only.
Used by question_engine_data_mapper to set the id when a usage is saved to the database.
int | $id | the newly determined id for this usage. |
question_usage_by_activity::set_max_mark | ( | $slot, | |
$maxmark ) |
Change the max mark for this question_attempt.
int | $slot | the slot number of the question of inerest. |
float | $maxmark | the new max mark. |
question_usage_by_activity::set_observer | ( | $observer | ) |
You should almost certainly not call this method from your code.
It is for internal use only.
question_usage_observer | that should be used to tracking changes made to this usage. |
question_usage_by_activity::set_preferred_behaviour | ( | $behaviour | ) |
string | $behaviour | the name of an archetypal behaviour, that should be used by questions in this usage if possible. |
question_usage_by_activity::set_question_attempt_metadata | ( | $slot, | |
$name, | |||
$value ) |
Set some metadata for a particular question attempt in this usage.
int | $slot | the slot number of the question of inerest. |
string | $name | the name of the metadata variable to return. |
string | $value | the value to set that metadata variable to. |
question_usage_by_activity::start_all_questions | ( | question_variant_selection_strategy | $variantstrategy = null, |
$timestamp = null, | |||
$userid = null ) |
Start the attempt at all questions that has been added to this usage.
question_variant_selection_strategy | how to pick which variant of each question to use. | |
int | $timestamp | optional, the timstamp to record for this action. Defaults to now. |
int | $userid | optional, the user to attribute this action to. Defaults to the current user. |
question_usage_by_activity::start_question | ( | $slot, | |
$variant = null, | |||
$timenow = null ) |
Start the attempt at a question that has been added to this usage.
int | $slot | the number used to identify this question within this usage. |
int | $variant | which variant of the question to use. Must be between 1 and ->get_num_variants($slot) inclusive. If not give, a variant is chosen at random. |
int | null | $timenow | optional, the timstamp to record for this action. Defaults to now. |
question_usage_by_activity::start_question_based_on | ( | $slot, | |
question_attempt | $oldqa ) |
Start the attempt at a question, starting from the point where the previous question_attempt $oldqa had reached.
This is used by the quiz 'Each attempt builds on last' mode.
int | $slot | the number used to identify this question within this usage. |
question_attempt | $oldqa | a previous attempt at this quetsion that defines the starting point. |
question_usage_by_activity::update_question_flags | ( | $postdata = null | ) |
Update the flagged state for all question_attempts in this usage, if their flagged state was changed in the request.
array | null | $postdata | optional, only intended for testing. Use this data instead of the data from $_POST. |
question_usage_by_activity::validate_can_regrade_with_other_version | ( | int | $slot, |
question_definition | $otherversion ) |
Verify if the question_attempt in the given slot can be regraded with that other question version.
int | $slot | the number used to identify this question within this usage. |
question_definition | $otherversion | a different version of the question to use in the regrade. |
string|null | null if the regrade can proceed, else a reason why not. |
question_usage_by_activity::validate_sequence_number | ( | $slot, | |
$postdata = null ) |
Check that the sequence number, that detects weird things like the student clicking back, is OK.
If the sequence check variable is not present, returns false. If the check variable is present and correct, returns true. If the variable is present and wrong, throws an exception.
int | $slot | the number used to identify this question within this usage. |
array | null | $postdata | (optional) data to use in place of $_POST. |
bool | true if the check variable is present and correct. False if it is missing. (Throws an exception if the check fails.) |
|
protected |
the id for this usage.
If this usage was loaded from the database, then this is the database id. Otherwise a unique random string is used.