Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 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.

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.

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

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

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
Generate the display of the edit question link.

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

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.

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

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