Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Renderer outputting the quiz editing UI. 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. | |
add_action_handler (component_action $action, $id=null) | |
Adds a JS action for the element with the provided id. | |
add_menu_actions (structure $structure, $page, moodle_url $pageurl, core_question\local\bank\question_edit_contexts $contexts, array $pagevars) | |
Returns the add menu that is output once per page. | |
edit_menu_actions (structure $structure, $page, moodle_url $pageurl, array $pagevars) | |
Returns the list of actions to go in the add menu. | |
edit_page (\mod_quiz\quiz_settings $quizobj, structure $structure, core_question\local\bank\question_edit_contexts $contexts, moodle_url $pageurl, array $pagevars) | |
Render the edit page. | |
get_action_icon (structure $structure, int $slot, moodle_url $pageurl) | |
Get the action icons render. | |
get_checkbox_render (structure $structure, int $slot) | |
Get the checkbox render. | |
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_question_name_for_slot (structure $structure, int $slot, moodle_url $pageurl) | |
Get the question name for the slot. | |
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. | |
marked_out_of_field (structure $structure, $slot) | |
Display the 'marked out of' information for a question. | |
maximum_grade_input ($structure, moodle_url $pageurl) | |
Render the form for setting a quiz' overall grade. | |
page_row (structure $structure, $slot, $contexts, $pagevars, $pageurl) | |
Displays one question with the surrounding controls. | |
page_split_join_button ($structure, $slot) | |
Display an icon to split or join two pages of the quiz. | |
pix_url ($imagename, $component='moodle') | |
Return the direct URL for an image from the pix folder. | |
question (structure $structure, int $slot, moodle_url $pageurl) | |
Display a question. | |
question_bank_contents (\mod_quiz\question\bank\custom_view $questionbank, array $pagevars) | |
Return the contents of the question bank, to be displayed in the question-bank pop-up. | |
question_bank_loading () | |
Render the contents of the question bank pop-up in its initial state, when it just contains a loading progress indicator. | |
question_chooser () | |
Render the question type chooser dialogue. | |
question_dependency_icon ($structure, $slot) | |
Display the icon for whether this question can only be seen if the previous one has been answered. | |
question_move_icon (structure $structure, $slot) | |
Render the move icon. | |
question_name (structure $structure, $slot, $pageurl) | |
Renders html to display a name with the link to the question on a quiz edit page. | |
question_number (string $editablenumber, string $uncustomisednumber) | |
Output the question number. | |
question_preview_icon ($quiz, $questiondata, $label=null, $variant=null, $restartversion=null) | |
Render the preview icon. | |
question_remove_icon (structure $structure, $slot, $pageurl) | |
Render an icon to remove a question from the quiz. | |
question_row (structure $structure, $slot, $contexts, $pagevars, $pageurl) | |
Displays one question with the surrounding controls. | |
questions_in_section (structure $structure, $section, $contexts, $pagevars, $pageurl) | |
Renders HTML to display the questions in a section of the quiz. | |
quiz_information (structure $structure) | |
Render the status bar. | |
quiz_state_warnings (structure $structure) | |
Render any warnings that might be required about the state of the quiz, e.g. | |
random_question (structure $structure, $slotnumber, $pageurl) | |
Renders html to display a random question the link to edit the configuration and also to see that category in the question bank. | |
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. | |
render_question_chooser (renderable $chooser) | |
Renders the question chooser. | |
section_remove_icon ($section) | |
Render an icon to remove a section from the quiz. | |
section_shuffle_questions (structure $structure, $section) | |
Display a checkbox for shuffling question within a section. | |
should_display_main_logo ($headinglevel=1) | |
Whether we should display the main logo. | |
should_display_navbar_logo () | |
Whether we should display the logo in the navbar. | |
total_marks ($quiz) | |
Render the total marks available for the quiz. | |
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 | |
add_page_icon_template (structure $structure) | |
HTML for a page, with ids stripped, so it can be used as a javascript template. | |
add_question_form (structure $structure, $page, moodle_url $pageurl, array $pagevars) | |
Render the form that contains the data for adding a new question to the quiz. | |
end_section () | |
Display the end of a section, after the questions. | |
end_section_list () | |
Generate the closing container html for the end of a list of sections. | |
get_mustache () | |
Return an instance of the mustache class. | |
initialise_editing_javascript (structure $structure, core_question\local\bank\question_edit_contexts $contexts, array $pagevars, moodle_url $pageurl) | |
Initialise the JavaScript for the general editing. | |
new_page_template (structure $structure, core_question\local\bank\question_edit_contexts $contexts, array $pagevars, moodle_url $pageurl) | |
HTML for a page, with ids stripped, so it can be used as a javascript template. | |
repaginate_button (structure $structure, moodle_url $pageurl) | |
Return the repaginate button. | |
repaginate_form (structure $structure, moodle_url $pageurl) | |
Return the repaginate form. | |
selectmultiple_button (structure $structure) | |
Generate the bulk action button. | |
selectmultiple_controls (structure $structure) | |
Generate the controls that appear when the bulk action button is pressed. | |
start_section ($structure, $section) | |
Display the start of a section, before the questions. | |
start_section_list (structure $structure) | |
Generate the starting container html for the start of a list of sections. | |
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. | |
string | $togglegroup = 'quiz-questions' |
The toggle group name of the checkboxes for the toggle-all functionality. | |
Renderer outputting the quiz editing UI.
|
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 |
|
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\output\edit_renderer::add_menu_actions | ( | structure | $structure, |
$page, | |||
moodle_url | $pageurl, | ||
core_question\local\bank\question_edit_contexts | $contexts, | ||
array | $pagevars ) |
Returns the add menu that is output once per page.
structure | $structure | object containing the structure of the quiz. |
int | $page | the page number that this menu will add to. |
moodle_url | $pageurl | the canonical URL of this page. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
array | $pagevars | the variables from question_edit_setup(). |
string | HTML to output. |
|
protected |
HTML for a page, with ids stripped, so it can be used as a javascript template.
structure | $structure | object containing the structure of the quiz. |
string | HTML for a new icon |
|
protected |
Render the form that contains the data for adding a new question to the quiz.
structure | $structure | object containing the structure of the quiz. |
int | $page | the page number that this menu will add to. |
moodle_url | $pageurl | the canonical URL of this page. |
array | $pagevars | the variables from question_edit_setup(). |
string | HTML to output. |
mod_quiz\output\edit_renderer::edit_menu_actions | ( | structure | $structure, |
$page, | |||
moodle_url | $pageurl, | ||
array | $pagevars ) |
Returns the list of actions to go in the add menu.
structure | $structure | object containing the structure of the quiz. |
int | $page | the page number that this menu will add to. |
moodle_url | $pageurl | the canonical URL of this page. |
array | $pagevars | the variables from question_edit_setup(). |
array | the actions. |
mod_quiz\output\edit_renderer::edit_page | ( | \mod_quiz\quiz_settings | $quizobj, |
structure | $structure, | ||
core_question\local\bank\question_edit_contexts | $contexts, | ||
moodle_url | $pageurl, | ||
array | $pagevars ) |
Render the edit page.
mod_quiz\quiz_settings | $quizobj | object containing all the quiz settings information. |
structure | $structure | object containing the structure of the quiz. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
moodle_url | $pageurl | the canonical URL of this page. |
array | $pagevars | the variables from question_edit_setup(). |
string | HTML to output. |
|
protected |
Display the end of a section, after the questions.
string | HTML to output. |
|
protected |
Generate the closing container html for the end of a list of sections.
string | HTML to output. |
mod_quiz\output\edit_renderer::get_action_icon | ( | structure | $structure, |
int | $slot, | ||
moodle_url | $pageurl ) |
Get the action icons render.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the slot on the page we are outputting. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::get_checkbox_render | ( | structure | $structure, |
int | $slot ) |
Get the checkbox render.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the slot on the page we are outputting. |
string | HTML to output. |
|
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 |
mod_quiz\output\edit_renderer::get_question_name_for_slot | ( | structure | $structure, |
int | $slot, | ||
moodle_url | $pageurl ) |
Get the question name for the slot.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the slot on the page we are outputting. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
|
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 |
|
protected |
Initialise the JavaScript for the general editing.
(JavaScript for popups is handled with the specific code for those.)
structure | $structure | object containing the structure of the quiz. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
array | $pagevars | the variables from question_edit_setup(). |
moodle_url | $pageurl | the canonical URL of this page. |
bool | Always returns true |
mod_quiz\output\edit_renderer::marked_out_of_field | ( | structure | $structure, |
$slot ) |
Display the 'marked out of' information for a question.
Along with the regrade action.
structure | $structure | object containing the structure of the quiz. |
int | $slot | which slot we are outputting. |
string | HTML to output. |
mod_quiz\output\edit_renderer::maximum_grade_input | ( | $structure, | |
moodle_url | $pageurl ) |
Render the form for setting a quiz' overall grade.
structure | $structure | the quiz structure. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
|
protected |
HTML for a page, with ids stripped, so it can be used as a javascript template.
structure | $structure | object containing the structure of the quiz. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
array | $pagevars | the variables from question_edit_setup(). |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML for a new page. |
mod_quiz\output\edit_renderer::page_row | ( | structure | $structure, |
$slot, | |||
$contexts, | |||
$pagevars, | |||
$pageurl ) |
Displays one question with the surrounding controls.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the first slot on the page we are outputting. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
array | $pagevars | the variables from question_edit_setup(). |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::page_split_join_button | ( | $structure, | |
$slot ) |
Display an icon to split or join two pages of the quiz.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the first slot on the page we are outputting. |
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\output\edit_renderer::question | ( | structure | $structure, |
int | $slot, | ||
moodle_url | $pageurl ) |
Display a question.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the first slot on the page we are outputting. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::question_bank_contents | ( | \mod_quiz\question\bank\custom_view | $questionbank, |
array | $pagevars ) |
Return the contents of the question bank, to be displayed in the question-bank pop-up.
mod_quiz\question\bank\custom_view | $questionbank | the question bank view object. |
array | $pagevars | the variables from question_edit_setup(). |
string | HTML to output / send back in response to an AJAX request. |
mod_quiz\output\edit_renderer::question_bank_loading | ( | ) |
Render the contents of the question bank pop-up in its initial state, when it just contains a loading progress indicator.
string | HTML to output. |
mod_quiz\output\edit_renderer::question_chooser | ( | ) |
Render the question type chooser dialogue.
string | HTML to output. |
mod_quiz\output\edit_renderer::question_dependency_icon | ( | $structure, | |
$slot ) |
Display the icon for whether this question can only be seen if the previous one has been answered.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the first slot on the page we are outputting. |
string | HTML to output. |
mod_quiz\output\edit_renderer::question_move_icon | ( | structure | $structure, |
$slot ) |
Render the move icon.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the first slot on the page we are outputting. |
string | The markup for the move action. |
mod_quiz\output\edit_renderer::question_name | ( | structure | $structure, |
$slot, | |||
$pageurl ) |
Renders html to display a name with the link to the question on a quiz edit page.
If the user does not have permission to edi the question, it is rendered without a link
structure | $structure | object containing the structure of the quiz. |
int | $slot | which slot we are outputting. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::question_number | ( | string | $editablenumber, |
string | $uncustomisednumber ) |
Output the question number.
string | $editablenumber | The, which may be an in-place editable. |
string | $uncustomisednumber | The un-customised number number, or 'i'. |
string | HTML to output. |
mod_quiz\output\edit_renderer::question_preview_icon | ( | $quiz, | |
$questiondata, | |||
$label = null, | |||
$variant = null, | |||
$restartversion = null ) |
Render the preview icon.
stdClass | $quiz | the quiz settings from the database. |
stdClass | $questiondata | which question to preview. If ->questionid is set, that is used instead of ->id. |
bool | $label | if true, show the preview question label after the icon |
int | $variant | which question variant to preview (optional). |
int | $restartversion | version to use when restarting the preview |
string | HTML to output. |
mod_quiz\output\edit_renderer::question_remove_icon | ( | structure | $structure, |
$slot, | |||
$pageurl ) |
Render an icon to remove a question from the quiz.
structure | $structure | object containing the structure of the quiz. |
int | $slot | the first slot on the page we are outputting. |
moodle_url | $pageurl | the canonical URL of the edit page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::question_row | ( | structure | $structure, |
$slot, | |||
$contexts, | |||
$pagevars, | |||
$pageurl ) |
Displays one question with the surrounding controls.
structure | $structure | object containing the structure of the quiz. |
int | $slot | which slot we are outputting. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
array | $pagevars | the variables from question_edit_setup(). |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::questions_in_section | ( | structure | $structure, |
$section, | |||
$contexts, | |||
$pagevars, | |||
$pageurl ) |
Renders HTML to display the questions in a section of the quiz.
This function calls core_course_renderer::quiz_section_question()
structure | $structure | object containing the structure of the quiz. |
stdClass | $section | information about the section. |
core_question\local\bank\question_edit_contexts | $contexts | the relevant question bank contexts. |
array | $pagevars | the variables from question_edit_setup(). |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::quiz_information | ( | structure | $structure | ) |
Render the status bar.
structure | $structure | the quiz structure. |
string | HTML to output. |
mod_quiz\output\edit_renderer::quiz_state_warnings | ( | structure | $structure | ) |
Render any warnings that might be required about the state of the quiz, e.g.
if it has been attempted, or if the shuffle questions option is turned on.
structure | $structure | the quiz structure. |
string | HTML to output. |
mod_quiz\output\edit_renderer::random_question | ( | structure | $structure, |
$slotnumber, | |||
$pageurl ) |
Renders html to display a random question the link to edit the configuration and also to see that category in the question bank.
structure | $structure | object containing the structure of the quiz. |
int | $slotnumber | which slot we are outputting. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
|
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 core_courseformat\output\section_renderer, and 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 |
mod_quiz\output\edit_renderer::render_question_chooser | ( | renderable | $chooser | ) |
Renders the question chooser.
renderable |
string |
|
protected |
Return the repaginate button.
structure | $structure | the structure of the quiz being edited. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
|
protected |
Return the repaginate form.
structure | $structure | the structure of the quiz being edited. |
moodle_url | $pageurl | the canonical URL of this page. |
string | HTML to output. |
mod_quiz\output\edit_renderer::section_remove_icon | ( | $section | ) |
Render an icon to remove a section from the quiz.
stdClass | $section | the section to be removed. |
string | HTML to output. |
mod_quiz\output\edit_renderer::section_shuffle_questions | ( | structure | $structure, |
$section ) |
Display a checkbox for shuffling question within a section.
structure | $structure | object containing the structure of the quiz. |
stdClass | $section | data from the quiz_section table. |
string | HTML to output. |
|
protected |
Generate the bulk action button.
structure | $structure | the structure of the quiz being edited. |
string | HTML to output. |
|
protected |
Generate the controls that appear when the bulk action button is pressed.
structure | $structure | the structure of the quiz being edited. |
string | HTML to output. |
|
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 |
|
protected |
Display the start of a section, before the questions.
structure | $structure | the structure of the quiz being edited. |
stdClass | $section | The quiz_section entry from DB |
string | HTML to output. |
|
protected |
Generate the starting container html for the start of a list of sections.
structure | $structure | the structure of the quiz being edited. |
string | HTML to output. |
mod_quiz\output\edit_renderer::total_marks | ( | $quiz | ) |
Render the total marks available for the quiz.
stdClass | $quiz | the quiz settings from the database. |
string | HTML to output. |
|
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