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

The base class for question behaviours.
A question behaviour is used by the question engine, specifically by a question_attempt to manage the flow of actions a student can take as they work through a question, and later, as a teacher manually grades it. In turn, the behaviour will delegate certain processing to the relevant question_definition.
Definition at line 42 of file behaviourbase.php.
| __construct | ( | question_attempt $ | qa, |
| $ | preferredbehaviour | ||
| ) |
Normally you should not call this constuctor directly. The appropriate behaviour object is created automatically as part of question_attempt::start().
| question_attempt | $qa | the question attempt we will be managing. |
| string | $preferredbehaviour | the type of behaviour that was actually requested. This information is not needed in most cases, the type of subclass is enough, but occasionally it is needed. |
Definition at line 70 of file behaviourbase.php.

| adjust_display_options | ( | question_display_options $ | options | ) |
Make any changes to the display options before a question is rendered, so that it can be displayed in a way that is appropriate for the statue it is currently in. For example, by default, if the question is finished, we ensure that it is only ever displayed read-only.
| question_display_options | $options | the options to adjust. Just change the properties of this object - objects are passed by referece. |
Reimplemented in qbehaviour_adaptive, qbehaviour_interactive, qbehaviour_informationitem, and qbehaviour_manualgraded.
Definition at line 175 of file behaviourbase.php.


| static adjust_random_guess_score | ( | $ | fraction | ) | [static] |
Adjust a random guess score for a question using this model. You have to do this without knowing details of the specific question, or which usage it is in.
| number | $fraction | the random guess score from the question type. |
Reimplemented in qbehaviour_immediatecbm, and qbehaviour_deferredcbm.
Definition at line 217 of file behaviourbase.php.
| check_file_access | ( | $ | options, |
| $ | component, | ||
| $ | filearea, | ||
| $ | args, | ||
| $ | forcedownload | ||
| ) |
Checks whether the users is allow to be served a particular file.
| 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. |
Definition at line 153 of file behaviourbase.php.

Definition at line 328 of file behaviourbase.php.
| format_comment | ( | $ | comment = null, |
| $ | commentformat = null |
||
| ) |
| $comment | the comment text to format. If omitted, $this->qa->get_manual_comment() is used. |
| $commentformat | the format of the comment, one of the FORMAT_... constants. |
Definition at line 477 of file behaviourbase.php.


Get the most applicable hint for the question in its current state.
Reimplemented in qbehaviour_interactive.
Definition at line 194 of file behaviourbase.php.
Return an array of any im variables, and the value required to get full marks.
Reimplemented in qbehaviour_deferredcbm, qbehaviour_immediatecbm, and qbehaviour_informationitem.
Definition at line 267 of file behaviourbase.php.
Return an array of the behaviour variables that could be submitted as part of a question of this type, with their types, so they can be properly cleaned.
Reimplemented in qbehaviour_interactive, qbehaviour_deferredcbm, qbehaviour_immediatefeedback, qbehaviour_immediatecbm, qbehaviour_informationitem, and qbehaviour_adaptive.
Definition at line 227 of file behaviourbase.php.
Return an array of question type variables for the question in its current state. Normally, if adjust_display_options() would set question_display_options::$readonly to true, then this method should return an empty array, otherwise it should return $this->question->get_expected_data(). Thus, there should be little need to override this method.
Reimplemented in qbehaviour_interactive.
Definition at line 251 of file behaviourbase.php.

| get_min_fraction | ( | ) |
What is the minimum fraction that can be scored for this question. Normally this will be based on $this->question->get_min_fraction(), but may be modified in some way by the model.
Reimplemented in qbehaviour_missing, qbehaviour_deferredcbm, qbehaviour_deferredfeedback, qbehaviour_immediatefeedback, and qbehaviour_immediatecbm.
Definition at line 206 of file behaviourbase.php.
| get_name | ( | ) |
Definition at line 111 of file behaviourbase.php.

| get_our_resume_data | ( | ) | [protected] |
Used by start_based_on() to get the data needed to start a new attempt from the point this attempt has go to.
Reimplemented in qbehaviour_deferredcbm, and qbehaviour_immediatecbm.
Definition at line 316 of file behaviourbase.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.
Normally, this method delegates to {question_definition::get_question_summary()}.
Definition at line 283 of file behaviourbase.php.
| get_renderer | ( | moodle_page $ | page | ) |
| moodle_page | $page | the page to render for. |
Definition at line 163 of file behaviourbase.php.


| get_resume_data | ( | ) |
Used by start_based_on() to get the data needed to start a new attempt from the point this attempt has go to.
Definition at line 304 of file behaviourbase.php.

Generate a brief, plain-text, summary of the correct answer to this question. This is used by various reports, and can also be useful when testing. This method will return null if such a summary is not possible, or inappropriate.
Reimplemented in qbehaviour_immediatefeedback, qbehaviour_adaptive, qbehaviour_deferredcbm, qbehaviour_immediatecbm, qbehaviour_interactive, and qbehaviour_deferredfeedback.
Definition at line 295 of file behaviourbase.php.
| get_state_string | ( | $ | showcorrectness | ) |
Generate a brief textual description of the current state of the question, normally displayed under the question number.
| bool | $showcorrectness | Whether right/partial/wrong states should be distinguised. |
Reimplemented in qbehaviour_interactive, qbehaviour_informationitem, qbehaviour_immediatefeedback, and qbehaviour_adaptive.
Definition at line 340 of file behaviourbase.php.
| static get_unused_display_options | ( | ) | [static] |
'Override' this method if there are some display options that do not make sense 'during the attempt'.
Reimplemented in qbehaviour_deferredcbm, qbehaviour_deferredfeedback, and qbehaviour_manualgraded.
Definition at line 121 of file behaviourbase.php.

