Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
question_behaviour_type Class Reference

This class represents the type of behaviour, rather than the instance of the behaviour which control a particular question attempt. More...

Inheritance diagram for question_behaviour_type:
qbehaviour_adaptive_type qbehaviour_deferredfeedback_type qbehaviour_immediatefeedback_type qbehaviour_informationitem_type qbehaviour_interactive_type qbehaviour_manualgraded_type qbehaviour_missing_type question_behaviour_type_fallback

Public Member Functions

 adjust_random_guess_score ($fraction)
 Adjust a random guess score for a question using this model.
 
 allows_multiple_submitted_responses ()
 Does this question behaviour accept multiple submissions of responses within one attempt eg.
 
 can_questions_finish_during_the_attempt ()
 With this behaviour, is it possible that a question might finish as the student interacts with it, without a call to the question_attempt::finish() method?
 
 get_unused_display_options ()
 Override this method if there are some display options that do not make sense 'during the attempt'.
 
 is_archetypal ()
 Certain behaviours are definitive of a way that questions can behave when attempted.
 
 summarise_usage (question_usage_by_activity $quba, question_display_options $options)
 Get summary information about a queston usage.
 

Detailed Description

This class represents the type of behaviour, rather than the instance of the behaviour which control a particular question attempt.

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

Member Function Documentation

◆ adjust_random_guess_score()

question_behaviour_type::adjust_random_guess_score ( $fraction)

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.

Parameters
number$fractionthe random guess score from the question type.
Return values
numberthe adjusted fraction.

Reimplemented in qbehaviour_deferredcbm_type, and question_behaviour_type_fallback.

◆ allows_multiple_submitted_responses()

question_behaviour_type::allows_multiple_submitted_responses ( )

Does this question behaviour accept multiple submissions of responses within one attempt eg.

multiple tries for the interactive or adaptive question behaviours.

Return values
bool

Reimplemented in qbehaviour_adaptive_type, and qbehaviour_interactive_type.

◆ can_questions_finish_during_the_attempt()

question_behaviour_type::can_questions_finish_during_the_attempt ( )

With this behaviour, is it possible that a question might finish as the student interacts with it, without a call to the question_attempt::finish() method?

Return values
boolwhether with this behaviour, questions may finish naturally.

Reimplemented in qbehaviour_immediatecbm_type, qbehaviour_immediatefeedback_type, and qbehaviour_interactive_type.

◆ get_unused_display_options()

question_behaviour_type::get_unused_display_options ( )

Override this method if there are some display options that do not make sense 'during the attempt'.

Return values
arrayof question_display_options field names, that are not relevant to this behaviour before a 'finish' action.

Reimplemented in qbehaviour_deferredfeedback_type, qbehaviour_immediatecbm_type, qbehaviour_manualgraded_type, and question_behaviour_type_fallback.

◆ is_archetypal()

question_behaviour_type::is_archetypal ( )

Certain behaviours are definitive of a way that questions can behave when attempted.

For example deferredfeedback model, interactive model, etc. These are the options that should be listed in the user-interface, and for these behaviours this method should return true. Other behaviours are more implementation details, for example the informationitem behaviours, or a special subclass like interactive_adapted_for_my_qtype. These behaviours should return false.

Return values
boolwhether this is an archetypal behaviour.

Reimplemented in qbehaviour_adaptive_type, qbehaviour_deferredfeedback_type, qbehaviour_immediatefeedback_type, qbehaviour_interactive_type, qbehaviour_interactivecountback_type, qbehaviour_manualgraded_type, and question_behaviour_type_fallback.

◆ summarise_usage()

question_behaviour_type::summarise_usage ( question_usage_by_activity $quba,
question_display_options $options )

Get summary information about a queston usage.

Behaviours are not obliged to do anything here, but this is an opportunity to provide additional information that can be displayed in places like at the top of the quiz review page.

In the return value, the array keys should be identifiers of the form qbehaviour_behaviourname_meaningfullkey. For qbehaviour_deferredcbm_highsummary. The values should be arrays with two items, title and content. Each of these should be either a string, or a renderable.

To understand how to implement this method, look at the CBM behaviours, and their unit tests.

Parameters
question_usage_by_activity$qubathe usage to provide summary data for.
Return values
arrayas described above.

Reimplemented in qbehaviour_deferredcbm_type.


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