Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Public Member Functions | |
__call ($method, $arguments) | |
Magic method used to pass calls otherwise meant for the standard renderer to it to ensure we don't go causing unnecessary grief. | |
access_messages ($messages) | |
Print each message in an array, surrounded by <p>, </p> tags. | |
add_action_handler (component_action $action, $id=null) | |
Adds a JS action for the element with the provided id. | |
attempt_form ($attemptobj, $page, $slots, $id, $nextpage) | |
Outputs the form for making an attempt. | |
attempt_page ($attemptobj, $page, $accessmanager, $messages, $slots, $id, $nextpage) | |
Attempt Page. | |
attempt_state ($attemptobj) | |
Generate a brief textual description of the current state of an attempt. | |
chart (\core\chart_base $chart, $title, $attrs=[]) | |
Outputs a chart. | |
close_attempt_popup ($url, $message='') | |
Output a page with an optional message, and JavaScript code to close the current window and redirect the parent window to a new URL. | |
connection_warning () | |
Output the connection warning messages, which are initially hidden, and only revealed by JavaScript if necessary. | |
countdown_timer (quiz_attempt $attemptobj, $timenow) | |
Return the HTML of the quiz timer. | |
during_attempt_tertiary_nav ($quizviewurl) | |
Render the tertiary navigation for pages during the attempt. | |
filter_review_attempt_summary (attempt_summary_information $summarydata, int $page) | |
A chance to filter the information before display. | |
finish_review_link (quiz_attempt $attemptobj) | |
Returns either a link or button. | |
get_compact_logo_url ($maxwidth=300, $maxheight=300) | |
Return the site's compact logo URL, if any. | |
get_logo_url ($maxwidth=null, $maxheight=200) | |
Return the site's logo URL, if any. | |
get_page () | |
Returns the moodle page object. | |
graph (moodle_url $url, $title) | |
Output a graph, or a message saying that GD is required. | |
has_started () | |
Returns true is output has already started, and false if not. | |
image_url ($imagename, $component='moodle') | |
Return the moodle_url for an image. | |
initialise_timer ($timerstartvalue, $ispreview) | |
Initialise the JavaScript required to initialise the countdown timer. | |
navigation_panel (navigation_panel_base $panel) | |
Outputs the navigation block panel. | |
no_questions_message ($canedit, $editurl) | |
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. | |
no_review_message ($message) | |
Displayed where there might normally be a review link, to explain why the review is not available at this time. | |
pix_url ($imagename, $component='moodle') | |
Return the direct URL for an image from the pix folder. | |
questions (quiz_attempt $attemptobj, $reviewing, $slots, $page, $showall, display_options $displayoptions) | |
Renders each question. | |
quiz_attempt_summary_link_to_reports ($quiz, $cm, $context, $returnzero=false, $currentgroup=0) | |
Returns the same as {. | |
quiz_intro ($quiz, $cm) | |
Output the quiz intro. | |
quiz_notices ($messages) | |
Returns any notices. | |
quiz_override_summary_links (stdClass $quiz, cm_info|stdClass $cm, $currentgroup=0) | |
Render a summary of the number of group and user overrides, with corresponding links. | |
redo_question_button ($slot, $disabled) | |
Render a button which allows students to redo a question in the attempt. | |
render (renderable $widget) | |
Renders the provided widget and returns the HTML to display it. | |
render_from_template ($templatename, $context) | |
Renders a template by name with the given context. | |
restart_preview_button ($url) | |
Create a preview link. | |
review_attempt_summary (attempt_summary_information $summarydata, int $page) | |
Outputs the overall summary of the attempt at the top of the review page. | |
review_form ($page, $showall, $displayoptions, $content, $attemptobj) | |
Renders the main bit of the review page. | |
review_link ($url, $reviewinpopup, $popupoptions) | |
Output either a link to the review page for an attempt, or a button to open the review in a popup window. | |
review_next_navigation (quiz_attempt $attemptobj, $page, $lastpage, $showall=null) | |
Creates the navigation links/buttons at the bottom of the review attempt page. | |
review_page (quiz_attempt $attemptobj, $slots, $page, $showall, $lastpage, display_options $displayoptions, $summarydata) | |
Builds the review page. | |
review_question_not_allowed (quiz_attempt $attemptobj, $message) | |
Renders the review question pop-up. | |
review_question_page (quiz_attempt $attemptobj, $slot, $seq, display_options $displayoptions, $summarydata) | |
Renders the review question pop-up. | |
review_summary_table ($summarydata, $page) | |
Outputs the table containing data from summary data array. | |
should_display_main_logo () | |
should_display_navbar_logo () | |
Whether we should display the logo in the navbar. | |
start_attempt_button ($buttontext, moodle_url $url, preflight_check_form $preflightcheckform=null, $popuprequired=false, $popupoptions=null) | |
Generates the view attempt button. | |
start_attempt_page (quiz_settings $quizobj, preflight_check_form $mform) | |
Render the 'start attempt' page. | |
summary_page ($attemptobj, $displayoptions) | |
Create the summary page. | |
summary_page_controls ($attemptobj) | |
Creates any controls the page should have. | |
summary_table ($attemptobj, $displayoptions) | |
Generates the table of summarydata. | |
view_information ($quiz, $cm, $context, $messages, bool $quizhasquestions=false) | |
Output the page information. | |
view_page ($course, $quiz, $cm, $context, $viewobj) | |
Generates the view page. | |
view_page_buttons (view_page $viewobj) | |
Work out, and render, whatever buttons, and surrounding info, should appear at the end of the review page. | |
view_page_guest ($course, $quiz, $cm, $context, $messages, $viewobj) | |
Outputs an error message for any guests accessing the quiz. | |
view_page_notenrolled ($course, $quiz, $cm, $context, $messages, $viewobj) | |
Outputs and error message for anyone who is not enrolled on the course. | |
view_page_tertiary_nav (view_page $viewobj) | |
Render the tertiary navigation for the view page. | |
view_result_info ($quiz, $context, $cm, $viewobj) | |
Generates data pertaining to quiz results. | |
view_table ($quiz, $context, $viewobj) | |
Generates the table of data. | |
view_table_heading () | |
Generates the table heading. | |
Static Public Member Functions | |
static | prepare_classes ($classes) |
Given an array or space-separated list of classes, prepares and returns the HTML class attribute value. | |
Protected Member Functions | |
attempt_navigation_buttons ($page, $lastpage, $navmethod='free') | |
Display the prev/next buttons that go at the bottom of each page of the attempt. | |
filter_review_summary_table ($summarydata, $page) | |
Filters the summarydata array. | |
get_mustache () | |
Return an instance of the mustache class. | |
render_grade_out_of (grade_out_of $grade) | |
Render a {. | |
render_links_to_other_attempts (links_to_other_attempts $links) | |
Renders a list of links the other attempts. | |
render_mod_quiz_links_to_other_attempts (links_to_other_attempts $links) | |
Deprecated version of render_links_to_other_attempts. | |
render_navigation_question_button (navigation_question_button $button) | |
Display a quiz navigation button. | |
render_navigation_section_heading (navigation_section_heading $heading) | |
Display a quiz navigation heading. | |
render_quiz_nav_question_button (navigation_question_button $button) | |
Deprecated version of render_navigation_question_button. | |
render_quiz_nav_section_heading (navigation_section_heading $heading) | |
Deprecated version of render_navigation_section_heading. | |
Protected Attributes | |
xhtml_container_stack | $opencontainers |
The xhtml_container_stack to use. | |
renderer_base core_renderer | $output |
A reference to the current renderer. | |
moodle_page | $page |
The Moodle page the renderer has been created to assist with. | |
string | $target |
The requested rendering target. | |
array | $templatecache = [] |
$templatecache The mustache template cache. | |
mod_quiz\output\renderer::access_messages | ( | $messages | ) |
Print each message in an array, surrounded by <p>, </p> tags.
array | $messages | the array of message strings. |
string | HTML to output. |
mod_quiz\output\renderer::attempt_form | ( | $attemptobj, | |
$page, | |||
$slots, | |||
$id, | |||
$nextpage ) |
Outputs the form for making an attempt.
quiz_attempt | $attemptobj | |
int | $page | Current page number |
array | $slots | Array of integers relating to questions |
int | $id | ID of the attempt |
int | $nextpage | Next page number |
|
protected |
Display the prev/next buttons that go at the bottom of each page of the attempt.
int | $page | the page number. Starts at 0 for the first page. |
bool | $lastpage | is this the last page in the quiz? |
string | $navmethod | Optional quiz attribute, 'free' (default) or 'sequential' |
string | HTML fragment. |
mod_quiz\output\renderer::attempt_page | ( | $attemptobj, | |
$page, | |||
$accessmanager, | |||
$messages, | |||
$slots, | |||
$id, | |||
$nextpage ) |
Attempt Page.
quiz_attempt | $attemptobj | Instance of quiz_attempt |
int | $page | Current page number |
access_manager | $accessmanager | Instance of access_manager |
array | $messages | An array of messages |
array | $slots | Contains an array of integers that relate to questions |
int | $id | The ID of an attempt |
int | $nextpage | The number of the next page |
string | HTML to output. |
mod_quiz\output\renderer::attempt_state | ( | $attemptobj | ) |
Generate a brief textual description of the current state of an attempt.
quiz_attempt | $attemptobj | the attempt |
string | the appropriate lang string to describe the state. |
mod_quiz\output\renderer::chart | ( | \core\chart_base | $chart, |
$title, | |||
$attrs = [] ) |
Outputs a chart.
core\chart_base | $chart | The chart. |
string | $title | The title to display above the graph. |
array | $attrs | extra container html attributes. |
string | HTML of the graph. |
mod_quiz\output\renderer::close_attempt_popup | ( | $url, | |
$message = '' ) |
Output a page with an optional message, and JavaScript code to close the current window and redirect the parent window to a new URL.
moodle_url | $url | the URL to redirect the parent window to. |
string | $message | message to display before closing the window. (optional) |
string | HTML to output. |
mod_quiz\output\renderer::countdown_timer | ( | quiz_attempt | $attemptobj, |
$timenow ) |
Return the HTML of the quiz timer.
quiz_attempt | $attemptobj | instance of quiz_attempt |
int | $timenow | timestamp to use as 'now'. |
string | HTML content. |
mod_quiz\output\renderer::during_attempt_tertiary_nav | ( | $quizviewurl | ) |
Render the tertiary navigation for pages during the attempt.
string | moodle_url | $quizviewurl | url of the view.php page for this quiz. |
string | HTML to output. |
mod_quiz\output\renderer::filter_review_attempt_summary | ( | attempt_summary_information | $summarydata, |
int | $page ) |
A chance to filter the information before display.
Moodle core uses this to display less infomrmation on pages after the first. This is a separate method, becaus it is a useful hook where themes can overrid things.
attempt_summary_information | $summarydata | the data that will be displayed. Modify as desired. |
int | $page | contains the current page number |
|
protected |
Filters the summarydata array.
array | $summarydata | contains row data for table |
int | $page | the current page number |
array | updated version of the $summarydata array. |
mod_quiz\output\renderer::finish_review_link | ( | quiz_attempt | $attemptobj | ) |
Returns either a link or button.
quiz_attempt | $attemptobj | instance of quiz_attempt |
mod_quiz\output\renderer::graph | ( | moodle_url | $url, |
$title ) |
Output a graph, or a message saying that GD is required.
moodle_url | $url | the URL of the graph. |
string | $title | the title to display above the graph. |
string | HTML of the graph. |
mod_quiz\output\renderer::initialise_timer | ( | $timerstartvalue, | |
$ispreview ) |
Initialise the JavaScript required to initialise the countdown timer.
int | $timerstartvalue | time remaining, in seconds. |
bool | $ispreview | true if this is a preview attempt. |
mod_quiz\output\renderer::navigation_panel | ( | navigation_panel_base | $panel | ) |
Outputs the navigation block panel.
navigation_panel_base | $panel |
mod_quiz\output\renderer::no_questions_message | ( | $canedit, | |
$editurl ) |
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.
bool | $canedit | can the current user edit the quiz? |
moodle_url | $editurl | URL of the edit quiz page. |
string | HTML to output. |
mod_quiz\output\renderer::no_review_message | ( | $message | ) |
Displayed where there might normally be a review link, to explain why the review is not available at this time.
string | $message | optional message explaining why the review is not possible. |
string | HTML to output. |
mod_quiz\output\renderer::questions | ( | quiz_attempt | $attemptobj, |
$reviewing, | |||
$slots, | |||
$page, | |||
$showall, | |||
display_options | $displayoptions ) |
Renders each question.
quiz_attempt | $attemptobj | instance of quiz_attempt |
bool | $reviewing | |
array | $slots | array of integers relating to questions |
int | $page | current page number |
bool | $showall | if true shows attempt on single page |
display_options | $displayoptions | instance of display_options |
mod_quiz\output\renderer::quiz_attempt_summary_link_to_reports | ( | $quiz, | |
$cm, | |||
$context, | |||
$returnzero = false, | |||
$currentgroup = 0 ) |
Returns the same as {.
stdClass | $quiz | the quiz object. Only $quiz->id is used at the moment. |
stdClass | $cm | the cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment. |
context | $context | the quiz context. |
bool | $returnzero | if false (default), when no attempts have been made '' is returned instead of 'Attempts: 0'. |
int | $currentgroup | if there is a concept of current group where this method is being called (e.g. a report) pass it in here. Default 0 which means no current group. |
string | HTML fragment for the link. |
mod_quiz\output\renderer::quiz_intro | ( | $quiz, | |
$cm ) |
Output the quiz intro.
stdClass | $quiz | the quiz settings. |
stdClass | $cm | the course_module object. |
string | HTML to output. |
mod_quiz\output\renderer::quiz_notices | ( | $messages | ) |
Returns any notices.
array | $messages |
mod_quiz\output\renderer::quiz_override_summary_links | ( | stdClass | $quiz, |
cm_info|stdClass | $cm, | ||
$currentgroup = 0 ) |
Render a summary of the number of group and user overrides, with corresponding links.
stdClass | $quiz | the quiz settings. |
cm_info | stdClass | $cm | the cm object. |
int | $currentgroup | currently selected group, if there is one. |
string | HTML fragment for the link. |
mod_quiz\output\renderer::redo_question_button | ( | $slot, | |
$disabled ) |
Render a button which allows students to redo a question in the attempt.
int | $slot | the number of the slot to generate the button for. |
bool | $disabled | if true, output the button disabled. |
string | HTML fragment. |
|
protected |
Render a {.
Most of the logic is in methods of the grade_out_of class. However, having this renderer method allows themes to override the default rendering.
grade_out_of | $grade |
string | HTML to output. |
|
protected |
Renders a list of links the other attempts.
links_to_other_attempts | $links |
string | HTML fragment. |
|
protected |
Deprecated version of render_links_to_other_attempts.
links_to_other_attempts | $links |
string | HTML fragment. |
|
protected |
Display a quiz navigation button.
navigation_question_button | $button |
string | HTML fragment. |
|
protected |
Display a quiz navigation heading.
navigation_section_heading | $heading | the heading. |
string | HTML fragment. |
|
protected |
Deprecated version of render_navigation_question_button.
navigation_question_button | $button |
string | HTML fragment. |
|
protected |
Deprecated version of render_navigation_section_heading.
navigation_section_heading | $heading | the heading. |
string | HTML fragment. |
mod_quiz\output\renderer::restart_preview_button | ( | $url | ) |
Create a preview link.
moodle_url | $url | URL to restart the attempt. |
mod_quiz\output\renderer::review_attempt_summary | ( | attempt_summary_information | $summarydata, |
int | $page ) |
Outputs the overall summary of the attempt at the top of the review page.
attempt_summary_information | $summarydata | contains row data for table. |
int | $page | contains the current page number |
string | HTML to display. |
mod_quiz\output\renderer::review_form | ( | $page, | |
$showall, | |||
$displayoptions, | |||
$content, | |||
$attemptobj ) |
Renders the main bit of the review page.
int | $page | current page number |
bool | $showall | if true display attempt on one page |
display_options | $displayoptions | instance of display_options |
string | $content | the rendered display of each question |
quiz_attempt | $attemptobj | instance of quiz_attempt |
string | HTML to display. |
mod_quiz\output\renderer::review_link | ( | $url, | |
$reviewinpopup, | |||
$popupoptions ) |
Output either a link to the review page for an attempt, or a button to open the review in a popup window.
moodle_url | $url | of the target page. |
bool | $reviewinpopup | whether a pop-up is required. |
array | $popupoptions | options to pass to the popup_action constructor. |
string | HTML to output. |
mod_quiz\output\renderer::review_next_navigation | ( | quiz_attempt | $attemptobj, |
$page, | |||
$lastpage, | |||
$showall = null ) |
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.
quiz_attempt | $attemptobj | instance of quiz_attempt |
int | $page | the current page |
bool | $lastpage | if true current page is the last page |
bool | null | $showall | if true, the URL will be to review the entire attempt on one page, and $page will be ignored. If null, a sensible default will be chosen. |
string | HTML fragment. |
mod_quiz\output\renderer::review_page | ( | quiz_attempt | $attemptobj, |
$slots, | |||
$page, | |||
$showall, | |||
$lastpage, | |||
display_options | $displayoptions, | ||
$summarydata ) |
Builds the review page.
quiz_attempt | $attemptobj | an instance of quiz_attempt. |
array | $slots | of slots to be displayed. |
int | $page | the current page number |
bool | $showall | whether to show entire attempt on one page. |
bool | $lastpage | if true the current page is the last page. |
display_options | $displayoptions | instance of display_options. |
attempt_summary_information | array | $summarydata | summary information about the attempt. Passing an array is deprecated. |
string | HTML to display. |
mod_quiz\output\renderer::review_question_not_allowed | ( | quiz_attempt | $attemptobj, |
$message ) |
Renders the review question pop-up.
quiz_attempt | $attemptobj | an instance of quiz_attempt. |
string | $message | Why the review is not allowed. |
string | html to output. |
mod_quiz\output\renderer::review_question_page | ( | quiz_attempt | $attemptobj, |
$slot, | |||
$seq, | |||
display_options | $displayoptions, | ||
$summarydata ) |
Renders the review question pop-up.
quiz_attempt | $attemptobj | an instance of quiz_attempt. |
int | $slot | which question to display. |
int | $seq | which step of the question attempt to show. null = latest. |
display_options | $displayoptions | instance of display_options. |
attempt_summary_information | array | $summarydata | summary information about the attempt. Passing an array is deprecated. |
string | HTML to display. |
mod_quiz\output\renderer::review_summary_table | ( | $summarydata, | |
$page ) |
Outputs the table containing data from summary data array.
array | $summarydata | contains row data for table |
int | $page | contains the current page number |
string | HTML to display. |
mod_quiz\output\renderer::start_attempt_button | ( | $buttontext, | |
moodle_url | $url, | ||
preflight_check_form | $preflightcheckform = null, | ||
$popuprequired = false, | |||
$popupoptions = null ) |
Generates the view attempt button.
string | $buttontext | the label to display on the button. |
moodle_url | $url | The URL to POST to in order to start the attempt. |
preflight_check_form | null | $preflightcheckform | deprecated. |
bool | $popuprequired | whether the attempt needs to be opened in a pop-up. |
array | $popupoptions | the options to use if we are opening a popup. |
string | HTML fragment. |
mod_quiz\output\renderer::start_attempt_page | ( | quiz_settings | $quizobj, |
preflight_check_form | $mform ) |
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).
mod_quiz\quiz_settings | $quizobj | |
preflight_check_form | $mform |
string |
mod_quiz\output\renderer::summary_page | ( | $attemptobj, | |
$displayoptions ) |
Create the summary page.
quiz_attempt | $attemptobj | |
display_options | $displayoptions |
mod_quiz\output\renderer::summary_page_controls | ( | $attemptobj | ) |
Creates any controls the page should have.
quiz_attempt | $attemptobj |
mod_quiz\output\renderer::summary_table | ( | $attemptobj, | |
$displayoptions ) |
Generates the table of summarydata.
quiz_attempt | $attemptobj | |
display_options | $displayoptions |
mod_quiz\output\renderer::view_information | ( | $quiz, | |
$cm, | |||
$context, | |||
$messages, | |||
bool | $quizhasquestions = false ) |
Output the page information.
stdClass | $quiz | the quiz settings. |
cm_info | stdClass | $cm | the course_module object. |
context | $context | the quiz context. |
array | $messages | any access messages that should be described. |
bool | $quizhasquestions | does quiz has questions added. |
string | HTML to output. |
mod_quiz\output\renderer::view_page | ( | $course, | |
$quiz, | |||
$cm, | |||
$context, | |||
$viewobj ) |
Generates the view page.
stdClass | $course | the course settings row from the database. |
stdClass | $quiz | the quiz settings row from the database. |
stdClass | $cm | the course_module settings row from the database. |
context_module | $context | the quiz context. |
view_page | $viewobj |
string | HTML to display |
mod_quiz\output\renderer::view_page_buttons | ( | view_page | $viewobj | ) |
Work out, and render, whatever buttons, and surrounding info, should appear at the end of the review page.
view_page | $viewobj | the information required to display the view page. |
string | HTML to output. |
mod_quiz\output\renderer::view_page_guest | ( | $course, | |
$quiz, | |||
$cm, | |||
$context, | |||
$messages, | |||
$viewobj ) |
Outputs an error message for any guests accessing the quiz.
stdClass | $course | the course settings row from the database. |
stdClass | $quiz | the quiz settings row from the database. |
stdClass | $cm | the course_module settings row from the database. |
context_module | $context | the quiz context. |
array | $messages | Array containing any messages |
view_page | $viewobj |
mod_quiz\output\renderer::view_page_notenrolled | ( | $course, | |
$quiz, | |||
$cm, | |||
$context, | |||
$messages, | |||
$viewobj ) |
Outputs and error message for anyone who is not enrolled on the course.
stdClass | $course | the course settings row from the database. |
stdClass | $quiz | the quiz settings row from the database. |
stdClass | $cm | the course_module settings row from the database. |
context_module | $context | the quiz context. |
array | $messages | Array containing any messages |
view_page | $viewobj |
mod_quiz\output\renderer::view_page_tertiary_nav | ( | view_page | $viewobj | ) |
Render the tertiary navigation for the view page.
view_page | $viewobj | the information required to display the view page. |
string | HTML to output. |
mod_quiz\output\renderer::view_result_info | ( | $quiz, | |
$context, | |||
$cm, | |||
$viewobj ) |
Generates data pertaining to quiz results.
stdClass | $quiz | Array containing quiz data |
context_module | $context | The quiz context. |
stdClass | cm_info | $cm | The course module information. |
view_page | $viewobj |
string | HTML to display. |
mod_quiz\output\renderer::view_table | ( | $quiz, | |
$context, | |||
$viewobj ) |
Generates the table of data.
stdClass | $quiz | the quiz settings. |
context_module | $context | the quiz context. |
view_page | $viewobj |