This class represents a 'question' that actually does not allow the student to respond, like the description 'question' type.
More...
|
| __construct () |
| Constructor.
|
|
| __get ($name) |
| When a pending definition tries to read its latest version, fill in the latest version for all pending definitions.
|
|
| 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.
|
|
| check_file_access ($qa, $options, $component, $filearea, $args, $forcedownload) |
| Checks whether the users is allow to be served a particular file.
|
|
| clear_wrong_from_response (array $response) |
| Given a response, rest the parts that are wrong.
|
|
| format_generalfeedback ($qa) |
|
| format_questiontext ($qa) |
|
| format_text ($text, $format, $qa, $component, $filearea, $itemid, $clean=false) |
| Apply format_text() to some content with appropriate settings for this question.
|
|
| get_correct_response () |
| What data would need to be submitted to get this question correct.
|
|
| get_expected_data () |
| What data may be included in the form submission when a student submits this question in its current state?
|
|
| get_max_fraction () |
| Some questions can return a mark greater than the maximum.
|
|
| get_min_fraction () |
| Some questions can return a negative mark if the student gets it wrong.
|
|
| get_num_parts_right (array $response) |
| Return the number of subparts of this response that are right.
|
|
| get_num_variants () |
|
| get_question_definition_for_external_rendering (question_attempt $qa, question_display_options $options) |
| Return the question settings that define this question as structured data.
|
|
| get_question_summary () |
| Generate a brief, plain-text, summary of this question.
|
|
| get_renderer (moodle_page $page) |
|
| get_student_response_values_for_simulation ($realresponse) |
| Does the opposite of prepare_simulated_post_data.
|
|
| get_type_name () |
|
| get_variants_selection_seed () |
|
| html_to_text ($text, $format) |
| Convert some part of the question text to plain text.
|
|
| make_behaviour (question_attempt $qa, $preferredbehaviour) |
| Creat the appropriate behaviour for an attempt at this quetsion, given the desired (archetypal) behaviour.
|
|
| make_html_inline ($html) |
| Take some HTML that should probably already be a single line, like a multiple choice choice, or the corresponding feedback, and make it so that it is suitable to go in a place where the HTML must be inline, like inside a.
|
|
| prepare_simulated_post_data ($simulatedresponse) |
| Takes an array of values representing a student response represented in a way that is understandable by a human and transforms that to the response as the POST values returned from the HTML form that takes the student response during a student attempt.
|
|
| set_latest_version (int $latestversion) |
| Set the latest version.
|
|
| 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.
|
|
| update_attempt_state_data_for_new_version (question_attempt_step $oldstep, question_definition $oldquestion) |
| Update the data representing the initial state of an attempt another version of this question, to allow for the changes.
|
|
| validate_can_regrade_with_other_version (question_definition $otherversion) |
| Verify if an attempt at this question can be re-graded using the other question version.
|
|
|
integer | $category |
| question category id.
|
|
integer | $contextid |
| question context id.
|
|
integer | $createdby |
| userid of the use who created this question.
|
|
array | $customfields = array() |
| of array of core_customfield\data_controller objects indexed by fieldid for the questions custom fields.
|
|
float | $defaultmark = 1 |
| what this quetsion is marked out of, by default.
|
|
string | $generalfeedback |
| question general feedback.
|
|
integer | $generalfeedbackformat |
| question test format.
|
|
array | $hints = array() |
| of question_hints.
|
|
integer | $id |
| id of the question in the datase, or null if this question is not in the database.
|
|
string | $idnumber |
| question idnumber.
|
|
integer | $length = 1 |
| How many question numbers this question consumes.
|
|
integer | $modifiedby |
| userid of the use who modified this question.
|
|
string | $name |
| question name.
|
|
integer | $parent = 0 |
| parent question id.
|
|
number | $penalty = 0 |
| penalty factor of this question.
|
|
question_type | $qtype |
| the question type this question is.
|
|
int | $questionbankentryid |
| Bank entry id for the question.
|
|
string | $questiontext |
| question text.
|
|
integer | $questiontextformat |
| question test format.
|
|
string | $stamp |
| unique identifier of this question.
|
|
boolean | $status = core_question\local\bank\question_version_status::QUESTION_STATUS_READY |
| question status hidden/ready/draft in the question bank.
|
|
integer | $timecreated |
| timestamp when this question was created.
|
|
integer | $timemodified |
| timestamp when this question was modified.
|
|
int | $version |
| Version number of the question in a question bank.
|
|
int | $versionid |
| Version id of the question in a question bank.
|
|
This class represents a 'question' that actually does not allow the student to respond, like the description 'question' type.
- Copyright
- 2009 The Open University
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
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.
- Parameters
-
Reimplemented in qtype_calculated_question, qtype_calculatedmulti_multi_question, qtype_calculatedmulti_single_question, qtype_gapselect_question_base, qtype_match_question, qtype_multianswer_question, qtype_multichoice_base, qtype_numerical_question, and qtype_randomsamatch_question.
Return the question settings that define this question as structured data.
This is used by external systems such as the Moodle mobile app, which want to display the question themselves, rather than using the renderer provided.
This method should only return the data that the student is allowed to see or know, given the current state of the question. For example, do not include the 'General feedback' until the student has completed the question, and even then, only include it if the question_display_options say it should be visible.
But, within those rules, it is recommended that you return all the settings for the question, to give maximum flexibility to the external system providing its own rendering of the question.
- Parameters
-
- Return values
-
mixed | structure representing the question settings. In web services, this will be JSON-encoded. |
Reimplemented in qtype_essay_question, qtype_gapselect_question_base, qtype_match_question, qtype_multianswer_question, qtype_multichoice_base, qtype_numerical_question, qtype_shortanswer_question, and qtype_truefalse_question.
question_information_item::get_question_summary |
( |
| ) |
|
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.
- Return values
-
string|null | a plain text summary of this question. |
Reimplemented from question_definition.
question_definition::get_student_response_values_for_simulation |
( |
| $realresponse | ) |
|
|
inherited |
Does the opposite of prepare_simulated_post_data.
This takes a student response (the POST values returned from the HTML form that takes the student response during a student attempt) it then represents it in a way that is understandable by a human.
Primarily this is used when creating a file of csv from real student responses in order later to be able to simulate the same student interaction with a quiz later.
- Parameters
-
string[] | $realresponse | the response array as was returned from the form during a student attempt (without prefixes). |
- Return values
-
string[] | an array of data representing a student response. |
Reimplemented in qtype_match_question, qtype_multianswer_question, qtype_multichoice_multi_question, and qtype_multichoice_single_question.
question_information_item::make_behaviour |
( |
question_attempt | $qa, |
|
|
| $preferredbehaviour ) |
Creat the appropriate behaviour for an attempt at this quetsion, given the desired (archetypal) behaviour.
This default implementation will suit most normal graded questions.
If your question is of a patricular type, then it may need to do something different. For example, if your question can only be graded manually, then it should probably return a manualgraded behaviour, irrespective of what is asked for.
If your question wants to do somthing especially complicated is some situations, then you may wish to return a particular behaviour related to the one asked for. For example, you migth want to return a qbehaviour_interactive_adapted_for_myqtype.
- Parameters
-
question_attempt | $qa | the attempt we are creating a behaviour for. |
string | $preferredbehaviour | the requested type of behaviour. |
- Return values
-
Reimplemented from question_definition.
question_definition::prepare_simulated_post_data |
( |
| $simulatedresponse | ) |
|
|
inherited |
Takes an array of values representing a student response represented in a way that is understandable by a human and transforms that to the response as the POST values returned from the HTML form that takes the student response during a student attempt.
Primarily this is used when reading csv values from a file of student responses in order to be able to simulate the student interaction with a quiz.
In most cases the array will just be returned as is. Some question types will need to transform the keys of the array, as the meaning of the keys in the html form is deliberately obfuscated so that someone looking at the html does not get an advantage. The values that represent the response might also be changed in order to more meaningful to a human.
See the examples of question types that have overridden this in core and also see the csv files of simulated student responses used in unit tests in :
- mod/quiz/tests/fixtures/stepsXX.csv
- mod/quiz/report/responses/tests/fixtures/steps00.csv
- mod/quiz/report/statistics/tests/fixtures/stepsXX.csv
Also see , a quiz report plug in for uploading and downloading student responses as csv files.
- Parameters
-
array | $simulatedresponse | an array of data representing a student response |
- Return values
-
array | a response array as would be returned from the html form (but without prefixes) |
Reimplemented in qtype_match_question, qtype_multianswer_question, qtype_multichoice_multi_question, and qtype_multichoice_single_question.
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(...).
- Parameters
-
Reimplemented in qtype_calculated_question, qtype_calculatedmulti_multi_question, qtype_calculatedmulti_single_question, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multianswer_question, qtype_multichoice_base, qtype_numerical_question, and qtype_randomsamatch_question.
Update the data representing the initial state of an attempt another version of this question, to allow for the changes.
What is required is probably most easily understood using an example. Think about multiple choice questions. The first step has a variable '_order' which is a comma-separated list of question_answer ids. A different version of the question will have different question_answers with different ids. However, the list of choices should be similar, and so we need to shuffle the new list of ids in the same way that the old one was.
Note: be sure to return all the data that was originally in $oldstep, while updating the fields that require it. Otherwise you might break features like 'Each attempt builds on last' in the quiz.
This method should only be called if {
- See also
- validate_can_regrade_with_other_version()} did not flag up a potential problem. So, this method will throw a {
-
coding_exception} if it is not possible to work out a return value.
- Parameters
-
- See also
- question_attempt} at $oldquestion.
- Parameters
-
question_definition | $oldquestion | the previous version of the question, which $oldstate comes from. |
- Return values
-
array | the submit data which can be passed to { |
- See also
- apply_attempt_state} to start an attempt at this version of this question, corresponding to the attempt at the old question.
- Exceptions
-
Reimplemented in qtype_match_question, qtype_multianswer_question, and qtype_multichoice_base.
question_definition::validate_can_regrade_with_other_version |
( |
question_definition | $otherversion | ) |
|
|
inherited |
Verify if an attempt at this question can be re-graded using the other question version.
To put it another way, will {
- See also
- update_attempt_state_date_from_old_version()} be able to work?
It is expected that this relationship is symmetrical, so if you can regrade from V1 to V3, then you can change back from V3 to V1.
- Parameters
-
- Return values
-
string|null | null if the regrade can proceed, else a reason why not. |
Reimplemented in qtype_gapselect_question_base, qtype_match_question, qtype_multianswer_question, and qtype_multichoice_base.