Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
qbehaviour_adaptive Class Reference

Question behaviour for adaptive mode. More...

Inheritance diagram for qbehaviour_adaptive:
question_behaviour_with_multiple_tries question_behaviour_with_save question_behaviour qbehaviour_adaptivenopenalty

Public Member Functions

 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.
 
 apply_attempt_state (question_attempt_step $step)
 When an attempt is started based on a previous attempt (see question_attempt::start_based_on) this method is called to setup the new attempt.
 
 can_finish_during_attempt ()
 Whether the current attempt at this question could be completed just by the student interacting with the question, before $qa->finish() is called.
 
 check_file_access ($options, $component, $filearea, $args, $forcedownload)
 Checks whether the users is allow to be served a particular file.
 
 classify_response ($whichtries=question_attempt::LAST_TRY)
 Classify responses for this question into a number of sub parts and response classes as defined by question_type::get_possible_responses for this question type.
 
 format_comment ($comment=null, $commentformat=null, $context=null)
 
 get_adaptive_marks ()
 
 get_applicable_hint ()
 Get the most applicable hint for the question in its current state.
 
 get_correct_response ()
 Return an array of any im variables, and the value required to get full marks.
 
 get_expected_data ()
 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.
 
 get_expected_qt_data ()
 Return an array of question type variables for the question in its current state.
 
 get_graded_step ()
 Got the most recently graded step.
 
 get_max_fraction ()
 Return the maximum possible fraction that can be scored for this question.
 
 get_min_fraction ()
 What is the minimum fraction that can be scored for this question.
 
 get_name ()
 
 get_question_summary ()
 Generate a brief, plain-text, summary of this question.
 
 get_renderer (moodle_page $page)
 
 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.
 
 get_right_answer_summary ()
 Generate a brief, plain-text, summary of the correct answer to this question.
 
 get_state_string ($showcorrectness)
 Generate a brief textual description of the current state of the question, normally displayed under the question number.
 
 init_first_step (question_attempt_step $step, $variant)
 Initialise the first step in a question attempt when a new question_attempt is being started.
 
 is_compatible_question (question_definition $question)
 Some behaviours can only work with certing types of question.
 
 is_state_improvable (question_state $state)
 Determine whether a question state represents an "improvable" result, that is, whether the user can still improve their score.
 
 process_action (question_attempt_pending_step $pendingstep)
 The main entry point for processing an action.
 
 process_autosave (question_attempt_pending_step $pendingstep)
 Auto-saved data.
 
 process_comment (question_attempt_pending_step $pendingstep)
 Implementation of processing a manual comment/grade action that should be suitable for most subclasses.
 
 process_finish (question_attempt_pending_step $pendingstep)
 
 process_save (question_attempt_pending_step $pendingstep)
 Implementation of processing a save action that should be suitable for most subclasses.
 
 process_submit (question_attempt_pending_step $pendingstep)
 
 render (question_display_options $options, $number, core_question_renderer $qoutput, qtype_renderer $qtoutput)
 Cause the question to be renderered.
 
 required_question_definition_type ()
 
 step_has_a_submitted_response ($step)
 Does this step include a response submitted by a student?
 
 summarise_action (question_attempt_step $step)
 
 summarise_finish ($step)
 
 summarise_save (question_attempt_step $step)
 
 summarise_start ($step)
 
 summarise_submit (question_attempt_step $step)
 

Public Attributes

const IS_ARCHETYPAL = true
 

Protected Member Functions

 adaptive_mark_details_from_step (question_attempt_step $gradedstep, question_state $state, $maxmark, $penalty)
 Actually populate the qbehaviour_adaptive_mark_details object.
 
 adjusted_fraction ($fraction, $prevtries)
 
 get_our_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.
 
 is_complete_response (question_attempt_step $pendingstep)
 Work out whether the response in $pendingstep represent a complete answer to the question.
 
 is_same_comment ($pendingstep)
 Checks whether two manual grading actions are the same.
 
 is_same_response (question_attempt_step $pendingstep)
 Work out whether the response in $pendingstep are significantly different from the last set of responses we have stored.
 
 summarise_manual_comment ($step)
 

