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.

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

Renderers for outputting parts of the question engine.

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

Defines 1 class

core_question_renderer:: (18 methods):
  get_page()
  question_preview_link()
  question()
  info()
  number()
  add_part_heading()
  status()
  mark_summary()
  standard_mark_summary()
  standard_marked_out_of_max()
  standard_mark_out_of_max()
  question_flag()
  get_flag_html()
  edit_question_link()
  formulation()
  outcome()
  manual_comment()
  response_history()


Class: core_question_renderer  - X-Ref

This renderer controls the overall output of questions. It works with a
{@link qbehaviour_renderer} and a {@link qtype_renderer} to output the
type-specific bits. The main entry point is the {@link question()} method.

get_page()   X-Ref
No description

question_preview_link($questionid, context $context, $showlabel)   X-Ref
Render an icon, optionally with the word 'Preview' beside it, to preview
a given question.

param: int $questionid the id of the question to be previewed.
param: context $context the context in which the preview is happening.
param: bool $showlabel if true, show the word 'Preview' after the icon.

question(question_attempt $qa, qbehaviour_renderer $behaviouroutput,qtype_renderer $qtoutput, question_display_options $options, $number)   X-Ref
Generate the display of a question in a particular state, and with certain
display options. Normally you do not call this method directly. Intsead
you call {@link question_usage_by_activity::render_question()} which will
call this method with appropriate arguments.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
param: qtype_renderer $qtoutput the renderer to output the question type
param: question_display_options $options controls what should and should not be displayed.
param: string|null $number The question number to display. 'i' is a special
return: string HTML representation of the question.

info(question_attempt $qa, qbehaviour_renderer $behaviouroutput,qtype_renderer $qtoutput, question_display_options $options, $number)   X-Ref
Generate the information bit of the question display that contains the
metadata like the question number, current state, and mark.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
param: qtype_renderer $qtoutput the renderer to output the question type
param: question_display_options $options controls what should and should not be displayed.
param: string|null $number The question number to display. 'i' is a special
return: HTML fragment.

number($number)   X-Ref
Generate the display of the question number.

param: string|null $number The question number to display. 'i' is a special
return: HTML fragment.

add_part_heading($heading, $content)   X-Ref
Add an invisible heading like 'question text', 'feebdack' at the top of
a section's contents, but only if the section has some content.

param: string $heading the heading to add.
param: string $content the content of the section.
return: string HTML fragment with the heading added.

status(question_attempt $qa, qbehaviour_renderer $behaviouroutput,question_display_options $options)   X-Ref
Generate the display of the status line that gives the current state of
the question.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
param: question_display_options $options controls what should and should not be displayed.
return: HTML fragment.

mark_summary(question_attempt $qa, qbehaviour_renderer $behaviouroutput, question_display_options $options)   X-Ref
Generate the display of the marks for this question.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the behaviour renderer, which can generate a custom display.
param: question_display_options $options controls what should and should not be displayed.
return: HTML fragment.

standard_mark_summary(question_attempt $qa, qbehaviour_renderer $behaviouroutput, question_display_options $options)   X-Ref
Generate the display of the marks for this question.

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

standard_marked_out_of_max(question_attempt $qa, question_display_options $options)   X-Ref
Generate the display of the available marks for this question.

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

standard_mark_out_of_max(question_attempt $qa, question_display_options $options)   X-Ref
Generate the display of the marks for this question out of the available marks.

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

question_flag(question_attempt $qa, $flagsoption)   X-Ref
Render the question flag, assuming $flagsoption allows it.

param: question_attempt $qa the question attempt to display.
param: int $flagsoption the option that says whether flags should be displayed.

get_flag_html($flagged, $id = '')   X-Ref
Work out the actual img tag needed for the flag

param: bool $flagged whether the question is currently flagged.
param: string $id an id to be added as an attribute to the img (optional).
return: string the img tag.

edit_question_link(question_attempt $qa,question_display_options $options)   X-Ref
No description

formulation(question_attempt $qa, qbehaviour_renderer $behaviouroutput,qtype_renderer $qtoutput, 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 feedback, for
example ticks and crosses, in this area.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
param: qtype_renderer $qtoutput the renderer to output the question type
param: question_display_options $options controls what should and should not be displayed.
return: HTML fragment.

outcome(question_attempt $qa, qbehaviour_renderer $behaviouroutput,qtype_renderer $qtoutput, 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.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
param: qtype_renderer $qtoutput the renderer to output the question type
param: question_display_options $options controls what should and should not be displayed.
return: HTML fragment.

manual_comment(question_attempt $qa, qbehaviour_renderer $behaviouroutput,qtype_renderer $qtoutput, question_display_options $options)   X-Ref
No description

response_history(question_attempt $qa, qbehaviour_renderer $behaviouroutput,qtype_renderer $qtoutput, question_display_options $options)   X-Ref
Generate the display of the response history part of the question. This
is the table showing all the steps the question has been through.

param: question_attempt $qa the question attempt to display.
param: qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
param: qtype_renderer $qtoutput the renderer to output the question type
param: question_display_options $options controls what should and should not be displayed.
return: HTML fragment.