Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
The renderer for the quiz module. More...
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. More... | |
access_messages ($messages) | |
Print each message in an array, surrounded by <p>, </p> tags. More... | |
add_action_handler (component_action $action, $id=null) | |
Adds a JS action for the element with the provided id. More... | |
attempt_form ($attemptobj, $page, $slots, $id, $nextpage) | |
Ouputs the form for making an attempt. More... | |
attempt_page ($attemptobj, $page, $accessmanager, $messages, $slots, $id, $nextpage) | |
Attempt Page. More... | |
attempt_state ($attemptobj) | |
Generate a brief textual desciption of the current state of an attempt. More... | |
chart (\core\chart_base $chart, $title) | |
Outputs a chart. More... | |
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. More... | |
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. More... | |
finish_review_link (quiz_attempt $attemptobj) | |
Returns either a liink or button. More... | |
get_compact_logo_url ($maxwidth=300, $maxheight=300) | |
Return the site's compact logo URL, if any. More... | |
get_logo_url ($maxwidth=null, $maxheight=200) | |
Return the site's logo URL, if any. More... | |
graph (moodle_url $url, $title) | |
Output a graph, or a message saying that GD is required. More... | |
has_started () | |
Returns true is output has already started, and false if not. More... | |
image_url ($imagename, $component='moodle') | |
Return the moodle_url for an image. More... | |
initialise_timer ($timerstartvalue, $ispreview) | |
Output the JavaScript required to initialise the countdown timer. More... | |
navigation_panel (quiz_nav_panel_base $panel) | |
Outputs the navigation block panel. More... | |
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. More... | |
no_review_message ($message) | |
Displayed where there might normally be a review link, to explain why the review is not available at this time. More... | |
pix_url ($imagename, $component='moodle') | |
Return the direct URL for an image from the pix folder. More... | |
questions (quiz_attempt $attemptobj, $reviewing, $slots, $page, $showall, mod_quiz_display_options $displayoptions) | |
Renders each question. More... | |
quiz_attempt_summary_link_to_reports ($quiz, $cm, $context, $returnzero=false, $currentgroup=0) | |
Returns the same as quiz_num_attempt_summary() but wrapped in a link to the quiz reports. More... | |
quiz_intro ($quiz, $cm) | |
Output the quiz intro. More... | |
quiz_notices ($messages) | |
Returns any notices. More... | |
redo_question_button ($slot, $disabled) | |
Render a button which allows students to redo a question in the attempt. More... | |
render (renderable $widget) | |
Renders the provided widget and returns the HTML to display it. More... | |
render_from_template ($templatename, $context) | |
Renders a template by name with the given context. More... | |
restart_preview_button ($url) | |
Create a preview link. More... | |
review_form ($page, $showall, $displayoptions, $content, $attemptobj) | |
Renders the main bit of the review page. More... | |
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. More... | |
review_next_navigation (quiz_attempt $attemptobj, $page, $lastpage, $showall=null) | |
Creates the navigation links/buttons at the bottom of the reivew attempt page. More... | |
review_page (quiz_attempt $attemptobj, $slots, $page, $showall, $lastpage, mod_quiz_display_options $displayoptions, $summarydata) | |
Builds the review page. More... | |
review_question_not_allowed (quiz_attempt $attemptobj, $message) | |
Renders the review question pop-up. More... | |
review_question_page (quiz_attempt $attemptobj, $slot, $seq, mod_quiz_display_options $displayoptions, $summarydata) | |
Renders the review question pop-up. More... | |
review_summary_table ($summarydata, $page) | |
Outputs the table containing data from summary data array. More... | |
should_display_main_logo ($headinglevel=1) | |
Whether we should display the main logo. More... | |
should_display_navbar_logo () | |
Whether we should display the logo in the navbar. More... | |
start_attempt_button ($buttontext, moodle_url $url, mod_quiz_preflight_check_form $preflightcheckform=null, $popuprequired=false, $popupoptions=null) | |
Generates the view attempt button. More... | |
start_attempt_page (quiz $quizobj, mod_quiz_preflight_check_form $mform) | |
summary_page ($attemptobj, $displayoptions) | |
Create the summary page. More... | |
summary_page_controls ($attemptobj) | |
Creates any controls a the page should have. More... | |
summary_table ($attemptobj, $displayoptions) | |
Generates the table of summarydata. More... | |
view_information ($quiz, $cm, $context, $messages) | |
Output the page information. More... | |
view_page ($course, $quiz, $cm, $context, $viewobj) | |
Generates the view page. More... | |
view_page_buttons (mod_quiz_view_object $viewobj) | |
Work out, and render, whatever buttons, and surrounding info, should appear at the end of the review page. More... | |
view_page_guest ($course, $quiz, $cm, $context, $messages) | |
Outputs an error message for any guests accessing the quiz. More... | |
view_page_notenrolled ($course, $quiz, $cm, $context, $messages) | |
Outputs and error message for anyone who is not enrolle don the course. More... | |
view_result_info ($quiz, $context, $cm, $viewobj) | |
Generates data pertaining to quiz results. More... | |
view_table ($quiz, $context, $viewobj) | |
Generates the table of data. More... | |
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. More... | |
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. More... | |
filter_review_summary_table ($summarydata, $page) | |
Filters the summarydata array. More... | |
get_mustache () | |
Return an instance of the mustache class. More... | |
render_mod_quiz_links_to_other_attempts (mod_quiz_links_to_other_attempts $links) | |
outputs the link the other attempts. More... | |
render_quiz_nav_question_button (quiz_nav_question_button $button) | |
Display a quiz navigation button. More... | |
render_quiz_nav_section_heading (quiz_nav_section_heading $heading) | |
Display a quiz navigation heading. More... | |
Protected Attributes | |
xhtml_container_stack | $opencontainers |
The xhtml_container_stack to use. | |
renderer_base core_renderer | $output |
A reference to the current renderer. More... | |
moodle_page | $page |
The Moodle page the renderer has been created to assist with. | |
string | $target |
The requested rendering target. | |
The renderer for the quiz module.
|
inherited |
Magic method used to pass calls otherwise meant for the standard renderer to it to ensure we don't go causing unnecessary grief.
string | $method | |
array | $arguments |
mixed |
mod_quiz_renderer::access_messages | ( | $messages | ) |
Print each message in an array, surrounded by <p>, </p> tags.
array | $messages | the array of message strings. |
bool | $return | if true, return a string, instead of outputting. |
string | HTML to output. |
|
inherited |
Adds a JS action for the element with the provided id.
This method adds a JS event for the provided component action to the page and then returns the id that the event has been attached to. If no id has been provided then a new ID is generated by html_writer::random_id()
component_action | $action | |
string | $id |
string | id of element, either original submitted or random new if not supplied |
mod_quiz_renderer::attempt_form | ( | $attemptobj, | |
$page, | |||
$slots, | |||
$id, | |||
$nextpage | |||
) |
Ouputs 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_renderer::attempt_page | ( | $attemptobj, | |
$page, | |||
$accessmanager, | |||
$messages, | |||
$slots, | |||
$id, | |||
$nextpage | |||
) |
Attempt Page.
quiz_attempt | $attemptobj | Instance of quiz_attempt |
int | $page | Current page number |
quiz_access_manager | $accessmanager | Instance of quiz_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 |
mod_quiz_renderer::attempt_state | ( | $attemptobj | ) |
Generate a brief textual desciption of the current state of an attempt.
quiz_attempt | $attemptobj | the attempt |
int | $timenow | the time to use as 'now'. |
string | the appropriate lang string to describe the state. |
mod_quiz_renderer::chart | ( | \core\chart_base | $chart, |
$title | |||
) |
Outputs a chart.
core\chart_base | $chart | The chart. |
string | $title | The title to display above the graph. |
string | HTML fragment for the graph. |
mod_quiz_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_renderer::countdown_timer | ( | quiz_attempt | $attemptobj, |
$timenow | |||
) |
Return the HTML of the quiz timer.
string | HTML content. |
|
protected |
Filters the summarydata array.
array | $summarydata | contains row data for table |
int | $page | the current page number |
$summarydata | containing filtered row data |
mod_quiz_renderer::finish_review_link | ( | quiz_attempt | $attemptobj | ) |
Returns either a liink or button.
quiz_attempt | $attemptobj | instance of quiz_attempt |
|
inherited |
Return the site's compact logo URL, if any.
int | $maxwidth | The maximum width, or null when the maximum width does not matter. |
int | $maxheight | The maximum height, or null when the maximum height does not matter. |
moodle_url|false |
|
inherited |
Return the site's logo URL, if any.
int | $maxwidth | The maximum width, or null when the maximum width does not matter. |
int | $maxheight | The maximum height, or null when the maximum height does not matter. |
moodle_url|false |
|
protectedinherited |
Return an instance of the mustache class.
Mustache_Engine |
mod_quiz_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 fragment for the graph. |
|
inherited |
Returns true is output has already started, and false if not.
boolean | true if the header has been printed. |
|
inherited |
Return the moodle_url for an image.
The exact image location and extension is determined automatically by searching for gif|png|jpg|jpeg, please note there can not be diferent images with the different extension. The imagename is for historical reasons a relative path name, it may be changed later for core images. It is recommended to not use subdirectories in plugin and theme pix directories.
There are three types of images: 1/ theme images - stored in theme/mytheme/pix/, use component 'theme' 2/ core images - stored in /pix/, overridden via theme/mytheme/pix_core/ 3/ plugin images - stored in mod/mymodule/pix, overridden via theme/mytheme/pix_plugins/mod/mymodule/, example: image_url('comment', 'mod_glossary')
string | $imagename | the pathname of the image |
string | $component | full plugin name (aka component) or 'theme' |
moodle_url |
mod_quiz_renderer::initialise_timer | ( | $timerstartvalue, | |
$ispreview | |||
) |
Output the JavaScript required to initialise the countdown timer.
int | $timerstartvalue | time remaining, in seconds. |
mod_quiz_renderer::navigation_panel | ( | quiz_nav_panel_base | $panel | ) |
Outputs the navigation block panel.
quiz_nav_panel_base | $panel | instance of quiz_nav_panel_base |
mod_quiz_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.
object | $quiz | the quiz settings. |
object | $cm | the course_module object. |
object | $context | the quiz context. |
string | HTML to output. |
mod_quiz_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. |
|
inherited |
Return the direct URL for an image from the pix folder.
Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.
string | $imagename | the name of the icon. |
string | $component | specification of one plugin like in get_string() |
moodle_url |
|
staticinherited |
Given an array or space-separated list of classes, prepares and returns the HTML class attribute value.
mixed | $classes | Space-separated string or array of classes |
string | HTML class attribute value |
mod_quiz_renderer::questions | ( | quiz_attempt | $attemptobj, |
$reviewing, | |||
$slots, | |||
$page, | |||
$showall, | |||
mod_quiz_display_options | $displayoptions | ||
) |
Renders each question.
quiz_attempt | $attemptobj | instance of quiz_attempt |
bool | $reviewing | |
array | $slots | array of intgers relating to questions |
int | $page | current page number |
bool | $showall | if true shows attempt on single page |
mod_quiz_display_options | $displayoptions | instance of mod_quiz_display_options |
mod_quiz_renderer::quiz_attempt_summary_link_to_reports | ( | $quiz, | |
$cm, | |||
$context, | |||
$returnzero = false , |
|||
$currentgroup = 0 |
|||
) |
Returns the same as quiz_num_attempt_summary() but wrapped in a link to the quiz reports.
object | $quiz | the quiz object. Only $quiz->id is used at the moment. |
object | $cm | the cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment. |
object | $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_renderer::quiz_intro | ( | $quiz, | |
$cm | |||
) |
Output the quiz intro.
object | $quiz | the quiz settings. |
object | $cm | the course_module object. |
string | HTML to output. |
mod_quiz_renderer::quiz_notices | ( | $messages | ) |
Returns any notices.
array | $messages |
mod_quiz_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. |
|
inherited |
Renders the provided widget and returns the HTML to display it.
renderable | $widget | instance with renderable interface |
string |
Reimplemented from renderer_base.
Reimplemented in tool_policy\output\renderer.
|
inherited |
Renders a template by name with the given context.
The provided data needs to be array/stdClass made up of only simple types. Simple types are array,stdClass,bool,int,float,string
array | stdClass | $context | Context containing data for the template. |
string|boolean |
|
protected |
outputs the link the other attempts.
mod_quiz_links_to_other_attempts | $links |
|
protected |
Display a quiz navigation button.
quiz_nav_question_button | $button |
string | HTML fragment. |
|
protected |
Display a quiz navigation heading.
quiz_nav_section_heading | $heading | the heading. |
string | HTML fragment. |
mod_quiz_renderer::restart_preview_button | ( | $url | ) |
Create a preview link.
moodle_url | $url | contains a url to the given page |
mod_quiz_renderer::review_form | ( | $page, | |
$showall, | |||
$displayoptions, | |||
$content, | |||
$attemptobj | |||
) |
Renders the main bit of the review page.
array | $summarydata | contain row data for table |
int | $page | current page number |
mod_quiz_display_options | $displayoptions | instance of mod_quiz_display_options |
$content | contains each question | |
quiz_attempt | $attemptobj | instance of quiz_attempt |
bool | $showall | if true display attempt on one page |
mod_quiz_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_renderer::review_next_navigation | ( | quiz_attempt | $attemptobj, |
$page, | |||
$lastpage, | |||
$showall = null |
|||
) |
Creates the navigation links/buttons at the bottom of the reivew 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_renderer::review_page | ( | quiz_attempt | $attemptobj, |
$slots, | |||
$page, | |||
$showall, | |||
$lastpage, | |||
mod_quiz_display_options | $displayoptions, | ||
$summarydata | |||
) |
Builds the review page.
quiz_attempt | $attemptobj | an instance of quiz_attempt. |
array | $slots | an array of intgers relating to questions. |
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. |
mod_quiz_display_options | $displayoptions | instance of mod_quiz_display_options. |
array | $summarydata | contains all table data |
$output | containing html data. |
mod_quiz_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_renderer::review_question_page | ( | quiz_attempt | $attemptobj, |
$slot, | |||
$seq, | |||
mod_quiz_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. |
mod_quiz_display_options | $displayoptions | instance of mod_quiz_display_options. |
array | $summarydata | contains all table data |
$output | containing html data. |
mod_quiz_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 |
|
inherited |
Whether we should display the main logo.
int | $headinglevel | The heading level we want to check against. |
bool |
|
inherited |
Whether we should display the logo in the navbar.
We will when there are no main logos, and we have compact logo.
bool |
mod_quiz_renderer::start_attempt_button | ( | $buttontext, | |
moodle_url | $url, | ||
mod_quiz_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. |
mod_quiz_preflight_check_form | $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_renderer::summary_page | ( | $attemptobj, | |
$displayoptions | |||
) |
Create the summary page.
quiz_attempt | $attemptobj | |
mod_quiz_display_options | $displayoptions |
mod_quiz_renderer::summary_page_controls | ( | $attemptobj | ) |
Creates any controls a the page should have.
quiz_attempt | $attemptobj |
mod_quiz_renderer::summary_table | ( | $attemptobj, | |
$displayoptions | |||
) |
Generates the table of summarydata.
quiz_attempt | $attemptobj | |
mod_quiz_display_options | $displayoptions |
mod_quiz_renderer::view_information | ( | $quiz, | |
$cm, | |||
$context, | |||
$messages | |||
) |
Output the page information.
object | $quiz | the quiz settings. |
object | $cm | the course_module object. |
object | $context | the quiz context. |
array | $messages | any access messages that should be described. |
string | HTML to output. |
mod_quiz_renderer::view_page | ( | $course, | |
$quiz, | |||
$cm, | |||
$context, | |||
$viewobj | |||
) |
Generates the view page.
int | $course | The id of the course |
array | $quiz | Array conting quiz data |
int | $cm | Course Module ID |
int | $context | The page context ID |
array | $infomessages | information about this quiz |
mod_quiz_view_object | $viewobj | |
string | $buttontext | text for the start/continue attempt button, if it should be shown. |
array | $infomessages | further information about why the student cannot attempt this quiz now, if appicable this quiz |
mod_quiz_renderer::view_page_buttons | ( | mod_quiz_view_object | $viewobj | ) |
Work out, and render, whatever buttons, and surrounding info, should appear at the end of the review page.
mod_quiz_view_object | $viewobj | the information required to display the view page. |
string | HTML to output. |
mod_quiz_renderer::view_page_guest | ( | $course, | |
$quiz, | |||
$cm, | |||
$context, | |||
$messages | |||
) |
Outputs an error message for any guests accessing the quiz.
int | $course | The course ID |
array | $quiz | Array contingin quiz data |
int | $cm | Course Module ID |
int | $context | The page contect ID |
array | $messages | Array containing any messages |
mod_quiz_renderer::view_page_notenrolled | ( | $course, | |
$quiz, | |||
$cm, | |||
$context, | |||
$messages | |||
) |
Outputs and error message for anyone who is not enrolle don the course.
int | $course | The course ID |
array | $quiz | Array contingin quiz data |
int | $cm | Course Module ID |
int | $context | The page contect ID |
array | $messages | Array containing any messages |
mod_quiz_renderer::view_result_info | ( | $quiz, | |
$context, | |||
$cm, | |||
$viewobj | |||
) |
Generates data pertaining to quiz results.
array | $quiz | Array containing quiz data |
int | $context | The page context ID |
int | $cm | The Course Module Id |
mod_quiz_view_object | $viewobj |
mod_quiz_renderer::view_table | ( | $quiz, | |
$context, | |||
$viewobj | |||
) |
Generates the table of data.
array | $quiz | Array contining quiz data |
int | $context | The page context ID |
mod_quiz_view_object | $viewobj |
|
protectedinherited |
A reference to the current renderer.
The renderer provided here will be determined by the page but will in 90% of cases by the core_renderer