Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mod_quiz\output\edit_renderer Class Reference

Renderer outputting the quiz editing UI. More...

Inheritance diagram for mod_quiz\output\edit_renderer:
plugin_renderer_base renderer_base

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...
 
 add_action_handler (component_action $action, $id=null)
 Adds a JS action for the element with the provided id. More...
 
 add_menu_actions (structure $structure, $page, moodle_url $pageurl, question_edit_contexts $contexts, array $pagevars)
 Returns the add menu that is output once per page. More...
 
 edit_menu_actions (structure $structure, $page, moodle_url $pageurl, array $pagevars)
 Returns the list of actions to go in the add menu. More...
 
 edit_page (\quiz $quizobj, structure $structure, question_edit_contexts $contexts, moodle_url $pageurl, array $pagevars)
 Render the edit page. 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...
 
 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...
 
 marked_out_of_field (structure $structure, $slot)
 Display the 'marked out of' information for a question. More...
 
 maximum_grade_input ($structure, moodle_url $pageurl)
 Render the form for setting a quiz' overall grade. More...
 
 page_row (structure $structure, $slot, $contexts, $pagevars, $pageurl)
 Displays one question with the surrounding controls. More...
 
 page_split_join_button ($structure, $slot)
 Display an icon to split or join two pages of the quiz. More...
 
 pix_url ($imagename, $component='moodle')
 Return the direct URL for an image from the pix folder. More...
 
 question (structure $structure, $slot, moodle_url $pageurl)
 Display a question. More...
 
 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. More...
 
 question_bank_loading ()
 Render the contents of the question bank pop-up in its initial state, when it just contains a loading progress indicator. More...
 
 question_chooser ()
 Render the question type chooser dialogue. More...
 
 question_dependency_icon ($structure, $slot)
 Display the icon for whether this question can only be seen if the previous one has been answered. More...
 
 question_move_icon (structure $structure, $slot)
 Render the move icon. More...
 
 question_name (structure $structure, $slot, $pageurl)
 Renders html to display a name with the link to the question on a quiz edit page. More...
 
 question_number ($number)
 Output the question number. More...
 
 question_preview_icon ($quiz, $question, $label=null, $variant=null)
 Render the preview icon. More...
 
 question_remove_icon (structure $structure, $slot, $pageurl)
 Render an icon to remove a question from the quiz. More...
 
 question_row (structure $structure, $slot, $contexts, $pagevars, $pageurl)
 Displays one question with the surrounding controls. More...
 
 questions_in_section (structure $structure, $section, $contexts, $pagevars, $pageurl)
 Renders HTML to display the questions in a section of the quiz. More...
 
 quiz_information (structure $structure)
 Render the status bar. More...
 
 quiz_state_warnings (structure $structure)
 Render any warnings that might be required about the state of the quiz, e.g. More...
 
 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. 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...
 
 render_question_chooser (renderable $chooser)
 Renders the question chooser. More...
 
 section_remove_icon ($section)
 Render an icon to remove a section from the quiz. More...
 
 section_shuffle_questions (structure $structure, $section)
 Display a checkbox for shuffling question within a section. 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...
 
 total_marks ($quiz)
 Render the total marks available for the quiz. More...
 

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

 add_page_icon_template (structure $structure)
 HTML for a page, with ids stripped, so it can be used as a javascript template. More...
 
 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. More...
 
 end_section ()
 Display the end of a section, after the questions. More...
 
 end_section_list ()
 Generate the closing container html for the end of a list of sections. More...
 
 get_mustache ()
 Return an instance of the mustache class. More...
 
 initialise_editing_javascript (structure $structure, question_edit_contexts $contexts, array $pagevars, moodle_url $pageurl)
 Initialise the JavaScript for the general editing. More...
 
 new_page_template (structure $structure, 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. More...
 
 repaginate_button (structure $structure, moodle_url $pageurl)
 Return the repaginate button. More...
 
 repaginate_form (structure $structure, moodle_url $pageurl)
 Return the repaginate form. More...
 
 selectmultiple_button (structure $structure)
 Generate the bulk action button. More...
 
 selectmultiple_controls (structure $structure)
 Generate the controls that appear when the bulk action button is pressed. More...
 
 start_section ($structure, $section)
 Display the start of a section, before the questions. More...
 
 start_section_list (structure $structure)
 Generate the starting container html for the start of a list of sections. 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.
 
string $togglegroup = 'quiz-questions'
 The toggle group name of the checkboxes for the toggle-all functionality.
 

Detailed Description

Renderer outputting the quiz editing UI.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 2.7

Member Function Documentation

◆ __call()

plugin_renderer_base::__call (   $method,
  $arguments 
)
inherited

Magic method used to pass calls otherwise meant for the standard renderer to it to ensure we don't go causing unnecessary grief.

Parameters
string$method
array$arguments
Return values
mixed

◆ add_action_handler()

renderer_base::add_action_handler ( component_action  $action,
  $id = null 
)
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()

Parameters
component_action$action
string$id
Return values
stringid of element, either original submitted or random new if not supplied

◆ add_menu_actions()

mod_quiz\output\edit_renderer::add_menu_actions ( structure  $structure,
  $page,
moodle_url  $pageurl,
question_edit_contexts  $contexts,
array  $pagevars 
)

Returns the add menu that is output once per page.

Parameters
structure$structureobject containing the structure of the quiz.
int$pagethe page number that this menu will add to.
moodle_url$pageurlthe canonical URL of this page.
question_edit_contexts$contextsthe relevant question bank contexts.
array$pagevarsthe variables from question_edit_setup().
Return values
stringHTML to output.

◆ add_page_icon_template()

mod_quiz\output\edit_renderer::add_page_icon_template ( structure  $structure)
protected

HTML for a page, with ids stripped, so it can be used as a javascript template.

Parameters
structure$structureobject containing the structure of the quiz.
Return values
stringHTML for a new icon

◆ add_question_form()

mod_quiz\output\edit_renderer::add_question_form ( structure  $structure,
  $page,
moodle_url  $pageurl,
array  $pagevars 
)
protected

Render the form that contains the data for adding a new question to the quiz.

Parameters
structure$structureobject containing the structure of the quiz.
int$pagethe page number that this menu will add to.
moodle_url$pageurlthe canonical URL of this page.
array$pagevarsthe variables from question_edit_setup().
Return values
stringHTML to output.

◆ edit_menu_actions()

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.

Parameters
structure$structureobject containing the structure of the quiz.
int$pagethe page number that this menu will add to.
moodle_url$pageurlthe canonical URL of this page.
array$pagevarsthe variables from question_edit_setup().
Return values
arraythe actions.

◆ edit_page()

mod_quiz\output\edit_renderer::edit_page ( \quiz  $quizobj,
structure  $structure,
question_edit_contexts  $contexts,
moodle_url  $pageurl,
array  $pagevars 
)

Render the edit page.

Parameters
quiz$quizobjobject containing all the quiz settings information.
structure$structureobject containing the structure of the quiz.
question_edit_contexts$contextsthe relevant question bank contexts.
moodle_url$pageurlthe canonical URL of this page.
array$pagevarsthe variables from question_edit_setup().
Return values
stringHTML to output.

◆ end_section()

mod_quiz\output\edit_renderer::end_section ( )
protected

Display the end of a section, after the questions.

Return values
stringHTML to output.

◆ end_section_list()

mod_quiz\output\edit_renderer::end_section_list ( )
protected

Generate the closing container html for the end of a list of sections.

Return values
stringHTML to output.

◆ get_compact_logo_url()

renderer_base::get_compact_logo_url (   $maxwidth = 300,
  $maxheight = 300 
)
inherited

Return the site's compact logo URL, if any.

Parameters
int$maxwidthThe maximum width, or null when the maximum width does not matter.
int$maxheightThe maximum height, or null when the maximum height does not matter.
Return values
moodle_url|false

◆ get_logo_url()

renderer_base::get_logo_url (   $maxwidth = null,
  $maxheight = 200 
)
inherited

Return the site's logo URL, if any.

Parameters
int$maxwidthThe maximum width, or null when the maximum width does not matter.
int$maxheightThe maximum height, or null when the maximum height does not matter.
Return values
moodle_url|false

◆ get_mustache()

renderer_base::get_mustache ( )
protectedinherited

Return an instance of the mustache class.

Since
2.9
Return values
Mustache_Engine

◆ has_started()

renderer_base::has_started ( )
inherited

Returns true is output has already started, and false if not.

Return values
booleantrue if the header has been printed.

◆ image_url()

renderer_base::image_url (   $imagename,
  $component = 'moodle' 
)
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')

Parameters
string$imagenamethe pathname of the image
string$componentfull plugin name (aka component) or 'theme'
Return values
moodle_url

◆ initialise_editing_javascript()

mod_quiz\output\edit_renderer::initialise_editing_javascript ( structure  $structure,
question_edit_contexts  $contexts,
array  $pagevars,
moodle_url  $pageurl 
)
protected

Initialise the JavaScript for the general editing.

(JavaScript for popups is handled with the specific code for those.)

Parameters
structure$structureobject containing the structure of the quiz.
question_edit_contexts$contextsthe relevant question bank contexts.
array$pagevarsthe variables from question_edit_setup().
moodle_url$pageurlthe canonical URL of this page.
Return values
boolAlways returns true

◆ marked_out_of_field()

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.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotwhich slot we are outputting.
Return values
stringHTML to output.

◆ maximum_grade_input()

mod_quiz\output\edit_renderer::maximum_grade_input (   $structure,
moodle_url  $pageurl 
)

Render the form for setting a quiz' overall grade.

Parameters
structure$structurethe quiz structure.
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ new_page_template()

mod_quiz\output\edit_renderer::new_page_template ( structure  $structure,
question_edit_contexts  $contexts,
array  $pagevars,
moodle_url  $pageurl 
)
protected

HTML for a page, with ids stripped, so it can be used as a javascript template.

Parameters
structure$structureobject containing the structure of the quiz.
question_edit_contexts$contextsthe relevant question bank contexts.
array$pagevarsthe variables from question_edit_setup().
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML for a new page.

◆ page_row()

mod_quiz\output\edit_renderer::page_row ( structure  $structure,
  $slot,
  $contexts,
  $pagevars,
  $pageurl 
)

Displays one question with the surrounding controls.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotthe first slot on the page we are outputting.
question_edit_contexts$contextsthe relevant question bank contexts.
array$pagevarsthe variables from question_edit_setup().
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ page_split_join_button()

mod_quiz\output\edit_renderer::page_split_join_button (   $structure,
  $slot 
)

Display an icon to split or join two pages of the quiz.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotthe first slot on the page we are outputting.
Return values
stringHTML to output.

◆ pix_url()

renderer_base::pix_url (   $imagename,
  $component = 'moodle' 
)
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.

Deprecated:
since Moodle 3.3
Parameters
string$imagenamethe name of the icon.
string$componentspecification of one plugin like in get_string()
Return values
moodle_url

◆ prepare_classes()

static renderer_base::prepare_classes (   $classes)
staticinherited

Given an array or space-separated list of classes, prepares and returns the HTML class attribute value.

Parameters
mixed$classesSpace-separated string or array of classes
Return values
stringHTML class attribute value

◆ question()

mod_quiz\output\edit_renderer::question ( structure  $structure,
  $slot,
moodle_url  $pageurl 
)

Display a question.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotthe first slot on the page we are outputting.
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ question_bank_contents()

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.

Parameters
mod_quiz::question::bank::custom_view$questionbankthe question bank view object.
array$pagevarsthe variables from question_edit_setup().
Return values
stringHTML to output / send back in response to an AJAX request.

◆ question_bank_loading()

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.

Return values
stringHTML to output.

◆ question_chooser()

mod_quiz\output\edit_renderer::question_chooser ( )

Render the question type chooser dialogue.

Return values
stringHTML to output.

◆ question_dependency_icon()

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.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotthe first slot on the page we are outputting.
Return values
stringHTML to output.

◆ question_move_icon()

mod_quiz\output\edit_renderer::question_move_icon ( structure  $structure,
  $slot 
)

Render the move icon.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotthe first slot on the page we are outputting.
Return values
stringThe markup for the move action.

◆ question_name()

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

Parameters
structure$structureobject containing the structure of the quiz.
int$slotwhich slot we are outputting.
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ question_number()

mod_quiz\output\edit_renderer::question_number (   $number)

Output the question number.

Parameters
string$numberThe number, or 'i'.
Return values
stringHTML to output.

◆ question_preview_icon()

mod_quiz\output\edit_renderer::question_preview_icon (   $quiz,
  $question,
  $label = null,
  $variant = null 
)

Render the preview icon.

Parameters
stdClass$quizthe quiz settings from the database.
stdClass$questiondata from the question and quiz_slots tables.
bool$labelif true, show the preview question label after the icon
int$variantwhich question variant to preview (optional).
Return values
stringHTML to output.

◆ question_remove_icon()

mod_quiz\output\edit_renderer::question_remove_icon ( structure  $structure,
  $slot,
  $pageurl 
)

Render an icon to remove a question from the quiz.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotthe first slot on the page we are outputting.
moodle_url$pageurlthe canonical URL of the edit page.
Return values
stringHTML to output.

◆ question_row()

mod_quiz\output\edit_renderer::question_row ( structure  $structure,
  $slot,
  $contexts,
  $pagevars,
  $pageurl 
)

Displays one question with the surrounding controls.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotwhich slot we are outputting.
question_edit_contexts$contextsthe relevant question bank contexts.
array$pagevarsthe variables from question_edit_setup().
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ questions_in_section()

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()

Parameters
structure$structureobject containing the structure of the quiz.
stdClass$sectioninformation about the section.
question_edit_contexts$contextsthe relevant question bank contexts.
array$pagevarsthe variables from question_edit_setup().
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ quiz_information()

mod_quiz\output\edit_renderer::quiz_information ( structure  $structure)

Render the status bar.

Parameters
structure$structurethe quiz structure.
Return values
stringHTML to output.

◆ quiz_state_warnings()

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.

Parameters
structure$structurethe quiz structure.
Return values
stringHTML to output.

◆ random_question()

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.

Parameters
structure$structureobject containing the structure of the quiz.
int$slotnumberwhich slot we are outputting.
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ render()

plugin_renderer_base::render ( renderable  $widget)
inherited

Renders the provided widget and returns the HTML to display it.

Parameters
renderable$widgetinstance with renderable interface
Return values
string

Reimplemented from renderer_base.

Reimplemented in tool_policy\output\renderer.

◆ render_from_template()

renderer_base::render_from_template (   $templatename,
  $context 
)
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

Since
2.9
Parameters
array | stdClass$contextContext containing data for the template.
Return values
string|boolean

◆ render_question_chooser()

mod_quiz\output\edit_renderer::render_question_chooser ( renderable  $chooser)

Renders the question chooser.

Parameters
renderable
Return values
string

◆ repaginate_button()

mod_quiz\output\edit_renderer::repaginate_button ( structure  $structure,
moodle_url  $pageurl 
)
protected

Return the repaginate button.

Parameters
structure$structurethe structure of the quiz being edited.
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ repaginate_form()

mod_quiz\output\edit_renderer::repaginate_form ( structure  $structure,
moodle_url  $pageurl 
)
protected

Return the repaginate form.

Parameters
structure$structurethe structure of the quiz being edited.
moodle_url$pageurlthe canonical URL of this page.
Return values
stringHTML to output.

◆ section_remove_icon()

mod_quiz\output\edit_renderer::section_remove_icon (   $section)

Render an icon to remove a section from the quiz.

Parameters
object$sectionthe section to be removed.
Return values
stringHTML to output.

◆ section_shuffle_questions()

mod_quiz\output\edit_renderer::section_shuffle_questions ( structure  $structure,
  $section 
)

Display a checkbox for shuffling question within a section.

Parameters
structure$structureobject containing the structure of the quiz.
stdClass$sectiondata from the quiz_section table.
Return values
stringHTML to output.

◆ selectmultiple_button()

mod_quiz\output\edit_renderer::selectmultiple_button ( structure  $structure)
protected

Generate the bulk action button.

Parameters
structure$structurethe structure of the quiz being edited.
Return values
stringHTML to output.

◆ selectmultiple_controls()

mod_quiz\output\edit_renderer::selectmultiple_controls ( structure  $structure)
protected

Generate the controls that appear when the bulk action button is pressed.

Parameters
structure$structurethe structure of the quiz being edited.
Return values
stringHTML to output.

◆ should_display_main_logo()

renderer_base::should_display_main_logo (   $headinglevel = 1)
inherited

Whether we should display the main logo.

Parameters
int$headinglevelThe heading level we want to check against.
Return values
bool

◆ should_display_navbar_logo()

renderer_base::should_display_navbar_logo ( )
inherited

Whether we should display the logo in the navbar.

We will when there are no main logos, and we have compact logo.

Return values
bool

◆ start_section()

mod_quiz\output\edit_renderer::start_section (   $structure,
  $section 
)
protected

Display the start of a section, before the questions.

Parameters
structure$structurethe structure of the quiz being edited.
stdClass$sectionThe quiz_section entry from DB
Return values
stringHTML to output.

◆ start_section_list()

mod_quiz\output\edit_renderer::start_section_list ( structure  $structure)
protected

Generate the starting container html for the start of a list of sections.

Parameters
structure$structurethe structure of the quiz being edited.
Return values
stringHTML to output.

◆ total_marks()

mod_quiz\output\edit_renderer::total_marks (   $quiz)

Render the total marks available for the quiz.

Parameters
stdClass$quizthe quiz settings from the database.
Return values
stringHTML to output.

Member Data Documentation

◆ $output

renderer_base core_renderer plugin_renderer_base::$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


The documentation for this class was generated from the following file: