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.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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: 525 lines (23 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


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.

return: string HTML representation of the question.
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

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.

return: HTML fragment.
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

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

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

question_number_text(?string $number)   X-Ref
Get the question number as a string.

return: string e.g. 'Question 123' or 'Information' or ''.
param: string|null $number e.g. '123' or 'i'. null or '' means do not display anything number-related.

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.

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

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.

return: HTML fragment.
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.

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

return: HTML fragment.
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.

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

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

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

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

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.

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

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

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

edit_question_link(question_attempt $qa, question_display_options $options)   X-Ref
Generate the display of the edit question link.

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

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.

return: HTML fragment.
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.

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.

return: HTML fragment.
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.

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.

return: HTML fragment.
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.

action_author(question_attempt_step $step, question_display_options $options)   X-Ref
Action author's profile link.

return: string The link to user's profile.
param: question_attempt_step $step The step.
param: question_display_options $options The display options.