Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
question_automatically_gradable_with_countback Interface Reference

Interface that a question_definition must implement to be usable by the interactivecountback behaviour. More...

Inheritance diagram for question_automatically_gradable_with_countback:
question_automatically_gradable question_manually_gradable question_graded_automatically_with_countback qtype_gapselect_question_base qtype_match_question qtype_multianswer_question qtype_ddtoimage_question_base qtype_ddwtos_question qtype_gapselect_question qtype_randomsamatch_question qtype_ddimageortext_question qtype_ddmarker_question

Public Member Functions

 classify_response (array $response)
 Categorise the student's response according to the categories defined by get_possible_responses.
 
 compute_final_grade ($responses, $totaltries)
 Work out a final grade for this attempt, taking into account all the tries the student made.
 
 get_hint ($hintnumber, question_attempt $qa)
 Get one of the question hints.
 
 get_right_answer_summary ()
 Generate a brief, plain-text, summary of the correct answer to this question.
 
 get_validation_error (array $response)
 In situations where is_gradable_response() returns false, this method should generate a description of what the problem is.
 
 grade_response (array $response)
 Grade a response to the question, returning a fraction between get_min_fraction() and get_max_fraction(), and the corresponding question_state right, partial or wrong.
 
 is_complete_response (array $response)
 Used by many of the behaviours, to work out whether the student's response to the question is complete.
 
 is_gradable_response (array $response)
 Use by many of the behaviours to determine whether the student has provided enough of an answer for the question to be graded automatically, or whether it must be considered aborted.
 
 is_same_response (array $prevresponse, array $newresponse)
 Use by many of the behaviours to determine whether the student's response has changed.
 
 summarise_response (array $response)
 Produce a plain text summary of a response.
 
 un_summarise_response (string $summary)
 If possible, construct a response that could have lead to the given response summary.
 

Detailed Description

Interface that a question_definition must implement to be usable by the interactivecountback behaviour.

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

Member Function Documentation

◆ classify_response()

question_manually_gradable::classify_response ( array $response)
inherited

Categorise the student's response according to the categories defined by get_possible_responses.

Parameters
$responsea response, as might be passed to grade_response().
Return values
arraysubpartid => question_classified_response objects. returns an empty array if no analysis is possible.

Implemented in qtype_ddmarker_question, qtype_ddtoimage_question_base, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, qtype_truefalse_question, question_graded_by_strategy, and question_with_responses.

◆ compute_final_grade()

question_automatically_gradable_with_countback::compute_final_grade ( $responses,
$totaltries )

Work out a final grade for this attempt, taking into account all the tries the student made.

Parameters
array$responsesthe response for each try. Each element of this array is a response array, as would be passed to grade_response(). There may be between 1 and $totaltries responses.
int$totaltriesThe maximum number of tries allowed.
Return values
numericthe fraction that should be awarded for this sequence of response.

Implemented in qtype_ddmarker_question, qtype_gapselect_question_base, qtype_match_question, and qtype_multianswer_question.

◆ get_hint()

question_automatically_gradable::get_hint ( $hintnumber,
question_attempt $qa )
inherited

Get one of the question hints.

The question_attempt is passed in case the question type wants to do something complex. For example, the multiple choice with multiple responses question type will turn off most of the hint options if the student has selected too many opitions.

Parameters
int$hintnumberWhich hint to display. Indexed starting from 0
question_attempt$qaThe question_attempt.

Implemented in qtype_missingtype_question, qtype_multichoice_multi_question, and question_graded_automatically.

◆ get_right_answer_summary()

question_automatically_gradable::get_right_answer_summary ( )
inherited

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.

Implemented in qtype_ddmarker_question, qtype_missingtype_question, and question_graded_automatically.

◆ get_validation_error()

question_automatically_gradable::get_validation_error ( array $response)
inherited

◆ grade_response()

question_automatically_gradable::grade_response ( array $response)
inherited

Grade a response to the question, returning a fraction between get_min_fraction() and get_max_fraction(), and the corresponding question_state right, partial or wrong.

Parameters
array$responseresponses, as returned by question_attempt_step::get_qt_data().
Return values
array(float, integer) the fraction, and the state.

Implemented in qtype_ddmarker_question, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multianswer_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, qtype_truefalse_question, and question_graded_by_strategy.

◆ is_complete_response()

question_manually_gradable::is_complete_response ( array $response)
inherited

Used by many of the behaviours, to work out whether the student's response to the question is complete.

That is, whether the question attempt should move to the COMPLETE or INCOMPLETE state.

Parameters
array$responseresponses, as returned by question_attempt_step::get_qt_data().
Return values
boolwhether this response is a complete answer to this question.

Implemented in qtype_ddmarker_question, qtype_essay_question, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multianswer_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, qtype_shortanswer_question, and qtype_truefalse_question.

◆ is_gradable_response()

question_manually_gradable::is_gradable_response ( array $response)
inherited

Use by many of the behaviours to determine whether the student has provided enough of an answer for the question to be graded automatically, or whether it must be considered aborted.

Parameters
array$responseresponses, as returned by question_attempt_step::get_qt_data().
Return values
boolwhether this response can be graded.

Implemented in qtype_ddmarker_question, qtype_essay_question, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multianswer_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, and question_with_responses.

◆ is_same_response()

question_manually_gradable::is_same_response ( array $prevresponse,
array $newresponse )
inherited

Use by many of the behaviours to determine whether the student's response has changed.

This is normally used to determine that a new set of responses can safely be discarded.

Parameters
array$prevresponsethe responses previously recorded for this question, as returned by question_attempt_step::get_qt_data()
array$newresponsethe new responses, in the same format.
Return values
boolwhether the two sets of responses are the same - that is whether the new set of responses can safely be discarded.

Implemented in qtype_ddmarker_question, qtype_essay_question, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multianswer_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, qtype_shortanswer_question, and qtype_truefalse_question.

◆ summarise_response()

question_manually_gradable::summarise_response ( array $response)
inherited

Produce a plain text summary of a response.

Parameters
array$responsea response, as might be passed to grade_response().
Return values
stringa plain text summary of that response, that could be used in reports.

Implemented in qtype_ddmarker_question, qtype_ddtoimage_question_base, qtype_essay_question, qtype_gapselect_question_base, qtype_match_question, qtype_missingtype_question, qtype_multianswer_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, qtype_shortanswer_question, and qtype_truefalse_question.

◆ un_summarise_response()

question_manually_gradable::un_summarise_response ( string $summary)
inherited

If possible, construct a response that could have lead to the given response summary.

This is basically the opposite of summarise_response() but it is intended only to be used for testing.

Parameters
string$summarya string, which might have come from summarise_response
Return values
arraya response that could have lead to that.

Implemented in qtype_essay_question, qtype_missingtype_question, qtype_multichoice_multi_question, qtype_multichoice_single_question, qtype_numerical_question, qtype_shortanswer_question, qtype_truefalse_question, and question_with_responses.


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