|
Moodle
2.2.1
http://www.collinsharper.com
|


Public Member Functions | |
| start_attempt (question_attempt_step $step, $variant) | |
| apply_attempt_state (question_attempt_step $step) | |
| get_question_summary () | |
| get_min_fraction () | |
| get_expected_data () | |
| get_correct_response () | |
| is_complete_response (array $response) | |
| is_gradable_response (array $response) | |
| is_same_response (array $prevresponse, array $newresponse) | |
| get_validation_error (array $response) | |
| grade_response (array $response) | |
| summarise_response (array $response) | |
| check_file_access ($qa, $options, $component, $filearea, $args, $forcedownload) | |
Data Fields | |
| $subquestions = array() | |
| $places | |
| $textfragments | |
Protected Member Functions | |
| get_substep ($step, $i) | |
| combine_states ($overallstate, $newstate) | |
Represents a multianswer question.
A multi-answer question is made of of several subquestions of various types. You can think of it as an application of the composite pattern to qusetion types.
Definition at line 42 of file question.php.
| apply_attempt_state | ( | question_attempt_step $ | step | ) |
When an in-progress question_attempt is re-loaded from the database, this method is called so that the question can re-initialise its internal state as needed by this attempt.
For example, the multiple choice question type needs to set the order of the choices to the order that was set up when start_attempt was called originally. All the information required to do this should be in the $step object, which is the first step of the question_attempt being loaded.
| question_attempt_step | The first step of the question_attempt being loaded. |
Reimplemented from question_definition.
Definition at line 74 of file question.php.

| check_file_access | ( | $ | qa, |
| $ | options, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | args, | ||
| $ | forcedownload | ||
| ) |
Checks whether the users is allow to be served a particular file.
| question_attempt | $qa | the question attempt being displayed. |
| 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. |
Reimplemented from question_definition.
Definition at line 247 of file question.php.

| combine_states | ( | $ | overallstate, |
| $ | newstate | ||
| ) | [protected] |
Used by grade_response to combine the states of the subquestions. The combined state is accumulates in $overallstate. That will be right if all the separate states are right; and wrong if all the separate states are wrong, otherwise, it will be partially right.
| question_state | $overallstate | the result so far. |
| question_state | $newstate | the new state to add to the combination. |
Definition at line 192 of file question.php.

What data would need to be submitted to get this question correct. If there is more than one correct answer, this method should just return one possibility. If it is not possible to compute a correct response, this method should return null.
Reimplemented from question_definition.
Definition at line 132 of file question.php.

What data may be included in the form submission when a student submits this question in its current state?
This information is used in calls to optional_param. The parameter name has question_attempt::get_field_prefix() automatically prepended.
Reimplemented from question_definition.
Definition at line 115 of file question.php.

| get_min_fraction | ( | ) |
Some questions can return a negative mark if the student gets it wrong.
This method returns the lowest mark the question can return, on the fraction scale. that is, where the maximum possible mark is 1.0.
Reimplemented from question_definition.
Definition at line 105 of file question.php.
Generate a brief, plain-text, summary of this question. This is used by various reports. This should show the particular variant of the question as presented to students. For example, the calculated quetsion type would fill in the particular numbers that were presented to the student. This method will return null if such a summary is not possible, or inappropriate.
Reimplemented from question_definition.
Definition at line 80 of file question.php.

| get_substep | ( | $ | step, |
| $ | i | ||
| ) | [protected] |
Get a question_attempt_step_subquestion_adapter
| question_attempt_step | $step | the step to adapt. |
| int | $i | the subquestion index. |
Definition at line 64 of file question.php.

| get_validation_error | ( | array $ | response | ) |
In situations where is_gradable_response() returns false, this method should generate a description of what the problem is.
Implements question_automatically_gradable.
Definition at line 174 of file question.php.

| grade_response | ( | array $ | response | ) |
Grade a response to the question, returning a fraction between get_min_fraction() and 1.0, and the corresponding question_state right, partial or wrong.
| array | $response | responses, as returned by question_attempt_step::get_qt_data(). |
Implements question_automatically_gradable.
Definition at line 215 of file question.php.

| is_complete_response | ( | array $ | response | ) |
Used by many of the behaviours, to work out whether the student's response to the question is complete. That is, whether the question attempt should move to the COMPLETE or INCOMPLETE state.
| array | $response | responses, as returned by question_attempt_step::get_qt_data(). |
Implements question_manually_gradable.
Definition at line 143 of file question.php.

| is_gradable_response | ( | array $ | response | ) |
Use by many of the behaviours to determine whether the student has provided enough of an answer for the question to be graded automatically, or whether it must be considered aborted.
| array | $response | responses, as returned by question_attempt_step::get_qt_data(). |
Reimplemented from question_graded_automatically.
Definition at line 153 of file question.php.

| is_same_response | ( | array $ | prevresponse, |
| array $ | newresponse | ||
| ) |
Use by many of the behaviours to determine whether the student's response has changed. This is normally used to determine that a new set of responses can safely be discarded.
| array | $prevresponse | the responses previously recorded for this question, as returned by question_attempt_step::get_qt_data() |
| array | $newresponse | the new responses, in the same format. |
Implements question_manually_gradable.
Definition at line 163 of file question.php.

| start_attempt | ( | question_attempt_step $ | step, |
| $ | variant | ||
| ) |
Start a new attempt at this question, storing any information that will be needed later in the step.
This is where the question can do any initialisation required on a per-attempt basis. For example, this is where the multiple choice question type randomly shuffles the choices (if that option is set).
Any information about how the question has been set up for this attempt should be stored in the $step, by calling $step->set_qt_var(...).
| question_attempt_step | The first step of the question_attempt being started. Can be used to store state. | |
| int | $varant | which variant of this question to start. Will be between 1 and get_num_variants() inclusive. |
Reimplemented from question_definition.
Definition at line 68 of file question.php.

| summarise_response | ( | array $ | response | ) |
Produce a plain text summary of a response.
| $response | a response, as might be passed to grade_response(). |
Implements question_manually_gradable.
Definition at line 234 of file question.php.

| $places |
Definition at line 50 of file question.php.
| $subquestions = array() |
Definition at line 44 of file question.php.
| $textfragments |
Definition at line 56 of file question.php.