Protected Attributes

question_attempt $qa
 the question attempt we are managing.
 
question_definition $question
 shortcut to $qa->get_question().
 

Detailed Description

Question behaviour for adaptive mode.

This is the old version of interactive mode.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ adaptive_mark_details_from_step()

qbehaviour_adaptive::adaptive_mark_details_from_step ( question_attempt_step $gradedstep,
question_state $state,
$maxmark,
$penalty )
protected

Actually populate the qbehaviour_adaptive_mark_details object.

Parameters
question_attempt_step$gradedstepthe step that holds the relevant mark details.
question_state$statethe state corresponding to $gradedstep.
unknown_type$maxmarkthe maximum mark for this question_attempt.
unknown_type$penaltythe penalty for this question, as a fraction.

◆ adjust_display_options()

qbehaviour_adaptive::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.

Parameters
question_display_options$optionsthe options to adjust. Just change the properties of this object - objects are passed by referece.

Reimplemented from question_behaviour.

◆ apply_attempt_state()

question_behaviour_with_save::apply_attempt_state ( question_attempt_step $step)
inherited

When an attempt is started based on a previous attempt (see question_attempt::start_based_on) this method is called to setup the new attempt.

This method must call $this->question->apply_attempt_state($step), and may perform additional processing if the behaviour requries it.

Parameters
question_attempt_stepThe first step of the question_attempt being loaded.

Reimplemented from question_behaviour.

◆ can_finish_during_attempt()

question_behaviour::can_finish_during_attempt ( )
inherited

Whether the current attempt at this question could be completed just by the student interacting with the question, before $qa->finish() is called.

Return values
booleanwhether the attempt can finish naturally.

Reimplemented in qbehaviour_immediatefeedback, and qbehaviour_interactive.

◆ check_file_access()

question_behaviour::check_file_access ( $options,
$component,
$filearea,
$args,
$forcedownload )
inherited

Checks whether the users is allow to be served a particular file.

Parameters
question_display_options$optionsthe options that control display of the question.
string$componentthe name of the component we are serving files for.
string$fileareathe name of the file area.
array$argsthe remaining bits of the file path.
bool$forcedownloadwhether the user must be forced to download the file.
Return values
booltrue if the user can access this file.

◆ classify_response()

question_behaviour::classify_response ( $whichtries = question_attempt::LAST_TRY)
inherited

Classify responses for this question into a number of sub parts and response classes as defined by question_type::get_possible_responses for this question type.

Parameters
string$whichtrieswhich tries to analyse for response analysis. Will be one of question_attempt\FIRST_TRY, LAST_TRY or ALL_TRIES. Defaults to question_attempt\LAST_TRY.
Return values
(question_classified_response|array)[]If $whichtries is question_attempt\FIRST_TRY or LAST_TRY index is subpartid and values are question_classified_response instances. If $whichtries is question_attempt\ALL_TRIES then first key is submitted response no and the second key is subpartid.

◆ format_comment()

question_behaviour::format_comment ( $comment = null,
$commentformat = null,
$context = null )
inherited
Parameters
$commentthe comment text to format. If omitted, $this->qa->get_manual_comment() is used.
$commentformatthe format of the comment, one of the FORMAT_... constants.
$contextthe quiz context.
Return values
stringthe comment, ready to be output.

◆ get_adaptive_marks()

qbehaviour_adaptive::get_adaptive_marks ( )
Return values
qbehaviour_adaptive_mark_detailsthe information about the current state-of-play, scoring-wise, for this adaptive attempt.

◆ get_applicable_hint()

question_behaviour::get_applicable_hint ( )
inherited

Get the most applicable hint for the question in its current state.

Return values
question_hintthe most applicable hint, or null, if none.

Reimplemented in qbehaviour_interactive.

◆ get_correct_response()

question_behaviour::get_correct_response ( )
inherited

Return an array of any im variables, and the value required to get full marks.

Return values
arrayvariable name => value.

Reimplemented in qbehaviour_deferredcbm, qbehaviour_immediatecbm, and qbehaviour_informationitem.

