Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

File Size: 1477 lines (59 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: renderer  - X-Ref

The main renderer for the quiz module.

review_page(quiz_attempt $attemptobj, $slots, $page, $showall,$lastpage, display_options $displayoptions, $summarydata)   X-Ref
Builds the review page

param: quiz_attempt $attemptobj an instance of quiz_attempt.
param: array $slots of slots to be displayed.
param: int $page the current page number
param: bool $showall whether to show entire attempt on one page.
param: bool $lastpage if true the current page is the last page.
param: display_options $displayoptions instance of display_options.
param: array $summarydata contains all table data
return: string HTML to display.

review_question_page(quiz_attempt $attemptobj, $slot, $seq,display_options $displayoptions, $summarydata)   X-Ref
Renders the review question pop-up.

param: quiz_attempt $attemptobj an instance of quiz_attempt.
param: int $slot which question to display.
param: int $seq which step of the question attempt to show. null = latest.
param: display_options $displayoptions instance of display_options.
param: array $summarydata contains all table data
return: string HTML to display.

review_question_not_allowed(quiz_attempt $attemptobj, $message)   X-Ref
Renders the review question pop-up.

param: quiz_attempt $attemptobj an instance of quiz_attempt.
param: string $message Why the review is not allowed.
return: string html to output.

filter_review_summary_table($summarydata, $page)   X-Ref
Filters the summarydata array.

param: array $summarydata contains row data for table
param: int $page the current page number
return: array updated version of the $summarydata array.

review_summary_table($summarydata, $page)   X-Ref
Outputs the table containing data from summary data array

param: array $summarydata contains row data for table
param: int $page contains the current page number
return: string HTML to display.

questions(quiz_attempt $attemptobj, $reviewing, $slots, $page, $showall,display_options $displayoptions)   X-Ref
Renders each question

param: quiz_attempt $attemptobj instance of quiz_attempt
param: bool $reviewing
param: array $slots array of integers relating to questions
param: int $page current page number
param: bool $showall if true shows attempt on single page
param: display_options $displayoptions instance of display_options

review_form($page, $showall, $displayoptions, $content, $attemptobj)   X-Ref
Renders the main bit of the review page.

param: int $page current page number
param: bool $showall if true display attempt on one page
param: display_options $displayoptions instance of display_options
param: string $content the rendered display of each question
param: quiz_attempt $attemptobj instance of quiz_attempt
return: string HTML to display.

finish_review_link(quiz_attempt $attemptobj)   X-Ref
Returns either a link or button.

param: quiz_attempt $attemptobj instance of quiz_attempt

review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage, $showall = null)   X-Ref
Creates the navigation links/buttons at the bottom of the review attempt page.

Note, the name of this function is no longer accurate, but when the design
changed, it was decided to keep the old name for backwards compatibility.

param: quiz_attempt $attemptobj instance of quiz_attempt
param: int $page the current page
param: bool $lastpage if true current page is the last page
param: bool|null $showall if true, the URL will be to review the entire attempt on one page,
return: string HTML fragment.

countdown_timer(quiz_attempt $attemptobj, $timenow)   X-Ref
Return the HTML of the quiz timer.

param: quiz_attempt $attemptobj instance of quiz_attempt
param: int $timenow timestamp to use as 'now'.
return: string HTML content.

restart_preview_button($url)   X-Ref
Create a preview link

param: moodle_url $url URL to restart the attempt.

navigation_panel(navigation_panel_base $panel)   X-Ref
Outputs the navigation block panel

param: navigation_panel_base $panel

render_navigation_question_button(navigation_question_button $button)   X-Ref
Display a quiz navigation button.

param: navigation_question_button $button
return: string HTML fragment.

render_navigation_section_heading(navigation_section_heading $heading)   X-Ref
Display a quiz navigation heading.

param: navigation_section_heading $heading the heading.
return: string HTML fragment.

render_links_to_other_attempts(links_to_other_attempts $links)   X-Ref
Renders a list of links the other attempts.

param: links_to_other_attempts $links
return: string HTML fragment.

start_attempt_page(quiz_settings $quizobj, preflight_check_form $mform)   X-Ref
Render the 'start attempt' page.

The student gets here if their interaction with the preflight check
from fails in some way (e.g. they typed the wrong password).

param: \mod_quiz\quiz_settings $quizobj
param: preflight_check_form $mform
return: string

attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id,$nextpage)   X-Ref
Attempt Page

