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

This class prints a view of the question bank, including. More...

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

Public Member Functions

 __construct ($contexts, $pageurl, $course, $cm=null)
 Constructor. More...
 
 add_searchcondition ($searchcondition)
 Add another search control to this view. More...
 
 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 ($questiondata)
 Get the URL to preview a question. More...
 
 process_actions ()
 
 process_actions_needing_ui ()
 

Public Attributes

const MAX_SORTS = 3
 

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='/question/edit.php', $showtextoption=true)
 Display the form with options for which questions are displayed and how they are displayed. More...
 
 display_question_bank_header ()
 Display the header element for the question bank. 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 ()
 
 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)
 
 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.
 
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

This class prints a view of the question bank, including.

This class gives a basic view, and provides plenty of hooks where subclasses can override parts of the display.

The list of questions presented as a table is generated by creating a list of core_question::bank::column objects, one for each 'column' to be displayed. These manage

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

Constructor & Destructor Documentation

◆ __construct()

core_question\bank\view::__construct (   $contexts,
  $pageurl,
  $course,
  $cm = null 
)

Constructor.

Parameters
question_edit_contexts$contexts
moodle_url$pageurl
object$coursecourse settings
object$cm(optional) activity settings.

Member Function Documentation

◆ add_searchcondition()

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

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

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)

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)

Get the URL for duplicating a given question.

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

◆ display()

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

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

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

Hidden by default.

◆ display_bottom_controls()

core_question\bank\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 in mod_quiz\question\bank\custom_view.

◆ display_category_form()

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

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

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

core_question\bank\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 in mod_quiz\question\bank\custom_view.

◆ display_options_form()

core_question\bank\view::display_options_form (   $showquestiontext,
  $scriptpath = '/question/edit.php',
  $showtextoption = true 
)
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 in mod_quiz\question\bank\custom_view.

◆ display_question_bank_header()

core_question\bank\view::display_question_bank_header ( )
protected

Display the header element for the question bank.

Reimplemented in mod_quiz\question\bank\custom_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() 
)
protected

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

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)

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)

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 ( )
Return values
intThe number of columns in the table.

◆ get_column_type()

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

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

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)
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)
Parameters
string$colnamea column internal name.
Return values
boolis this column included in the output?

◆ heading_column()

core_question\bank\view::heading_column ( )
protected

Specify the column heading.

Return values
stringColumn name for the heading

Reimplemented in mod_quiz\question\bank\custom_view.

◆ init_columns()

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

Initializing table columns.

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

◆ init_sort_from_params()

core_question\bank\view::init_sort_from_params ( )
protected

◆ load_page_questions()

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

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 
)

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

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

core_question\bank\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 in mod_quiz\question\bank\custom_view.

◆ print_category_info()

core_question\bank\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 in mod_quiz\question\bank\custom_view.

◆ print_choose_category_message()

core_question\bank\view::print_choose_category_message (   $categoryandcontext)
protected

Member Data Documentation

◆ $baseurl

moodle_url core_question\bank\view::$baseurl
protected

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
protected

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
protected

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
protected

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: