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

Subclass to customise the view of the question bank for the quiz editing screen. More...

Inheritance diagram for mod_quiz\question\bank\custom_view:
core_question\bank\view

Public Member Functions

 __construct ($contexts, $pageurl, $course, $cm, $quiz)
 Constructor. More...
 
 add_searchcondition ($searchcondition)
 Add another search control to this view. More...
 
 add_to_quiz_url ($questionid)
 
 base_url ()
 
 copy_question_moodle_url ($questionid)
 Get the URL for duplicating a question as a moodle_url. More...
 
 copy_question_url ($questionid)
 Get the URL for duplicating a given question. More...
 
 display ($tabname, $page, $perpage, $cat, $recurse, $showhidden, $showquestiontext, $tagids=[])
 Shows the question bank editing interface. More...
 
 edit_question_moodle_url ($questionid)
 Get the URL for editing a question as a moodle_url. More...
 
 edit_question_url ($questionid)
 Get the URL for editing a question as a HTML-escaped string. More...
 
 get_column_count ()
 
 get_courseid ()
 
 get_most_specific_context ()
 Get the context we are displaying the question bank for. More...
 
 get_primary_sort_order ($sort)
 
 has_column ($colname)
 
 new_sort_url ($sort, $newsortreverse)
 Get a URL to redisplay the page with a new sort for the question bank. More...
 
 preview_question_url ($question)
 Get the URL to preview a question. More...
 
 process_actions ()
 
 process_actions_needing_ui ()
 
 render ($tabname, $page, $perpage, $cat, $recurse, $showhidden, $showquestiontext, $tagids=[])
 Renders the html question bank (same as display, but returns the result). More...
 
 set_quiz_has_attempts ($quizhasattempts)
 Let the question bank display know whether the quiz has been attempted, hence whether some bits of UI, like the add this question to the quiz icon, should be displayed. More...
 

Public Attributes

const MAX_SORTS = 3
 
int const MAX_TEXT_LENGTH = 200
 The maximum displayed length of the category info.
 

Protected Member Functions

 build_query ()
 Create the SQL query to retrieve the indicated questions, based on core_question::bank::search::condition filters.
 
 build_query_sql ($category, $recurse, $showhidden)
 Create the SQL query to retrieve the indicated questions. More...
 
 create_new_question_form ($category, $canadd)
 
 default_sort ()
 
 display_advanced_search_form ()
 Print the "advanced" UI elements for the form to select which questions. More...
 
 display_bottom_controls ($totalnumber, $recurse, $category, context $catcontext, array $addcontexts)
 Display the controls at the bottom of the list of questions. More...
 
 display_category_form ($contexts, $pageurl, $current)
 Prints a form to choose categories. More...
 
 display_category_form_checkbox ($name, $value, $label)
 Print a single option checkbox. More...
 
 display_options ($recurse, $showhidden, $showquestiontext)
 Display the options form. More...
 
 display_options_form ($showquestiontext, $scriptpath='/mod/quiz/edit.php', $showtextoption=false)
 Display the form with options for which questions are displayed and how they are displayed. More...
 
 display_question_bank_header ()
 Override the base implementation in core_question::bank::view because we don't want to print the headers in the fragment for the modal. More...
 
 display_question_list ($contexts, $pageurl, $categoryandcontext, $cm=null, $recurse=1, $page=0, $perpage=100, $showhidden=false, $showquestiontext=false, $addcontexts=array())
 Prints the table of questions in a category with interactions. More...
 
 display_showtext_checkbox ($showquestiontext)
 Display the checkbox UI for toggling the display of the question text in the list. More...
 
 end_table ()
 
 get_column_type ($columnname)
 Get a column object from its name. More...
 
 get_current_category ($categoryandcontext)
 
 get_question_count ()
 
 get_row_classes ($question, $rowcount)
 
 heading_column ()
 Specify the column heading. More...
 
 init_columns ($wanted, $heading='')
 Initializing table columns. More...
 
 init_search_conditions ()
 Initialize search conditions from plugins local_*_get_question_bank_search_conditions() must return an array of core_question::bank::search::condition objects.
 
 init_sort ()
 
 init_sort_from_params ()
 Override the base implementation in core_question::bank::view because we don't want it to read from the $_POST global variables for the sort parameters since they are not present in a fragment. More...
 
 load_page_questions ($page, $perpage)
 Load the questions we need to display. More...
 
 parse_subsort ($sort)
 Deal with a sort name of the form columnname, or colname_subsort by breaking it up, validating the bits that are present, and returning them. More...
 
 print_category_info ($category)
 prints category information More...
 
 print_choose_category_message ($categoryandcontext)
 Prints a form to choose categories. More...
 
 print_table_headers ()
 
 print_table_row ($question, $rowcount)
 
 sort_to_params ($sorts)
 
 start_table ()
 
 wanted_columns ()
 