param: quiz_attempt $attemptobj Instance of quiz_attempt
param: int $page Current page number
param: access_manager $accessmanager Instance of access_manager
param: array $messages An array of messages
param: array $slots Contains an array of integers that relate to questions
param: int $id The ID of an attempt
param: int $nextpage The number of the next page
return: string HTML to output.

during_attempt_tertiary_nav($quizviewurl)   X-Ref
Render the tertiary navigation for pages during the attempt.

param: string|moodle_url $quizviewurl url of the view.php page for this quiz.
return: string HTML to output.

quiz_notices($messages)   X-Ref
Returns any notices.

param: array $messages

attempt_form($attemptobj, $page, $slots, $id, $nextpage)   X-Ref
Outputs the form for making an attempt

param: quiz_attempt $attemptobj
param: int $page Current page number
param: array $slots Array of integers relating to questions
param: int $id ID of the attempt
param: int $nextpage Next page number

attempt_navigation_buttons($page, $lastpage, $navmethod = 'free')   X-Ref
Display the prev/next buttons that go at the bottom of each page of the attempt.

param: int $page the page number. Starts at 0 for the first page.
param: bool $lastpage is this the last page in the quiz?
param: string $navmethod Optional quiz attribute, 'free' (default) or 'sequential'
return: string HTML fragment.

redo_question_button($slot, $disabled)   X-Ref
Render a button which allows students to redo a question in the attempt.

param: int $slot the number of the slot to generate the button for.
param: bool $disabled if true, output the button disabled.
return: string HTML fragment.

initialise_timer($timerstartvalue, $ispreview)   X-Ref
Initialise the JavaScript required to initialise the countdown timer.

param: int $timerstartvalue time remaining, in seconds.
param: bool $ispreview true if this is a preview attempt.

close_attempt_popup($url, $message = '')   X-Ref
Output a page with an optional message, and JavaScript code to close the
current window and redirect the parent window to a new URL.

param: moodle_url $url the URL to redirect the parent window to.
param: string $message message to display before closing the window. (optional)
return: string HTML to output.

access_messages($messages)   X-Ref
Print each message in an array, surrounded by <p>, </p> tags.

param: array $messages the array of message strings.
return: string HTML to output.

summary_page($attemptobj, $displayoptions)   X-Ref
Create the summary page

param: quiz_attempt $attemptobj
param: display_options $displayoptions

summary_table($attemptobj, $displayoptions)   X-Ref
Generates the table of summarydata

param: quiz_attempt $attemptobj
param: display_options $displayoptions

summary_page_controls($attemptobj)   X-Ref
Creates any controls the page should have.

param: quiz_attempt $attemptobj

view_page($course, $quiz, $cm, $context, $viewobj)   X-Ref
Generates the view page

param: stdClass $course the course settings row from the database.
param: stdClass $quiz the quiz settings row from the database.
param: stdClass $cm the course_module settings row from the database.
param: context_module $context the quiz context.
param: view_page $viewobj
return: string HTML to display

view_page_tertiary_nav(view_page $viewobj)   X-Ref
Render the tertiary navigation for the view page.

param: view_page $viewobj the information required to display the view page.
return: string HTML to output.

view_page_buttons(view_page $viewobj)   X-Ref
Work out, and render, whatever buttons, and surrounding info, should appear
at the end of the review page.

param: view_page $viewobj the information required to display the view page.
return: string HTML to output.

start_attempt_button($buttontext, moodle_url $url,preflight_check_form $preflightcheckform = null,$popuprequired = false, $popupoptions = null)   X-Ref
Generates the view attempt button

param: string $buttontext the label to display on the button.
param: moodle_url $url The URL to POST to in order to start the attempt.
param: preflight_check_form|null $preflightcheckform deprecated.
param: bool $popuprequired whether the attempt needs to be opened in a pop-up.
param: array $popupoptions the options to use if we are opening a popup.
return: string HTML fragment.

no_questions_message($canedit, $editurl)   X-Ref
Generate a message saying that this quiz has no questions, with a button to
go to the edit page, if the user has the right capability.

param: bool $canedit can the current user edit the quiz?
param: moodle_url $editurl URL of the edit quiz page.
return: string HTML to output.

view_page_guest($course, $quiz, $cm, $context, $messages, $viewobj)   X-Ref
Outputs an error message for any guests accessing the quiz

param: stdClass $course the course settings row from the database.
param: stdClass $quiz the quiz settings row from the database.
param: stdClass $cm the course_module settings row from the database.
param: context_module $context the quiz context.
param: array $messages Array containing any messages
param: view_page $viewobj