◆ get_expected_data()

qbehaviour_adaptive::get_expected_data ( )

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.

Return values
arrayvariable name => PARAM_... constant.

Reimplemented from question_behaviour.

◆ get_expected_qt_data()

question_behaviour::get_expected_qt_data ( )
inherited

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.

Return values
array|stringvariable name => PARAM_... constant, or, as a special case that should only be used in unavoidable, the constant question_attempt\USE_RAW_DATA meaning take all the raw submitted data belonging to this question.

Reimplemented in qbehaviour_interactive.

◆ get_graded_step()

qbehaviour_adaptive::get_graded_step ( )

Got the most recently graded step.

This is mainly intended for use by the renderer.

Return values
question_attempt_stepthe most recently graded step.

◆ get_max_fraction()

question_behaviour::get_max_fraction ( )
inherited

Return the maximum possible fraction that can be scored for this question.

Normally this will be based on $this->question->get_max_fraction(), but may be modified in some way by the behaviour.

Return values
numberthe maximum fraction when this question is attempted under this behaviour.

Reimplemented in qbehaviour_deferredcbm, qbehaviour_immediatecbm, and qbehaviour_missing.

◆ get_min_fraction()

question_behaviour::get_min_fraction ( )
inherited

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 behaviour.

Return values
numberthe minimum fraction when this question is attempted under this behaviour.

Reimplemented in qbehaviour_deferredcbm, qbehaviour_deferredfeedback, qbehaviour_immediatecbm, qbehaviour_immediatefeedback, and qbehaviour_missing.

◆ get_name()

question_behaviour::get_name ( )
inherited
Return values
stringthe name of this behaviour. For example the name of qbehaviour_mymodle is 'mymodel'.

◆ get_our_resume_data()

question_behaviour::get_our_resume_data ( )
protectedinherited

Used by start_based_on() to get the data needed to start a new attempt from the point this attempt has go to.

Return values
unknown_type

Reimplemented in qbehaviour_deferredcbm, and qbehaviour_immediatecbm.

◆ get_question_summary()

question_behaviour::get_question_summary ( )
inherited

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()}.

Return values
string|nulla plain text summary of this question.

◆ get_renderer()

question_behaviour::get_renderer ( moodle_page $page)
inherited
Parameters
moodle_page$pagethe page to render for.
Return values
qbehaviour_rendererget the appropriate renderer to use for this model.

◆ get_resume_data()

question_behaviour::get_resume_data ( )
inherited

Used by start_based_on() to get the data needed to start a new attempt from the point this attempt has go to.

Return values
arrayname => value pairs.

◆ get_right_answer_summary()

qbehaviour_adaptive::get_right_answer_summary ( )

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.

Return values
string|nulla plain text summary of the right answer to this question.

Reimplemented from question_behaviour.

◆ get_state_string()

qbehaviour_adaptive::get_state_string ( $showcorrectness)

Generate a brief textual description of the current state of the question, normally displayed under the question number.

Parameters
bool$showcorrectnessWhether right/partial/wrong states should be distinguised.
Return values
stringa brief summary of the current state of the qestion attempt.

Reimplemented from question_behaviour.

◆ init_first_step()

question_behaviour::init_first_step ( question_attempt_step $step,
$variant )
inherited

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, $variant), and may perform additional processing if the behaviour requries it.

Parameters
question_attempt_step$stepthe first step of the question_attempt being started.
int$variantwhich variant of the question to use.

Reimplemented in qbehaviour_interactive, and qbehaviour_missing.

◆ is_compatible_question()

qbehaviour_adaptive::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.

Parameters
question_definition$questionthe question.

Reimplemented from question_behaviour.

◆ is_complete_response()

question_behaviour_with_save::is_complete_response ( question_attempt_step $pendingstep)
protectedinherited

Work out whether the response in $pendingstep represent a complete answer to the question.

Normally this will call question_manually_gradable::is_complete_response, but some behaviours, for example the CBM ones, have their own parts to the response.

Parameters
question_attempt_step$pendingstepcontains the new responses.
Return values
boolwhether the new response is complete.

