Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 and 403]

This file defines the question attempt class, and a few related classes.

Copyright: 2009 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2021 lines (78 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 0 files

Defines 5 classes

question_attempt:: (100 methods):
  __construct()
  get_full_qa()
  get_question()
  get_question_id()
  get_variant()
  set_slot()
  get_slot()
  get_database_id()
  set_database_id()
  set_observer()
  get_usage_id()
  set_usage_id()
  get_behaviour_name()
  get_behaviour()
  set_flagged()
  is_flagged()
  get_flag_field_name()
  get_qt_field_name()
  get_behaviour_field_name()
  get_control_field_name()
  get_field_prefix()
  get_outer_question_div_unique_id()
  get_step()
  get_sequence_check_count()
  get_num_steps()
  get_last_step()
  has_autosaved_step()
  get_step_iterator()
  get_full_step_iterator()
  get_reverse_step_iterator()
  get_last_qt_data()
  get_last_step_with_qt_var()
  get_last_step_with_behaviour_var()
  get_last_qt_var()
  get_last_qt_files()
  get_response_file_url()
  prepare_response_files_draft_itemid()
  get_last_behaviour_var()
  get_state()
  get_state_string()
  get_state_class()
  get_last_action_time()
  get_fraction()
  has_marks()
  get_mark()
  get_current_manual_mark()
  fraction_to_mark()
  get_max_mark()
  get_min_fraction()
  get_max_fraction()
  format_mark()
  format_fraction_as_mark()
  format_max_mark()
  get_applicable_hint()
  summarise_action()
  get_metadata()
  set_metadata()
  extra_file_path_components()
  rewrite_pluginfile_urls()
  rewrite_response_pluginfile_urls()
  render()
  render_head_html()
  render_at_step()
  check_file_access()
  add_step()
  add_autosaved_step()
  discard_autosaved_step()
  convert_autosaved_step_to_real_step()
  select_variant()
  start()
  start_based_on()
  get_resume_data()
  get_submitted_var()
  validate_manual_mark()
  process_response_files()
  get_expected_data()
  get_all_submitted_qt_vars()
  get_submitted_data()
  check_qt_var_name_restrictions()
  get_correct_response()
  set_question_summary()
  get_question_summary()
  get_response_summary()
  get_right_answer_summary()
  can_finish_during_attempt()
  process_action()
  process_autosave()
  finish()
  validate_can_regrade_with_other_version()
  regrade()
  get_attempt_state_data_to_regrade_with_version()
  set_max_mark()
  manual_grade()
  has_manual_comment()
  get_manual_comment()
  get_current_manual_comment()
  classify_response()
  load_from_records()
  ensure_question_initialised()
  get_steps_with_submitted_response_iterator()

question_attempt_with_restricted_history:: (11 methods):
  __construct()
  get_full_qa()
  get_full_step_iterator()
  add_step()
  process_action()
  start()
  set_database_id()
  set_flagged()
  set_slot()
  set_question_summary()
  set_usage_id()

question_attempt_step_iterator:: (10 methods):
  __construct()
  current()
  key()
  next()
  rewind()
  valid()
  offsetExists()
  offsetGet()
  offsetSet()
  offsetUnset()

question_attempt_reverse_step_iterator:: (2 methods):
  next()
  rewind()

question_attempt_steps_with_submitted_response_iterator:: (13 methods):
  __construct()
  find_steps_with_submitted_response()
  current()
  key()
  next()
  rewind()
  valid()
  offsetExists()
  offsetGet()
  count()
  step_no_for_try()
  offsetSet()
  offsetUnset()


Class: question_attempt  - X-Ref

Tracks an attempt at one particular question in a {@link question_usage_by_activity}.

Most calling code should need to access objects of this class. They should be
able to do everything through the usage interface. This class is an internal
implementation detail of the question engine.

Instances of this class correspond to rows in the question_attempts table, and
a collection of {@link question_attempt_steps}. Question inteaction models and
question types do work with question_attempt objects.

__construct(question_definition $question, $usageid,question_usage_observer $observer = null, $maxmark = null)   X-Ref
Create a new {@link question_attempt}. Normally you should create question_attempts
indirectly, by calling {@link question_usage_by_activity::add_question()}.

param: question_definition $question the question this is an attempt at.
param: int|string $usageid The id of the
param: question_usage_observer $observer tracks changes to the useage this
param: number $maxmark the maximum grade for this question_attempt. If not

get_full_qa()   X-Ref
This method exists so that {@link question_attempt_with_restricted_history}
can override it. You should not normally need to call it.

return: question_attempt return ourself.

get_question($requirequestioninitialised = true)   X-Ref
Get the question that is being attempted.

param: bool $requirequestioninitialised set this to false if you don't need
return: question_definition the question this is an attempt at.

get_question_id()   X-Ref
Get the id of the question being attempted.

return: int question id.

get_variant()   X-Ref
Get the variant of the question being used in a given slot.

return: int the variant number.

set_slot($slot)   X-Ref
Set the number used to identify this question_attempt within the usage.
For internal use only.

param: int $slot

get_slot()   X-Ref
No description

get_database_id()   X-Ref

return: int the id of row for this question_attempt, if it is stored in the

set_database_id($id)   X-Ref
For internal use only. Set the id of the corresponding database row.

param: int $id the id of row for this question_attempt, if it is

set_observer($observer)   X-Ref
You should almost certainly not call this method from your code. It is for
internal use only.

param: question_usage_observer that should be used to tracking changes made to this qa.

get_usage_id()   X-Ref
No description

set_usage_id($usageid)   X-Ref
Set the id of the {@link question_usage_by_activity} we belong to.
For internal use only.

param: int|string the new id.

get_behaviour_name()   X-Ref
No description

get_behaviour($requirequestioninitialised = true)   X-Ref
For internal use only.

param: bool $requirequestioninitialised set this to false if you don't need
return: question_behaviour the behaviour that is controlling this attempt.

set_flagged($flagged)   X-Ref
Set the flagged state of this question.

param: bool $flagged the new state.

is_flagged()   X-Ref
No description

get_flag_field_name()   X-Ref
Get the name (in the sense a HTML name="" attribute, or a $_POST variable
name) to use for the field that indicates whether this question is flagged.

return: string The field name to use.

get_qt_field_name($varname)   X-Ref
Get the name (in the sense a HTML name="" attribute, or a $_POST variable
name) to use for a question_type variable belonging to this question_attempt.

See the comment on {@link question_attempt_step} for an explanation of
question type and behaviour variables.

param: string $varname The short form of the variable name.
return: string The field name to use.

get_behaviour_field_name($varname)   X-Ref
Get the name (in the sense a HTML name="" attribute, or a $_POST variable
name) to use for a question_type variable belonging to this question_attempt.

See the comment on {@link question_attempt_step} for an explanation of
question type and behaviour variables.

param: string $varname The short form of the variable name.
return: string The field name to use.

get_control_field_name($varname)   X-Ref
Get the name (in the sense a HTML name="" attribute, or a $_POST variable
name) to use for a control variables belonging to this question_attempt.

Examples are :sequencecheck and :flagged

param: string $varname The short form of the variable name.
return: string The field name to use.

get_field_prefix()   X-Ref
Get the prefix added to variable names to give field names for this
question attempt.

You should not use this method directly. This is an implementation detail
anyway, but if you must access it, use {@link question_usage_by_activity::get_field_prefix()}.

return: string The field name to use.

get_outer_question_div_unique_id()   X-Ref
When the question is rendered, this unique id is added to the
outer div of the question. It can be used to uniquely reference
the question from JavaScript.

return: string id added to the outer <div class="que ..."> when the question is rendered.

get_step($i)   X-Ref
Get one of the steps in this attempt.

param: int $i the step number, which counts from 0.
return: question_attempt_step

get_sequence_check_count()   X-Ref
Get the number of real steps in this attempt.
This is put as a hidden field in the HTML, so that when we receive some
data to process, then we can check that it came from the question
in the state we are now it.

return: int a number that summarises the current state of this question attempt.

get_num_steps()   X-Ref
Get the number of steps in this attempt.
For internal/test code use only.

return: int the number of steps we currently have.

get_last_step()   X-Ref
Return the latest step in this question_attempt.
For internal/test code use only.

return: question_attempt_step

has_autosaved_step()   X-Ref

return: boolean whether this question_attempt has autosaved data from

get_step_iterator()   X-Ref

return: question_attempt_step_iterator for iterating over the steps in

get_full_step_iterator()   X-Ref
The same as {@link get_step_iterator()}. However, for a
{@link question_attempt_with_restricted_history} this returns the full
list of steps, while {@link get_step_iterator()} returns only the
limited history.

return: question_attempt_step_iterator for iterating over the steps in

get_reverse_step_iterator()   X-Ref

return: question_attempt_reverse_step_iterator for iterating over the steps in

get_last_qt_data($default = array()   X-Ref
Get the qt data from the latest step that has any qt data. Return $default
array if it is no step has qt data.

param: mixed default the value to return no step has qt data.
return: array|mixed the data, or $default if there is not any.

get_last_step_with_qt_var($name)   X-Ref
Get the last step with a particular question type varialbe set.

param: string $name the name of the variable to get.
return: question_attempt_step the last step, or a step with no variables

get_last_step_with_behaviour_var($name)   X-Ref
Get the last step with a particular behaviour variable set.

param: string $name the name of the variable to get.
return: question_attempt_step the last step, or a step with no variables

get_last_qt_var($name, $default = null)   X-Ref
Get the latest value of a particular question type variable. That is, get
the value from the latest step that has it set. Return null if it is not
set in any step.

param: string $name the name of the variable to get.
param: mixed default the value to return in the variable has never been set.
return: mixed string value, or $default if it has never been set.

get_last_qt_files($name, $contextid)   X-Ref
Get the latest set of files for a particular question type variable of
type question_attempt::PARAM_FILES.

param: string $name the name of the associated variable.
param: int $contextid the context to which the files are linked.
return: array of {@link stored_files}.

get_response_file_url(stored_file $file)   X-Ref
Get the URL of a file that belongs to a response variable of this
question_attempt.

param: stored_file $file the file to link to.
return: string the URL of that file.

prepare_response_files_draft_itemid($name, $contextid)   X-Ref
Prepare a draft file are for the files belonging the a response variable
of this question attempt. The draft area is populated with the files from
the most recent step having files.

param: string $name the variable name the files belong to.
param: int $contextid the id of the context the quba belongs to.
return: int the draft itemid.

get_last_behaviour_var($name, $default = null)   X-Ref
Get the latest value of a particular behaviour variable. That is,
get the value from the latest step that has it set. Return null if it is
not set in any step.

param: string $name the name of the variable to get.
param: mixed default the value to return in the variable has never been set.
return: mixed string value, or $default if it has never been set.

get_state()   X-Ref
Get the current state of this question attempt. That is, the state of the
latest step.

return: question_state

get_state_string($showcorrectness)   X-Ref

param: bool $showcorrectness Whether right/partial/wrong states should
return: string A brief textual description of the current state.

get_state_class($showcorrectness)   X-Ref

param: bool $showcorrectness Whether right/partial/wrong states should
return: string a CSS class name for the current state.

get_last_action_time()   X-Ref

return: int the timestamp of the most recent step in this question attempt.

get_fraction()   X-Ref
Get the current fraction of this question attempt. That is, the fraction
of the latest step, or null if this question has not yet been graded.

return: number the current fraction.

has_marks()   X-Ref
No description

get_mark()   X-Ref

return: number the current mark for this question.

get_current_manual_mark()   X-Ref
This is used by the manual grading code, particularly in association with
validation. It gets the current manual mark for a question, in exactly the string
form that the teacher entered it, if possible. This may come from the current
POST request, if there is one, otherwise from the database.

return: string the current manual mark for this question, in the format the teacher typed,

fraction_to_mark($fraction)   X-Ref

param: number|null $fraction a fraction.
return: number|null the corresponding mark.

get_max_mark()   X-Ref

return: float the maximum mark possible for this question attempt.

get_min_fraction()   X-Ref
No description

get_max_fraction()   X-Ref
No description

format_mark($dp)   X-Ref
The current mark, formatted to the stated number of decimal places. Uses
{@link format_float()} to format floats according to the current locale.

param: int $dp number of decimal places.
return: string formatted mark.

format_fraction_as_mark($fraction, $dp)   X-Ref
The a mark, formatted to the stated number of decimal places. Uses
{@link format_float()} to format floats according to the current locale.

param: number $fraction a fraction.
param: int $dp number of decimal places.
return: string formatted mark.

format_max_mark($dp)   X-Ref
The maximum mark for this question attempt, formatted to the stated number
of decimal places. Uses {@link format_float()} to format floats according
to the current locale.

param: int $dp number of decimal places.
return: string formatted maximum mark.

get_applicable_hint()   X-Ref
Return the hint that applies to the question in its current state, or null.

return: question_hint|null

summarise_action(question_attempt_step $step)   X-Ref
Produce a plain-text summary of what the user did during a step.

param: question_attempt_step $step the step in question.
return: string a summary of what was done during that step.

get_metadata($name)   X-Ref
Return one of the bits of metadata for a this question attempt.

param: string $name the name of the metadata variable to return.
return: string the value of that metadata variable.

set_metadata($name, $value)   X-Ref
Set some metadata for this question attempt.

param: string $name the name of the metadata variable to return.
param: string $value the value to set that metadata variable to.

extra_file_path_components()   X-Ref
Helper function used by {@link rewrite_pluginfile_urls()} and
{@link rewrite_response_pluginfile_urls()}.

return: array ids that need to go into the file paths.

rewrite_pluginfile_urls($text, $component, $filearea, $itemid)   X-Ref
Calls {@link question_rewrite_question_urls()} with appropriate parameters
for content belonging to this question.

param: string $text the content to output.
param: string $component the component name (normally 'question' or 'qtype_...')
param: string $filearea the name of the file area.
param: int $itemid the item id.
return: string the content with the URLs rewritten.

rewrite_response_pluginfile_urls($text, $contextid, $name,question_attempt_step $step)   X-Ref
Calls {@link question_rewrite_question_urls()} with appropriate parameters
for content belonging to responses to this question.

param: string $text the text to update the URLs in.
param: int $contextid the id of the context the quba belongs to.
param: string $name the variable name the files belong to.
param: question_attempt_step $step the step the response is coming from.
return: string the content with the URLs rewritten.

render($options, $number, $page = null)   X-Ref
Get the {@link core_question_renderer}, in collaboration with appropriate
{@link qbehaviour_renderer} and {@link qtype_renderer} subclasses, to generate the
HTML to display this question attempt in its current state.

param: question_display_options $options controls how the question is rendered.
param: string|null $number The question number to display.
param: moodle_page|null $page the page the question is being redered to.
return: string HTML fragment representing the question.

render_head_html($page = null)   X-Ref
Generate any bits of HTML that needs to go in the <head> tag when this question
attempt is displayed in the body.

return: string HTML fragment.

render_at_step($seq, $options, $number, $preferredbehaviour)   X-Ref
Like {@link render_question()} but displays the question at the past step
indicated by $seq, rather than showing the latest step.

param: int $seq the seq number of the past state to display.
param: question_display_options $options controls how the question is rendered.
param: string|null $number The question number to display. 'i' is a special
param: string $preferredbehaviour the preferred behaviour. It is slightly
return: string HTML fragment representing the question.

check_file_access($options, $component, $filearea, $args, $forcedownload)   X-Ref
Checks whether the users is allow to be served a particular file.

param: question_display_options $options the options that control display of the question.
param: string $component the name of the component we are serving files for.
param: string $filearea the name of the file area.
param: array $args the remaining bits of the file path.
param: bool $forcedownload whether the user must be forced to download the file.
return: bool true if the user can access this file.

add_step(question_attempt_step $step)   X-Ref
Add a step to this question attempt.

param: question_attempt_step $step the new step.

add_autosaved_step(question_attempt_step $step)   X-Ref
Add an auto-saved step to this question attempt. We mark auto-saved steps by
changing saving the step number with a - sign.

param: question_attempt_step $step the new step.

discard_autosaved_step()   X-Ref
Discard any auto-saved data belonging to this question attempt.


convert_autosaved_step_to_real_step()   X-Ref
If there is an autosaved step, convert it into a real save, so that it
is preserved.


select_variant(question_variant_selection_strategy $variantstrategy)   X-Ref
Use a strategy to pick a variant.

param: question_variant_selection_strategy $variantstrategy a strategy.
return: int the selected variant.

start($preferredbehaviour, $variant, $submitteddata = array()   X-Ref
Start this question attempt.

You should not call this method directly. Call
{@link question_usage_by_activity::start_question()} instead.

param: string|question_behaviour $preferredbehaviour the name of the
param: int $variant the variant of the question to start. Between 1 and
param: array $submitteddata optional, used when re-starting to keep the same initial state.
param: int $timestamp optional, the timstamp to record for this action. Defaults to now.
param: int $userid optional, the user to attribute this action to. Defaults to the current user.
param: int $existingstepid optional, if this step is going to replace an existing step

start_based_on(question_attempt $oldqa)   X-Ref
Start this question attempt, starting from the point that the previous
attempt $oldqa had reached.

You should not call this method directly. Call
{@link question_usage_by_activity::start_question_based_on()} instead.

param: question_attempt $oldqa a previous attempt at this quetsion that

get_resume_data()   X-Ref
Used by {@link start_based_on()} to get the data needed to start a new
attempt from the point this attempt has go to.

return: array name => value pairs.

get_submitted_var($name, $type, $postdata = null)   X-Ref
Get a particular parameter from the current request. A wrapper round
{@link optional_param()}, except that the results is returned without
slashes.

param: string $name the paramter name.
param: int $type one of the standard PARAM_... constants, or one of the
param: array $postdata (optional, only inteded for testing use) take the
return: mixed the requested value.

validate_manual_mark($currentmark)   X-Ref
Validate the manual mark for a question.

param: string $currentmark the user input (e.g. '1,0', '1,0' or 'invalid'.
return: string any errors with the value, or '' if it is OK.

process_response_files($name, $draftidname, $postdata = null, $text = null)   X-Ref
Handle a submitted variable representing uploaded files.

param: string $name the field name.
param: string $draftidname the field name holding the draft file area id.
param: array $postdata (optional, only inteded for testing use) take the
param: string $text optional reponse text.
return: question_file_saver that can be used to save the files later.

get_expected_data($expected, $postdata, $extraprefix)   X-Ref
Get any data from the request that matches the list of expected params.

param: array $expected variable name => PARAM_... constant.
param: null|array $postdata null to use real post data, otherwise an array of data to use.
param: string $extraprefix '-' or ''.
return: array name => value.

get_all_submitted_qt_vars($postdata)   X-Ref
Get all the submitted question type data for this question, whithout checking
that it is valid or cleaning it in any way.

param: null|array $postdata null to use real post data, otherwise an array of data to use.
return: array name => value.

get_submitted_data($postdata = null)   X-Ref
Get all the sumbitted data belonging to this question attempt from the
current request.

param: array $postdata (optional, only inteded for testing use) take the
return: array name => value pairs that could be passed to {@link process_action()}.

check_qt_var_name_restrictions($expected)   X-Ref
Ensure that no reserved prefixes are being used by installed
question types.

param: array $expected An array of question type variables

get_correct_response()   X-Ref
Get a set of response data for this question attempt that would get the
best possible mark. If it is not possible to compute a correct
response, this method should return null.

return: array|null name => value pairs that could be passed to {@link process_action()}.

set_question_summary($questionsummary)   X-Ref
Change the quetsion summary. Note, that this is almost never necessary.
This method was only added to work around a limitation of the Opaque
protocol, which only sends questionLine at the end of an attempt.

param: string $questionsummary the new summary to set.

get_question_summary()   X-Ref

return: string a simple textual summary of the question that was asked.

get_response_summary()   X-Ref

return: string a simple textual summary of response given.

get_right_answer_summary()   X-Ref

return: string a simple textual summary of the correct resonse.

can_finish_during_attempt()   X-Ref
Whether this attempt at this question could be completed just by the
student interacting with the question, before {@link finish()} is called.

return: boolean whether this attempt can finish naturally.

process_action($submitteddata, $timestamp = null, $userid = null, $existingstepid = null)   X-Ref
Perform the action described by $submitteddata.

param: array $submitteddata the submitted data the determines the action.
param: int $timestamp the time to record for the action. (If not given, use now.)
param: int $userid the user to attribute the action to. (If not given, use the current user.)
param: int $existingstepid used by the regrade code.

process_autosave($submitteddata, $timestamp = null, $userid = null)   X-Ref
Process an autosave.

param: array $submitteddata the submitted data the determines the action.
param: int $timestamp the time to record for the action. (If not given, use now.)
param: int $userid the user to attribute the action to. (If not given, use the current user.)
return: bool whether anything was saved.

finish($timestamp = null, $userid = null)   X-Ref
Perform a finish action on this question attempt. This corresponds to an
external finish action, for example the user pressing Submit all and finish
in the quiz, rather than using one of the controls that is part of the
question.

param: int $timestamp the time to record for the action. (If not given, use now.)
param: int $userid the user to attribute the aciton to. (If not given, use the current user.)

validate_can_regrade_with_other_version(question_definition $otherversion)   X-Ref
Verify if this question_attempt in can be regraded with that other question version.

param: question_definition $otherversion a different version of the question to use in the regrade.
return: string|null null if the regrade can proceed, else a reason why not.

regrade(question_attempt $oldqa, $finished)   X-Ref
Perform a regrade. This replays all the actions from $oldqa into this
attempt.

param: question_attempt $oldqa the attempt to regrade.
param: bool $finished whether the question attempt should be forced to be finished

get_attempt_state_data_to_regrade_with_version(question_attempt_step $oldstep,question_definition $otherversion)   X-Ref
Helper used by regrading.

Get the data from the first step of the old attempt and, if necessary,
update it to be suitable for use with the other version of the question.

param: question_attempt_step $oldstep First step at an attempt at $otherversion of this question.
param: question_definition $otherversion Another version of the question being attempted.
return: array updated data required to restart an attempt with the current version of this question.

set_max_mark($maxmark)   X-Ref
Change the max mark for this question_attempt.

param: float $maxmark the new max mark.

manual_grade($comment, $mark, $commentformat = null, $timestamp = null, $userid = null)   X-Ref
Perform a manual grading action on this attempt.

param: string $comment the comment being added.
param: float $mark the new mark. If null, then only a comment is added.
param: int $commentformat the FORMAT_... for $comment. Must be given.
param: int $timestamp the time to record for the action. (If not given, use now.)
param: int $userid the user to attribute the aciton to. (If not given, use the current user.)

has_manual_comment()   X-Ref
No description

get_manual_comment()   X-Ref

return: array(string, int) the most recent manual comment that was added

get_current_manual_comment()   X-Ref
This is used by the manual grading code, particularly in association with
validation. If there is a comment submitted in the request, then use that,
otherwise use the latest comment for this question.

return: array with three elements, comment, commentformat and mark.

classify_response($whichtries = self::LAST_TRY)   X-Ref
Break down a student response by sub part and classification. See also {@link question::classify_response}.
Used for response analysis.

param: string $whichtries which tries to analyse for response analysis. Will be one of
return: question_classified_response[]|question_classified_response[][] If $whichtries is

load_from_records($records, $questionattemptid,question_usage_observer $observer, $preferredbehaviour)   X-Ref
Create a question_attempt_step from records loaded from the database.

For internal use only.

param: Iterator $records Raw records loaded from the database.
param: int $questionattemptid The id of the question_attempt to extract.
param: question_usage_observer $observer the observer that will be monitoring changes in us.
param: string $preferredbehaviour the preferred behaviour under which we are operating.
return: question_attempt The newly constructed question_attempt.

ensure_question_initialised()   X-Ref
This method is part of the lazy-initialisation of question objects.

Methods which require $this->question to be fully initialised
(to have had init_first_step or apply_attempt_state called on it)
should call this method before proceeding.

get_steps_with_submitted_response_iterator()   X-Ref
Allow access to steps with responses submitted by students for grading in a question attempt.

return: question_attempt_steps_with_submitted_response_iterator to access all steps with submitted data for questions that

Class: question_attempt_with_restricted_history  - X-Ref

This subclass of question_attempt pretends that only part of the step history
exists. It is used for rendering the question in past states.

All methods that try to modify the question_attempt throw exceptions.

__construct(question_attempt $baseqa, $lastseq, $preferredbehaviour)   X-Ref
Create a question_attempt_with_restricted_history

param: question_attempt $baseqa The question_attempt to make a restricted version of.
param: int $lastseq the index of the last step to include.
param: string $preferredbehaviour the preferred behaviour. It is slightly

get_full_qa()   X-Ref
No description

get_full_step_iterator()   X-Ref
No description

add_step(question_attempt_step $step)   X-Ref
No description

process_action($submitteddata, $timestamp = null, $userid = null, $existingstepid = null)   X-Ref
No description

start($preferredbehaviour, $variant, $submitteddata = array()   X-Ref
No description

set_database_id($id)   X-Ref
No description

set_flagged($flagged)   X-Ref
No description

set_slot($slot)   X-Ref
No description

set_question_summary($questionsummary)   X-Ref
No description

set_usage_id($usageid)   X-Ref
No description

Class: question_attempt_step_iterator  - X-Ref

A class abstracting access to the {@link question_attempt::$states} array.

This is actively linked to question_attempt. If you add an new step
mid-iteration, then it will be included.

__construct(question_attempt $qa)   X-Ref
Do not call this constructor directly.
Use {@link question_attempt::get_step_iterator()}.

param: question_attempt $qa the attempt to iterate over.

current()   X-Ref
No description

key()   X-Ref
No description

next()   X-Ref
No description

rewind()   X-Ref
No description

valid()   X-Ref
No description

offsetExists($i)   X-Ref
No description

offsetGet($i)   X-Ref
No description

offsetSet($offset, $value)   X-Ref
No description

offsetUnset($offset)   X-Ref
No description

Class: question_attempt_reverse_step_iterator  - X-Ref

A variant of {@link question_attempt_step_iterator} that iterates through the
steps in reverse order.

next()   X-Ref
No description

rewind()   X-Ref
No description

Class: question_attempt_steps_with_submitted_response_iterator  - X-Ref

A variant of {@link question_attempt_step_iterator} that iterates through the
steps with submitted tries.

__construct(question_attempt $qa)   X-Ref
Do not call this constructor directly.
Use {@link question_attempt::get_submission_step_iterator()}.

param: question_attempt $qa the attempt to iterate over.

find_steps_with_submitted_response()   X-Ref
Find the step nos  in which a student has submitted a response. Including any step with a response that is saved before
the question attempt finishes.

Called from constructor, should not be called from elsewhere.


current()   X-Ref
No description

key()   X-Ref
No description

next()   X-Ref
No description

rewind()   X-Ref
No description

valid()   X-Ref
No description

offsetExists($submittedresponseno)   X-Ref

param: int $submittedresponseno
return: bool

offsetGet($submittedresponseno)   X-Ref

param: int $submittedresponseno
return: question_attempt_step

count()   X-Ref

return: int the count of steps with tries.

step_no_for_try($submittedresponseno)   X-Ref

param: int $submittedresponseno
return: int|null the step number or null if there is no such submitted response.

offsetSet($offset, $value)   X-Ref
No description

offsetUnset($offset)   X-Ref
No description