view_page_notenrolled($course, $quiz, $cm, $context, $messages, $viewobj)   X-Ref
Outputs and error message for anyone who is not enrolled on the course.

param: stdClass $course the course settings row from the database.
param: stdClass $quiz the quiz settings row from the database.
param: stdClass $cm the course_module settings row from the database.
param: context_module $context the quiz context.
param: array $messages Array containing any messages
param: view_page $viewobj

view_information($quiz, $cm, $context, $messages, bool $quizhasquestions = false)   X-Ref
Output the page information

param: stdClass $quiz the quiz settings.
param: cm_info|stdClass $cm the course_module object.
param: context $context the quiz context.
param: array $messages any access messages that should be described.
param: bool $quizhasquestions does quiz has questions added.
return: string HTML to output.

quiz_intro($quiz, $cm)   X-Ref
Output the quiz intro.

param: stdClass $quiz the quiz settings.
param: stdClass $cm the course_module object.
return: string HTML to output.

view_table_heading()   X-Ref
Generates the table heading.


view_table($quiz, $context, $viewobj)   X-Ref
Generates the table of data

param: stdClass $quiz the quiz settings.
param: context_module $context the quiz context.
param: view_page $viewobj

attempt_state($attemptobj)   X-Ref
Generate a brief textual description of the current state of an attempt.

param: quiz_attempt $attemptobj the attempt
return: string the appropriate lang string to describe the state.

view_result_info($quiz, $context, $cm, $viewobj)   X-Ref
Generates data pertaining to quiz results

param: stdClass $quiz Array containing quiz data
param: context_module $context The quiz context.
param: stdClass|cm_info $cm The course module information.
param: view_page $viewobj
return: string HTML to display.

review_link($url, $reviewinpopup, $popupoptions)   X-Ref
Output either a link to the review page for an attempt, or a button to
open the review in a popup window.

param: moodle_url $url of the target page.
param: bool $reviewinpopup whether a pop-up is required.
param: array $popupoptions options to pass to the popup_action constructor.
return: string HTML to output.

no_review_message($message)   X-Ref
Displayed where there might normally be a review link, to explain why the
review is not available at this time.

param: string $message optional message explaining why the review is not possible.
return: string HTML to output.

quiz_attempt_summary_link_to_reports($quiz, $cm, $context,$returnzero = false, $currentgroup = 0)   X-Ref
Returns the same as {@see quiz_num_attempt_summary()} but wrapped in a link to the quiz reports.

param: stdClass $quiz the quiz object. Only $quiz->id is used at the moment.
param: stdClass $cm the cm object. Only $cm->course, $cm->groupmode and $cm->groupingid
param: context $context the quiz context.
param: bool $returnzero if false (default), when no attempts have been made '' is returned
param: int $currentgroup if there is a concept of current group where this method is being
return: string HTML fragment for the link.

quiz_override_summary_links(stdClass $quiz, cm_info|stdClass $cm, $currentgroup = 0)   X-Ref
Render a summary of the number of group and user overrides, with corresponding links.

param: stdClass $quiz the quiz settings.
param: cm_info|stdClass $cm the cm object.
param: int $currentgroup currently selected group, if there is one.
return: string HTML fragment for the link.

chart(\core\chart_base $chart, $title, $attrs = [])   X-Ref
Outputs a chart.

param: \core\chart_base $chart The chart.
param: string $title The title to display above the graph.
param: array $attrs extra container html attributes.
return: string HTML of the graph.

graph(moodle_url $url, $title)   X-Ref
Output a graph, or a message saying that GD is required.

param: moodle_url $url the URL of the graph.
param: string $title the title to display above the graph.
return: string HTML of the graph.

connection_warning()   X-Ref
Output the connection warning messages, which are initially hidden, and
only revealed by JavaScript if necessary.


render_mod_quiz_links_to_other_attempts(links_to_other_attempts $links)   X-Ref
Deprecated version of render_links_to_other_attempts.

param: links_to_other_attempts $links
return: string HTML fragment.

render_quiz_nav_question_button(navigation_question_button $button)   X-Ref
Deprecated version of render_navigation_question_button.

param: navigation_question_button $button
return: string HTML fragment.

render_quiz_nav_section_heading(navigation_section_heading $heading)   X-Ref
Deprecated version of render_navigation_section_heading.

param: navigation_section_heading $heading the heading.
return: string HTML fragment.