Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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: 0 times
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.

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

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.
return: string HTML fragment.
param: question_attempt $qa the question attempt to display.

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.

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

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

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

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

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

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.

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

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

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

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.

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

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.

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

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.

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

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.

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

Class: qtype_with_combined_feedback_renderer  - X-Ref

Renderer base classes for question types.

combined_feedback(question_attempt $qa)   X-Ref
No description