Protected Attributes

moodle_url $baseurl
 base URL for the current page. More...
 
object cm_info null $cm
 if we are in a module context, the cm.
 
question_edit_contexts $contexts
 
string $countsql
 SQL to count the number of questions matching the current search conditions.
 
object $course
 the course we are within.
 
moodle_url $editquestionurl
 used as a basis for URLs that edit a question.
 
question_bank_column_base[] $extrarows
 these are the 'columns' that are actually displayed as an additional row (e.g. More...
 
int null $lastchangedid
 id of the a question to highlight in the list (if present).
 
string $loadsql
 SQL to actually load the question data to display.
 
stdClass $quiz = false
 the quiz settings.
 
bool $quizhasattempts = false
 whether the quiz this is used by has been attemptd.
 
question_bank_column_base[] $requiredcolumns
 these are all the 'columns' that are part of the display. More...
 
condition[] $searchconditions = array()
 search conditions.
 
array $sort
 list of column class names for which columns to sort on.
 
array $sqlparams
 params used by $countsql and $loadsql (which currently must be the same).
 
question_bank_column_base[] $visiblecolumns
 these are the 'columns' that are actually displayed as a column, in order. More...
 

Detailed Description

Subclass to customise the view of the question bank for the quiz editing screen.

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

Constructor & Destructor Documentation

◆ __construct()

mod_quiz\question\bank\custom_view::__construct (   $contexts,
  $pageurl,
  $course,
  $cm,
  $quiz 
)

Constructor.

Parameters
question_edit_contexts$contexts
moodle_url$pageurl
stdClass$coursecourse settings
stdClass$cmactivity settings.
stdClass$quizquiz settings.

Member Function Documentation

◆ add_searchcondition()

core_question\bank\view::add_searchcondition (   $searchcondition)
inherited

Add another search control to this view.

Parameters
condition$searchconditionthe condition to add.

◆ build_query_sql()

core_question\bank\view::build_query_sql (   $category,
  $recurse,
  $showhidden 
)
protectedinherited

Create the SQL query to retrieve the indicated questions.

Parameters
stdClass$categoryno longer used.
bool$recurseno longer used.
bool$showhiddenno longer used.
Deprecated:
since Moodle 2.7 MDL-40313.
See also
build_query()
core_question::bank::search::condition
Todo:
MDL-41978 This will be deleted in Moodle 2.8

◆ copy_question_moodle_url()

core_question\bank\view::copy_question_moodle_url (   $questionid)
inherited

Get the URL for duplicating a question as a moodle_url.

Parameters
int$questionidthe question id.
Return values
moodle_urlthe URL.

◆ copy_question_url()

core_question\bank\view::copy_question_url (   $questionid)
inherited

Get the URL for duplicating a given question.

Parameters
int$questionidthe question id.
Return values
stringthe URL, HTML-escaped.

◆ create_new_question_form()

mod_quiz\question\bank\custom_view::create_new_question_form (   $category,
  $canadd 
)
protected

Reimplemented from core_question\bank\view.

◆ default_sort()

mod_quiz\question\bank\custom_view::default_sort ( )
protected

Reimplemented from core_question\bank\view.

◆ display()

core_question\bank\view::display (   $tabname,
  $page,
  $perpage,
  $cat,
  $recurse,
  $showhidden,
  $showquestiontext,
  $tagids = [] 
)
inherited

Shows the question bank editing interface.

The function also processes a number of actions:

Actions affecting the question pool: move Moves a question to a different category deleteselected Deletes the selected questions from the category Other actions: category Chooses the category

Parameters
string$tabnamequestion bank edit tab name, for permission checking.
int$pagethe page number to show.
int$perpagethe number of questions per page to show.
string$cat'categoryid,contextid'.
int$recurseWhether to include subcategories.
bool$showhiddenwhether deleted questions should be displayed.
bool$showquestiontextwhether the text of each question should be shown in the list. Deprecated.
array$tagidscurrent list of selected tags.

◆ display_advanced_search_form()

core_question\bank\view::display_advanced_search_form ( )
protectedinherited

Print the "advanced" UI elements for the form to select which questions.

Hidden by default.

◆ display_bottom_controls()

mod_quiz\question\bank\custom_view::display_bottom_controls (   $totalnumber,
  $recurse,
  $category,
context  $catcontext,
array  $addcontexts 
)
protected

Display the controls at the bottom of the list of questions.

Parameters
int$totalnumberTotal number of questions that might be shown (if it was not for paging).
bool$recurseWhether to include subcategories.
stdClass$categoryThe question_category row from the database.
context$catcontextThe context of the category being displayed.
array$addcontextscontexts where the user is allowed to add new questions.

Reimplemented from core_question\bank\view.

◆ display_category_form()

core_question\bank\view::display_category_form (   $contexts,
  $pageurl,
  $current 
)
protectedinherited

Prints a form to choose categories.

Deprecated:
since Moodle 2.7 MDL-40313.
See also
core_question::bank::search::condition
Todo:
MDL-41978 This will be deleted in Moodle 2.8

◆ display_category_form_checkbox()

core_question\bank\view::display_category_form_checkbox (   $name,
  $value,
  $label 
)
protectedinherited

Print a single option checkbox.

Deprecated:
since Moodle 2.7 MDL-40313.
See also
core_question::bank::search::condition
html_writer::checkbox
Todo:
MDL-41978 This will be deleted in Moodle 2.8

◆ display_options()

mod_quiz\question\bank\custom_view::display_options (   $recurse,
  $showhidden,
  $showquestiontext 
)
protected

Display the options form.

Parameters
bool$recurseno longer used.
bool$showhiddenno longer used.
bool$showquestiontextwhether to show the question text.
Deprecated:
since Moodle 2.7 MDL-40313.
See also
display_options_form
Todo:
MDL-41978 This will be deleted in Moodle 2.8
See also
core_question::bank::search::condition

Reimplemented from core_question\bank\view.

◆ display_options_form()

mod_quiz\question\bank\custom_view::display_options_form (   $showquestiontext,
  $scriptpath = '/mod/quiz/edit.php',
  $showtextoption = false 
)
protected

Display the form with options for which questions are displayed and how they are displayed.

Parameters
bool$showquestiontextDisplay the text of the question within the list.
string$scriptpathpath to the script displaying this page.
bool$showtextoptionwhether to include the 'Show question text' checkbox.

Reimplemented from core_question\bank\view.

◆ display_question_bank_header()

mod_quiz\question\bank\custom_view::display_question_bank_header ( )
protected

Override the base implementation in core_question::bank::view because we don't want to print the headers in the fragment for the modal.

Reimplemented from core_question\bank\view.

◆ display_question_list()

core_question\bank\view::display_question_list (   $contexts,
  $pageurl,
  $categoryandcontext,
  $cm = null,
  $recurse = 1,
  $page = 0,
  $perpage = 100,
  $showhidden = false,
  $showquestiontext = false,
  $addcontexts = array() 
)
protectedinherited

Prints the table of questions in a category with interactions.

Parameters
array$contextsNot used!
moodle_url$pageurlThe URL to reload this page.
string$categoryandcontext'categoryID,contextID'.
stdClass$cmNot used!
int$recurseWhether to include subcategories.
int$pageThe number of the page to be displayed
int$perpageNumber of questions to show per page
bool$showhiddenNot used! This is now controlled in a different way.
bool$showquestiontextNot used! This is now controlled in a different way.
array$addcontextscontexts where the user is allowed to add new questions.

◆ display_showtext_checkbox()

core_question\bank\view::display_showtext_checkbox (   $showquestiontext)
protectedinherited

Display the checkbox UI for toggling the display of the question text in the list.

Parameters
bool$showquestiontextthe current or default value for whether to display the text.

◆ edit_question_moodle_url()

core_question\bank\view::edit_question_moodle_url (   $questionid)
inherited

Get the URL for editing a question as a moodle_url.

Parameters
int$questionidthe question id.
Return values
moodle_urlthe URL, HTML-escaped.

◆ edit_question_url()

core_question\bank\view::edit_question_url (   $questionid)
inherited

Get the URL for editing a question as a HTML-escaped string.

Parameters
int$questionidthe question id.
Return values
stringthe URL, HTML-escaped.

◆ get_column_count()

core_question\bank\view::get_column_count ( )
inherited
Return values
intThe number of columns in the table.

◆ get_column_type()

core_question\bank\view::get_column_type (   $columnname)
protectedinherited

Get a column object from its name.

Parameters
string$columnname,.
Return values
core_question::bank::column_base.

◆ get_most_specific_context()

core_question\bank\view::get_most_specific_context ( )
inherited

Get the context we are displaying the question bank for.

Return values
contextcontext object.

◆ get_primary_sort_order()

core_question\bank\view::get_primary_sort_order (   $sort)
inherited
Parameters
string$sorta column or column_subsort name.
Return values
intthe current sort order for this column -1, 0, 1

◆ has_column()

core_question\bank\view::has_column (   $colname)
inherited
Parameters
string$colnamea column internal name.
Return values
boolis this column included in the output?

◆ heading_column()

mod_quiz\question\bank\custom_view::heading_column ( )
protected

Specify the column heading.

Return values
stringColumn name for the heading

Reimplemented from core_question\bank\view.

◆ init_columns()

core_question\bank\view::init_columns (   $wanted,
  $heading = '' 
)
protectedinherited

Initializing table columns.

Parameters
array$wantedCollection of column names
string$headingThe name of column that is set as heading

◆ init_sort_from_params()

mod_quiz\question\bank\custom_view::init_sort_from_params ( )
protected

Override the base implementation in core_question::bank::view because we don't want it to read from the $_POST global variables for the sort parameters since they are not present in a fragment.

Unfortunately the best we can do is to look at the URL for those parameters (only marginally better really).

Reimplemented from core_question\bank\view.

◆ load_page_questions()

core_question\bank\view::load_page_questions (   $page,
  $perpage 
)
protectedinherited

Load the questions we need to display.

Parameters
int$pagepage to display.
int$perpagenumber of questions per page.
Return values
moodle_recordsetquestionid => data about each question.

◆ new_sort_url()

core_question\bank\view::new_sort_url (   $sort,
  $newsortreverse 
)
inherited

Get a URL to redisplay the page with a new sort for the question bank.

Parameters
string$sortthe column, or column_subsort to sort on.
bool$newsortreversewhether to sort in reverse order.
Return values
stringThe new URL.

◆ parse_subsort()

core_question\bank\view::parse_subsort (   $sort)
protectedinherited

Deal with a sort name of the form columnname, or colname_subsort by breaking it up, validating the bits that are present, and returning them.

If there is no subsort, then $subsort is returned as ''.

Parameters
string$sortthe sort parameter to process.
Return values
arrayarray($colname, $subsort).

◆ preview_question_url()

mod_quiz\question\bank\custom_view::preview_question_url (   $questiondata)

Get the URL to preview a question.

Parameters
stdClass$questiondatathe data defining the question.
Return values
moodle_urlthe URL.

Reimplemented from core_question\bank\view.

◆ print_category_info()

mod_quiz\question\bank\custom_view::print_category_info (   $category)
protected

prints category information

Parameters
stdClass$categorythe category row from the database.
Deprecated:
since Moodle 2.7 MDL-40313.
See also
core_question::bank::search::condition
Todo:
MDL-41978 This will be deleted in Moodle 2.8

Reimplemented from core_question\bank\view.

◆ print_choose_category_message()

mod_quiz\question\bank\custom_view::print_choose_category_message (   $categoryandcontext)
protected

Prints a form to choose categories.

Parameters
string$categoryandcontext'categoryID,contextID'.
Deprecated:
since Moodle 2.6 MDL-40313.
See also
core_question::bank::search::category_condition
Todo:
MDL-41978 This will be deleted in Moodle 2.8

Reimplemented from core_question\bank\view.

◆ render()

mod_quiz\question\bank\custom_view::render (   $tabname,
  $page,
  $perpage,
  $cat,
  $recurse,
  $showhidden,
  $showquestiontext,
  $tagids = [] 
)

Renders the html question bank (same as display, but returns the result).

Note that you can only output this rendered result once per page, as it contains IDs which must be unique.

Return values
stringHTML code for the form

◆ set_quiz_has_attempts()

mod_quiz\question\bank\custom_view::set_quiz_has_attempts (   $quizhasattempts)

Let the question bank display know whether the quiz has been attempted, hence whether some bits of UI, like the add this question to the quiz icon, should be displayed.

Parameters
bool$quizhasattemptswhether the quiz has attempts.

◆ wanted_columns()

mod_quiz\question\bank\custom_view::wanted_columns ( )
protected

Reimplemented from core_question\bank\view.

Member Data Documentation

◆ $baseurl

moodle_url core_question\bank\view::$baseurl
protectedinherited

base URL for the current page.

Used as the basis for making URLs for actions that reload the page.

◆ $extrarows

question_bank_column_base [] core_question\bank\view::$extrarows
protectedinherited

these are the 'columns' that are actually displayed as an additional row (e.g.

question text), in order. Array keys are the class name.

◆ $requiredcolumns

question_bank_column_base [] core_question\bank\view::$requiredcolumns
protectedinherited

these are all the 'columns' that are part of the display.

Array keys are the class name.

◆ $visiblecolumns

question_bank_column_base [] core_question\bank\view::$visiblecolumns
protectedinherited

these are the 'columns' that are actually displayed as a column, in order.

Array keys are the class name.


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