Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Stores one step in a {. More...
Public Member Functions | |
__construct ($data=array(), $timecreated=null, $userid=null, $existingstepid=null) | |
You should not need to call this constructor in your own code. | |
add_full_user_object (stdClass $user) | |
Update full user information for step. | |
get_all_data () | |
Get all the data. | |
get_behaviour_data () | |
Get all the behaviour variables. | |
get_behaviour_var ($name) | |
get_fraction () | |
get_id () | |
get_metadata_var ($name) | |
Get a metadata variable. | |
get_qt_data () | |
Get all the question type variables. | |
get_qt_files ($name, $contextid) | |
Get the latest set of files for a particular question type variable of type question_attempt\PARAM_FILES. | |
get_qt_var ($name) | |
get_state () | |
get_submitted_data () | |
Get all the submitted data, but not the cached data. | |
get_timecreated () | |
get_user () | |
Return the full user object. | |
get_user_fullname () | |
Get full name of user who did action. | |
get_user_id () | |
has_behaviour_var ($name) | |
has_metadata_var ($name) | |
Whether this step has a metadata variable. | |
has_qt_var ($name) | |
prepare_response_files_draft_itemid ($name, $contextid) | |
Prepare a draft file are for the files belonging the a response variable of this step. | |
prepare_response_files_draft_itemid_with_text ($name, $contextid, $text) | |
Prepare a draft file are for the files belonging the a response variable of this step, while rewriting the URLs in some text. | |
rewrite_response_pluginfile_urls ($text, $contextid, $name, $extras) | |
Rewrite the @PLUGINFILE@ tokens in a response variable from this step that contains links to file. | |
set_behaviour_var ($name, $value) | |
Set a cached behaviour variable. | |
set_fraction ($fraction) | |
Set the fraction. | |
set_metadata_var ($name, $value) | |
Set a metadata variable. | |
set_qt_var ($name, $value) | |
Set a cached question type variable. | |
set_state ($state) | |
Set the state. | |
Static Public Member Functions | |
static | load_from_records ($records, $attemptstepid, $qtype=null) |
Create a question_attempt_step from records loaded from the database. | |
Stores one step in a {.
The most important attributes of a step are the state, which is one of the {
A step also tracks the time it was created, and the user responsible for creating it.
The submitted data is basically just an array of name => value pairs, with certain conventions about the to divide the variables into five = 2 x 2 + 1 categories.
Variables may either belong to the behaviour, in which case the name starts with a '-', or they may belong to the question type in which case they name does not start with a '-'.
Second, variables may either be ones that came form the original request, in which case the name does not start with an _, or they are cached values that were created during processing, in which case the name does start with an _.
In addition, we can store 'metadata', typically only in the first step of a question attempt. These are stored with the initial characters ':_'.
That is, each name will start with one of '', '_', '-', '-_' or ':_'. The remainder of the name was supposed to match the regex [a-z][a-z0-9]* - but this has never been enforced. Question types exist which break this rule. E.g. qtype_combined. Perhpas now, an accurate regex would be [a-z][a-z0-9_:]*.
These variables can be accessed with {
question_attempt_step::__construct | ( | $data = array(), | |
$timecreated = null, | |||
$userid = null, | |||
$existingstepid = null ) |
You should not need to call this constructor in your own code.
Steps are normally created by {
array | $data | the submitted data that defines this step. |
int | $timestamp | the time to record for the action. (If not given, use now.) |
int | $userid | the user to attribute the aciton to. (If not given, use the current user.) |
int | $existingstepid | if this step is going to replace an existing step (for example, during a regrade) this is the id of the previous step we are replacing. |
question_attempt_step::add_full_user_object | ( | stdClass | $user | ) |
Update full user information for step.
stdClass | $user | Full user object. |
coding_exception |
question_attempt_step::get_all_data | ( | ) |
Get all the data.
behaviour variables have the - at the start of their name. This is only intended for internal use, for example by {
array | name => value pairs. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_behaviour_data | ( | ) |
Get all the behaviour variables.
array | name => value pairs. NOTE! the name has the leading - stripped off. (If you don't understand the note, read the comment at the top of this class :-)) |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_behaviour_var | ( | $name | ) |
string | $name | the name of a behaviour variable to look for in the submitted data. |
string | the requested variable, or null if the variable is not set. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_fraction | ( | ) |
null|number | the fraction (grade on a scale of minfraction .. maxfraction, normally 0..1), or null if this step has not been marked. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_id | ( | ) |
int|null | The id of this step in the database. null if this step is not stored in the database. |
question_attempt_step::get_metadata_var | ( | $name | ) |
Get a metadata variable.
Do not call this method directly from your code. It is for internal use only. You should call {
string | $name | the name of the variable to set. [a-z][a-z0-9]*. |
string | the value to set previously, or null if this variable was never set. |
question_attempt_step::get_qt_data | ( | ) |
Get all the question type variables.
array | name => value pairs. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_qt_files | ( | $name, | |
$contextid ) |
Get the latest set of files for a particular question type variable of type question_attempt\PARAM_FILES.
string | $name | the name of the associated variable. |
int | $contextid | contextid of the question attempt |
array | of { |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_qt_var | ( | $name | ) |
string | $name | the name of a question type variable to look for in the submitted data. |
string | the requested variable, or null if the variable is not set. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_state | ( | ) |
question_state | The state after this step. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_submitted_data | ( | ) |
Get all the submitted data, but not the cached data.
behaviour variables have the - at the start of their name. This is only really intended for use by {
array | name => value pairs. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_timecreated | ( | ) |
int | the timestamp when this step was created. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::get_user | ( | ) |
Return the full user object.
stdClass | Get full user object. |
question_attempt_step::get_user_fullname | ( | ) |
Get full name of user who did action.
string | full name of user. |
question_attempt_step::get_user_id | ( | ) |
int | the id of the user resonsible for creating this step. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::has_behaviour_var | ( | $name | ) |
string | $name | the name of a behaviour variable to look for in the submitted data. |
bool | whether a variable with this name exists in the question type data. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::has_metadata_var | ( | $name | ) |
Whether this step has a metadata variable.
Do not call this method directly from your code. It is for internal use only. You should call {
string | $name | the name of the variable to set. [a-z][a-z0-9]*. |
bool | the value to set previously, or null if this variable was never set. |
question_attempt_step::has_qt_var | ( | $name | ) |
string | $name | the name of a question type variable to look for in the submitted data. |
bool | whether a variable with this name exists in the question type data. |
Reimplemented in question_attempt_step_subquestion_adapter.
|
static |
Create a question_attempt_step from records loaded from the database.
Iterator | $records | Raw records loaded from the database. |
int | $stepid | The id of the records to extract. |
string | $qtype | The question type of which this is an attempt. If not given, each record must include a qtype field. |
question_attempt_step | The newly constructed question_attempt_step. |
question_attempt_step::prepare_response_files_draft_itemid | ( | $name, | |
$contextid ) |
Prepare a draft file are for the files belonging the a response variable of this step.
string | $name | the variable name the files belong to. |
int | $contextid | the id of the context the quba belongs to. |
int | the draft itemid. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::prepare_response_files_draft_itemid_with_text | ( | $name, | |
$contextid, | |||
$text ) |
Prepare a draft file are for the files belonging the a response variable of this step, while rewriting the URLs in some text.
string | $name | the variable name the files belong to. |
int | $contextid | the id of the context the quba belongs to. |
string | null | $text | the text to update the URLs in. |
array(int,string) | the draft itemid and the text with URLs rewritten. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::rewrite_response_pluginfile_urls | ( | $text, | |
$contextid, | |||
$name, | |||
$extras ) |
Rewrite the @PLUGINFILE@ tokens in a response variable from this step that contains links to file.
Normally you should probably call {
string | $text | the text to update the URLs in. |
int | $contextid | the id of the context the quba belongs to. |
string | $name | the variable name the files belong to. |
array | $extras | extra file path components. |
string | the rewritten text. |
Reimplemented in question_attempt_step_subquestion_adapter.
question_attempt_step::set_behaviour_var | ( | $name, | |
$value ) |
Set a cached behaviour variable.
string | $name | the name of the variable to set. Must match _[a-z][a-z0-9]*. |
string | $value | the value to set. |
Reimplemented in question_attempt_step_read_only, and question_attempt_step_subquestion_adapter.
question_attempt_step::set_fraction | ( | $fraction | ) |
Set the fraction.
Normally only called by behaviours.
null | number | $fraction | the fraction to set. |
Reimplemented in question_attempt_step_read_only, and question_attempt_step_subquestion_adapter.
question_attempt_step::set_metadata_var | ( | $name, | |
$value ) |
Set a metadata variable.
Do not call this method directly from your code. It is for internal use only. You should call {
string | $name | the name of the variable to set. [a-z][a-z0-9]*. |
string | $value | the value to set. |
question_attempt_step::set_qt_var | ( | $name, | |
$value ) |
Set a cached question type variable.
string | $name | the name of the variable to set. Must match _[a-z][a-z0-9]*. |
string | $value | the value to set. |
Reimplemented in question_attempt_step_read_only, and question_attempt_step_subquestion_adapter.
question_attempt_step::set_state | ( | $state | ) |
Set the state.
Normally only called by behaviours.
question_state | $state | one of the { |
Reimplemented in question_attempt_step_read_only, and question_attempt_step_subquestion_adapter.