Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Defines the question behaviour type base class

Copyright: 2012 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 163 lines (6 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

question_behaviour_type:: (6 methods):
  is_archetypal()
  get_unused_display_options()
  can_questions_finish_during_the_attempt()
  adjust_random_guess_score()
  summarise_usage()
  allows_multiple_submitted_responses()

question_behaviour_type_fallback:: (4 methods):
  __construct()
  is_archetypal()
  get_unused_display_options()
  adjust_random_guess_score()


Class: question_behaviour_type  - X-Ref

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

is_archetypal()   X-Ref
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: bool whether this is an archetypal behaviour.

get_unused_display_options()   X-Ref
Override this method if there are some display options that do not make
sense 'during the attempt'.

return: array of {@link question_display_options} field names, that are

can_questions_finish_during_the_attempt()   X-Ref
With this behaviour, is it possible that a question might finish as the student
interacts with it, without a call to the {@link question_attempt::finish()} method?

return: bool whether with this behaviour, questions may finish naturally.

adjust_random_guess_score($fraction)   X-Ref
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.

param: number $fraction the random guess score from the question type.
return: number the adjusted fraction.

summarise_usage(question_usage_by_activity $quba,question_display_options $options)   X-Ref
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.

param: question_usage_by_activity $quba the usage to provide summary data for.
return: array as described above.

allows_multiple_submitted_responses()   X-Ref
Does this question behaviour accept multiple submissions of responses within one attempt eg. multiple tries for the
interactive or adaptive question behaviours.

return: bool

Class: question_behaviour_type_fallback  - X-Ref

This class exists to allow behaviours that worked in Moodle 2.3 to continue
to work. It implements the question_behaviour_type API for the other behaviour
as much as possible in a backwards-compatible way.

__construct($behaviour)   X-Ref

param: string $behaviourtype the type of behaviour we are providing a fallback for.

is_archetypal()   X-Ref
No description

get_unused_display_options()   X-Ref
Override this method if there are some display options that do not make
sense 'during the attempt'.

return: array of {@link question_display_options} field names, that are

adjust_random_guess_score($fraction)   X-Ref
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.

param: number $fraction the random guess score from the question type.
return: number the adjusted fraction.