Reimplemented in qbehaviour_deferredcbm, and qbehaviour_immediatecbm.

◆ is_same_comment()

question_behaviour::is_same_comment ( $pendingstep)
protectedinherited

Checks whether two manual grading actions are the same.

That is, whether the comment, and the mark (if given) is the same.

Parameters
question_attempt_step$pendingstepcontains the new responses.
Return values
boolwhether the new response is the same as we already have.

◆ is_same_response()

question_behaviour_with_save::is_same_response ( question_attempt_step $pendingstep)
protectedinherited

Work out whether the response in $pendingstep are significantly different from the last set of responses we have stored.

Parameters
question_attempt_step$pendingstepcontains the new responses.
Return values
boolwhether the new response is the same as we already have.

Reimplemented in qbehaviour_deferredcbm, and qbehaviour_immediatecbm.

◆ is_state_improvable()

qbehaviour_adaptive::is_state_improvable ( question_state $state)

Determine whether a question state represents an "improvable" result, that is, whether the user can still improve their score.

Parameters
question_state$statethe question state.
Return values
boolwhether the state is improvable

◆ process_action()

qbehaviour_adaptive::process_action ( question_attempt_pending_step $pendingstep)

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.

Parameters
question_attempt_pending_step$pendingstepa 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().
Return values
booleither question_attempt::KEEP or question_attempt::DISCARD

Reimplemented from question_behaviour.

◆ process_autosave()

question_behaviour_with_save::process_autosave ( question_attempt_pending_step $pendingstep)
inherited

Auto-saved data.

By default this does nothing. interesting processing is done in question_behaviour_with_save.

Parameters
question_attempt_pending_step$pendingstepa 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().
Return values
booleither question_attempt::KEEP or question_attempt::DISCARD

Reimplemented from question_behaviour.

◆ process_comment()

question_behaviour::process_comment ( question_attempt_pending_step $pendingstep)
inherited

Implementation of processing a manual comment/grade action that should be suitable for most subclasses.

Parameters
question_attempt_pending_step$pendingstepa partially initialised step containing all the information about the action that is being peformed.
Return values
booleither question_attempt::KEEP

Reimplemented in qbehaviour_informationitem.

◆ process_save()

qbehaviour_adaptive::process_save ( question_attempt_pending_step $pendingstep)

Implementation of processing a save action that should be suitable for most subclasses.

Parameters
question_attempt_pending_step$pendingstepa partially initialised step containing all the information about the action that is being peformed.
Return values
booleither question_attempt::KEEP or question_attempt::DISCARD

Reimplemented from question_behaviour_with_save.

◆ render()

question_behaviour::render ( question_display_options $options,
$number,
core_question_renderer $qoutput,
qtype_renderer $qtoutput )
inherited

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.

Parameters
question_display_options$optionscontrols what should and should not be displayed.
string | null$numberthe question number to display.
core_question_renderer$qoutputthe question renderer that will coordinate everything.
qtype_renderer$qtoutputthe question type renderer that will be helping.
Return values
stringHTML fragment.

◆ step_has_a_submitted_response()

question_behaviour_with_multiple_tries::step_has_a_submitted_response ( $step)
inherited

Does this step include a response submitted by a student?

This method should return true for any attempt explicitly submitted by a student. The question engine itself will also automatically recognise any last saved response before the attempt is finished, you don't need to return true here for these steps with responses which are not explicitly submitted by the student.

Parameters
question_attempt_step$step
Return values
boolis this a step within a question attempt that includes a submitted response by a student.

Reimplemented from question_behaviour.

◆ summarise_action()

qbehaviour_adaptive::summarise_action ( question_attempt_step $step)

Reimplemented from question_behaviour.

◆ summarise_finish()

question_behaviour_with_save::summarise_finish ( $step)
inherited

Reimplemented from question_behaviour.

◆ summarise_manual_comment()

question_behaviour::summarise_manual_comment ( $step)
protectedinherited
Return values
stringa summary of a manual comment action.
Parameters
question_attempt_step$step

The documentation for this class was generated from the following file: