Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Defines the renderer base classes for question types.

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

Defines 2 classes

qtype_renderer:: (13 methods):
  formulation_and_controls()
  formulation_heading()
  clear_wrong()
  feedback()
  specific_feedback()
  num_parts_correct()
  hint()
  general_feedback()
  correct_response()
  manual_comment()
  head_code()
  feedback_class()
  feedback_image()

qtype_with_combined_feedback_renderer:: (1 method):
  combined_feedback()


Class: qtype_renderer  - X-Ref

Renderer base classes for question types.

formulation_and_controls(question_attempt $qa,question_display_options $options)   X-Ref
Generate the display of the formulation part of the question. This is the
area that contains the quetsion text, and the controls for students to
input their answers. Some question types also embed bits of feedback, for
example ticks and crosses, in this area.

param: question_attempt $qa the question attempt to display.
param: question_display_options $options controls what should and should not be displayed.
return: string HTML fragment.

formulation_heading()   X-Ref
In the question output there are some class="accesshide" headers to help
screen-readers. This method returns the text to use for the heading above
the formulation_and_controls section.

return: string to use as the heading.

clear_wrong(question_attempt $qa)   X-Ref
Output hidden form fields to clear any wrong parts of the student's response.

This method will only be called if the question is in read-only mode.
param: question_attempt $qa the question attempt to display.
return: string HTML fragment.

feedback(question_attempt $qa, question_display_options $options)   X-Ref
Generate the display of the outcome part of the question. This is the
area that contains the various forms of feedback. This function generates
the content of this area belonging to the question type.

Subclasses will normally want to override the more specific methods
{specific_feedback()}, {general_feedback()} and {correct_response()}
that this method calls.

param: question_attempt $qa the question attempt to display.
param: question_display_options $options controls what should and should not be displayed.
return: string HTML fragment.

specific_feedback(question_attempt $qa)   X-Ref
Generate the specific feedback. This is feedback that varies according to
the response the student gave.

param: question_attempt $qa the question attempt to display.
return: string HTML fragment.

num_parts_correct(question_attempt $qa)   X-Ref
Gereate a brief statement of how many sub-parts of this question the
student got right.

param: question_attempt $qa the question attempt to display.
return: string HTML fragment.

hint(question_attempt $qa, question_hint $hint)   X-Ref
Gereate the specific feedback. This is feedback that varies according to
the response the student gave.

param: question_attempt $qa the question attempt to display.
return: string HTML fragment.

general_feedback(question_attempt $qa)   X-Ref
Gereate the general feedback. This is feedback is shown ot all students.

param: question_attempt $qa the question attempt to display.
return: string HTML fragment.

correct_response(question_attempt $qa)   X-Ref
Gereate an automatic description of the correct response to this question.
Not all question types can do this. If it is not possible, this method
should just return an empty string.

param: question_attempt $qa the question attempt to display.
return: string HTML fragment.

manual_comment(question_attempt $qa, question_display_options $options)   X-Ref
Display any extra question-type specific content that should be visible
when grading, if appropriate.

param: question_attempt $qa a question attempt.
param: question_display_options $options controls what should and should not be displayed.
return: string HTML fragment.

head_code(question_attempt $qa)   X-Ref
Return any HTML that needs to be included in the page's <head> when this
question is used.

param: $qa the question attempt that will be displayed on the page.
return: string HTML fragment.

feedback_class($fraction)   X-Ref
No description

feedback_image($fraction, $selected = true)   X-Ref
Return an appropriate icon (green tick, red cross, etc.) for a grade.

param: float $fraction grade on a scale 0..1.
param: bool $selected whether to show a big or small icon. (Deprecated)
return: string html fragment.

Class: qtype_with_combined_feedback_renderer  - X-Ref

Renderer base classes for question types.

combined_feedback(question_attempt $qa)   X-Ref
No description