| init_first_step | ( | question_attempt_step $ | step, |
| $ | variant | ||
| ) |
Initialise the first step in a question attempt when a new question_attempt is being started.
This method must call $this->question->start_attempt($step), and may perform additional processing if the model requries it.
| question_attempt_step | $step | the first step of the question_attempt being started. |
| int | $variant | which variant of the question to use. |
Reimplemented in qbehaviour_interactive, and qbehaviour_missing.
Definition at line 357 of file behaviourbase.php.
| is_compatible_question | ( | question_definition $ | question | ) |
Some behaviours can only work with certing types of question. This method allows the behaviour to verify that a question is compatible.
This implementation is only provided for backwards-compatibility. You should override this method if you are implementing a behaviour.
| question_definition | $question | the question. |
Reimplemented in qbehaviour_interactivecountback, qbehaviour_interactive, qbehaviour_missing, qbehaviour_immediatefeedback, qbehaviour_deferredfeedback, qbehaviour_informationitem, and qbehaviour_adaptive.
Definition at line 88 of file behaviourbase.php.


| is_same_comment | ( | $ | pendingstep | ) | [protected] |
Checks whether two manual grading actions are the same. That is, whether the comment, and the mark (if given) is the same.
| question_attempt_step | $pendingstep | contains the new responses. |
Definition at line 368 of file behaviourbase.php.


| process_action | ( | question_attempt_pending_step $ | pendingstep | ) | [abstract] |
The main entry point for processing an action.
All the various operations that can be performed on a question_attempt get channeled through this function, except for question_attempt::start() which goes to init_first_step(). question_attempt::finish() becomes an action with im vars finish => 1, and manual comment/grade becomes an action with im vars comment => comment text, and mark => ..., max_mark => ... if the question is graded.
This method should first determine whether the action is significant. For example, if no actual action is being performed, but instead the current responses are being saved, and there has been no change since the last set of responses that were saved, this the action is not significatn. In this case, this method should return question_attempt::DISCARD. Otherwise it should return question_attempt::KEEP.
If the action is significant, this method should also perform any necessary updates to $pendingstep. For example, it should call question_attempt_step::set_state() to set the state that results from this action, and if this is a grading action, it should call question_attempt_step::set_fraction().
This method can also call question_attempt_step::set_behaviour_var() to store additional infomation. There are two main uses for this. This can be used to store the result of any randomisation done. It is important to store the result of randomisation once, and then in future use the same outcome if the actions are ever replayed. This is how regrading works. The other use is to cache the result of expensive computations performed on the raw response data, so that subsequent display and review of the question does not have to repeat the same expensive computations.
Often this method is implemented as a dispatching method that examines the pending step to determine the kind of action being performed, and then calls a more specific method like process_save() or process_comment(). Look at some of the standard behaviours for examples.
| question_attempt_pending_step | $pendingstep | a partially initialised step containing all the information about the action that is being peformed. This information can be accessed using question_attempt_step::get_behaviour_var(). |
Reimplemented in qbehaviour_interactive, qbehaviour_adaptive, qbehaviour_informationitem, qbehaviour_immediatefeedback, qbehaviour_missing, qbehaviour_deferredfeedback, and qbehaviour_manualgraded.
| process_comment | ( | question_attempt_pending_step $ | pendingstep | ) |
Implementation of processing a manual comment/grade action that should be suitable for most subclasses.
| question_attempt_pending_step | $pendingstep | a partially initialised step containing all the information about the action that is being peformed. |
Reimplemented in qbehaviour_informationitem.
Definition at line 445 of file behaviourbase.php.


| render | ( | question_display_options $ | options, |
| $ | number, | ||
| core_question_renderer $ | qoutput, | ||
| qtype_renderer $ | qtoutput | ||
| ) |
Cause the question to be renderered. This gets the appropriate behaviour renderer using get_renderer(), and adjusts the display options using adjust_display_options() and then calls core_question_renderer::question() to do the work.
| question_display_options | $options | controls what should and should not be displayed. |
| unknown_type | $number | the question number to display. |
| core_question_renderer | $qoutput | the question renderer that will coordinate everything. |
| qtype_renderer | $qtoutput | the question type renderer that will be helping. |
Definition at line 136 of file behaviourbase.php.

| required_question_definition_type | ( | ) | [protected] |
Most behaviours can only work with question_definitions of a particular subtype, or that implement a particular interface. This method lets the behaviour document that. The type of question passed to the constructor is then checked against this type.
Reimplemented in question_behaviour_with_save.
Definition at line 103 of file behaviourbase.php.

| summarise_action | ( | question_attempt_step $ | step | ) | [abstract] |
| summarise_finish | ( | $ | step | ) |
Reimplemented in question_behaviour_with_save.
Definition at line 515 of file behaviourbase.php.

| summarise_manual_comment | ( | $ | step | ) | [protected] |
| unknown_type | $step |
Definition at line 493 of file behaviourbase.php.


| summarise_start | ( | $ | step | ) |
$qa [protected] |
Definition at line 57 of file behaviourbase.php.
$question [protected] |
Definition at line 59 of file behaviourbase.php.
| const IS_ARCHETYPAL = false |
Reimplemented in qbehaviour_interactivecountback, qbehaviour_deferredcbm, qbehaviour_immediatecbm, qbehaviour_immediatefeedback, qbehaviour_interactive, qbehaviour_adaptivenopenalty, qbehaviour_deferredfeedback, qbehaviour_manualgraded, and qbehaviour_adaptive.
Definition at line 54 of file behaviourbase.php.