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.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

This defines the states a question can be in.

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

Defines 19 classes

question_state:: (20 methods):
  __construct()
  init()
  get_all()
  get_all_for_summary_state()
  __toString()
  get()
  is_active()
  is_finished()
  is_graded()
  is_correct()
  is_partially_correct()
  is_incorrect()
  is_gave_up()
  is_commented()
  get_summary_state()
  graded_state_for_fraction()
  manually_graded_state_for_fraction()
  corresponding_commented_state()
  get_feedback_class()
  default_string()

question_state_notstarted:: (2 methods):
  is_finished()
  get_state_class()

question_state_unprocessed:: (2 methods):
  is_finished()
  get_state_class()

question_state_todo:: (3 methods):
  is_active()
  is_finished()
  get_state_class()

question_state_invalid:: (3 methods):
  is_active()
  is_finished()
  get_state_class()

question_state_complete:: (3 methods):
  is_active()
  is_finished()
  get_state_class()

question_state_needsgrading:: (2 methods):
  get_state_class()
  corresponding_commented_state()

question_state_finished:: (2 methods):
  get_state_class()
  corresponding_commented_state()

question_state_gaveup:: (4 methods):
  is_gave_up()
  get_feedback_class()
  get_state_class()
  corresponding_commented_state()

question_state_graded:: (3 methods):
  is_graded()
  get_state_class()
  corresponding_commented_state()

question_state_gradedwrong:: (2 methods):
  is_incorrect()
  get_feedback_class()

question_state_gradedpartial:: (3 methods):
  is_graded()
  is_partially_correct()
  get_feedback_class()

question_state_gradedright:: (3 methods):
  is_graded()
  is_correct()
  get_feedback_class()

question_state_manfinished:: (1 method):
  is_commented()

question_state_mangaveup:: (1 method):
  is_commented()

question_state_manuallygraded:: (1 method):
  is_commented()

question_state_mangrwrong:: (2 methods):
  is_incorrect()
  get_feedback_class()

question_state_mangrpartial:: (2 methods):
  is_partially_correct()
  get_feedback_class()

question_state_mangrright:: (2 methods):
  is_correct()
  get_feedback_class()


Class: question_state  - X-Ref

An enumeration representing the states a question can be in after a
{@link question_attempt_step}.

There are also some useful methods for testing and manipulating states.

__construct()   X-Ref
No description

init()   X-Ref
No description

get_all()   X-Ref
Get all the states in an array.

return: question_state[] of question_state objects.

get_all_for_summary_state($summarystate)   X-Ref
Get all the states in an array.

param: string $summarystate one of the four summary states
return: array of the corresponding states.

__toString()   X-Ref

return: string convert this state to a string.

get($name)   X-Ref

param: string $name a state name.
return: question_state the state with that name.

is_active()   X-Ref
Is this state one of the ones that mean the question attempt is in progress?
That is, started, but no finished.

return: bool

is_finished()   X-Ref
Is this state one of the ones that mean the question attempt is finished?
That is, no further interaction possible, apart from manual grading.

return: bool

is_graded()   X-Ref
Is this state one of the ones that mean the question attempt has been graded?

return: bool

is_correct()   X-Ref
Is this state one of the ones that mean the question attempt has been graded?

return: bool

is_partially_correct()   X-Ref
Is this state one of the ones that mean the question attempt has been graded?

return: bool

is_incorrect()   X-Ref
Is this state one of the ones that mean the question attempt has been graded?

return: bool

is_gave_up()   X-Ref
Is this state one of the ones that mean the question attempt has been graded?

return: bool

is_commented()   X-Ref
Is this state one of the ones that mean the question attempt has had a manual comment added?

return: bool

get_summary_state()   X-Ref
Each state can be categorised into one of four categories:
inprogress, needsgrading, manuallygraded or autograded.

return: string which category this state falls into.

graded_state_for_fraction($fraction)   X-Ref
Return the appropriate graded state based on a fraction. That is 0 or less
is $graded_incorrect, 1 is $graded_correct, otherwise it is $graded_partcorrect.
Appropriate allowance is made for rounding float values.

param: number $fraction the grade, on the fraction scale.
return: question_state one of the state constants.

manually_graded_state_for_fraction($fraction)   X-Ref
Return the appropriate manually graded state based on a fraction. That is 0 or less
is $manually_graded_incorrect, 1 is $manually_graded_correct, otherwise it is
$manually_graded_partcorrect. Appropriate allowance is made for rounding float values.

param: number $fraction the grade, on the fraction scale.
return: int one of the state constants.

corresponding_commented_state($fraction)   X-Ref
Compute an appropriate state to move to after a manual comment has been
added to this state.

param: number $fraction the manual grade (if any) on the fraction scale.
return: int the new state.

get_feedback_class()   X-Ref
Return an appropriate CSS class name ''/'correct'/'partiallycorrect'/'incorrect',
for a state.

return: string

default_string($showcorrectness)   X-Ref
The result of doing get_string on the result of {@link get_state_class()}.

param: bool $showcorrectness Whether right/partial/wrong states should
return: string a string from the lang pack that can be used in the UI.

Class: question_state_notstarted  - X-Ref

is_finished()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

Class: question_state_unprocessed  - X-Ref

is_finished()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

Class: question_state_todo  - X-Ref

is_active()   X-Ref
No description

is_finished()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

Class: question_state_invalid  - X-Ref

is_active()   X-Ref
No description

is_finished()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

Class: question_state_complete  - X-Ref

is_active()   X-Ref
No description

is_finished()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

Class: question_state_gaveup  - X-Ref

is_gave_up()   X-Ref
No description

get_feedback_class()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

corresponding_commented_state($fraction)   X-Ref
No description

Class: question_state_graded  - X-Ref

is_graded()   X-Ref
No description

get_state_class($showcorrectness)   X-Ref
No description

corresponding_commented_state($fraction)   X-Ref
No description

Class: question_state_gradedwrong  - X-Ref

is_incorrect()   X-Ref
No description

get_feedback_class()   X-Ref
No description

Class: question_state_gradedpartial  - X-Ref

is_graded()   X-Ref
No description

is_partially_correct()   X-Ref
No description

get_feedback_class()   X-Ref
No description

Class: question_state_gradedright  - X-Ref

is_graded()   X-Ref
No description

is_correct()   X-Ref
No description

get_feedback_class()   X-Ref
No description

Class: question_state_manfinished  - X-Ref

is_commented()   X-Ref
No description

Class: question_state_mangaveup  - X-Ref

is_commented()   X-Ref
No description

Class: question_state_manuallygraded  - X-Ref

is_commented()   X-Ref
No description

Class: question_state_mangrwrong  - X-Ref

is_incorrect()   X-Ref
No description

get_feedback_class()   X-Ref
No description

Class: question_state_mangrpartial  - X-Ref

is_partially_correct()   X-Ref
No description

get_feedback_class()   X-Ref
No description

Class: question_state_mangrright  - X-Ref

is_correct()   X-Ref
No description

get_feedback_class()   X-Ref
No description