Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
This class prints a view of the question bank, including. More...
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... | |
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
core_question\bank\view::__construct | ( | $contexts, | |
$pageurl, | |||
$course, | |||
$cm = null |
|||
) |
Constructor.
question_edit_contexts | $contexts | |
moodle_url | $pageurl | |
object | $course | course settings |
object | $cm | (optional) activity settings. |
core_question\bank\view::add_searchcondition | ( | $searchcondition | ) |
Add another search control to this view.
condition | $searchcondition | the condition to add. |
|
protected |
Create the SQL query to retrieve the indicated questions.
stdClass | $category | no longer used. |
bool | $recurse | no longer used. |
bool | $showhidden | no longer used. |
core_question\bank\view::copy_question_moodle_url | ( | $questionid | ) |
Get the URL for duplicating a question as a moodle_url.
int | $questionid | the question id. |
moodle_url | the URL. |
core_question\bank\view::copy_question_url | ( | $questionid | ) |
Get the URL for duplicating a given question.
int | $questionid | the question id. |
string | the URL, HTML-escaped. |
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
string | $tabname | question bank edit tab name, for permission checking. |
int | $page | the page number to show. |
int | $perpage | the number of questions per page to show. |
string | $cat | 'categoryid,contextid'. |
int | $recurse | Whether to include subcategories. |
bool | $showhidden | whether deleted questions should be displayed. |
bool | $showquestiontext | whether the text of each question should be shown in the list. Deprecated. |
array | $tagids | current list of selected tags. |
|
protected |
Print the "advanced" UI elements for the form to select which questions.
Hidden by default.
|
protected |
Display the controls at the bottom of the list of questions.
int | $totalnumber | Total number of questions that might be shown (if it was not for paging). |
bool | $recurse | Whether to include subcategories. |
stdClass | $category | The question_category row from the database. |
context | $catcontext | The context of the category being displayed. |
array | $addcontexts | contexts where the user is allowed to add new questions. |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Prints a form to choose categories.
|
protected |
Print a single option checkbox.
|
protected |
Display the options form.
bool | $recurse | no longer used. |
bool | $showhidden | no longer used. |
bool | $showquestiontext | whether to show the question text. |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Display the form with options for which questions are displayed and how they are displayed.
bool | $showquestiontext | Display the text of the question within the list. |
string | $scriptpath | path to the script displaying this page. |
bool | $showtextoption | whether to include the 'Show question text' checkbox. |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Display the header element for the question bank.
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Prints the table of questions in a category with interactions.
array | $contexts | Not used! |
moodle_url | $pageurl | The URL to reload this page. |
string | $categoryandcontext | 'categoryID,contextID'. |
stdClass | $cm | Not used! |
int | $recurse | Whether to include subcategories. |
int | $page | The number of the page to be displayed |
int | $perpage | Number of questions to show per page |
bool | $showhidden | Not used! This is now controlled in a different way. |
bool | $showquestiontext | Not used! This is now controlled in a different way. |
array | $addcontexts | contexts where the user is allowed to add new questions. |
|
protected |
Display the checkbox UI for toggling the display of the question text in the list.
bool | $showquestiontext | the current or default value for whether to display the text. |
core_question\bank\view::edit_question_moodle_url | ( | $questionid | ) |
Get the URL for editing a question as a moodle_url.
int | $questionid | the question id. |
moodle_url | the URL, HTML-escaped. |
core_question\bank\view::edit_question_url | ( | $questionid | ) |
Get the URL for editing a question as a HTML-escaped string.
int | $questionid | the question id. |
string | the URL, HTML-escaped. |
core_question\bank\view::get_column_count | ( | ) |
int | The number of columns in the table. |
|
protected |
Get a column object from its name.
string | $columnname,. |
core_question::bank::column_base. |
core_question\bank\view::get_most_specific_context | ( | ) |
Get the context we are displaying the question bank for.
context | context object. |
core_question\bank\view::get_primary_sort_order | ( | $sort | ) |
string | $sort | a column or column_subsort name. |
int | the current sort order for this column -1, 0, 1 |
core_question\bank\view::has_column | ( | $colname | ) |
string | $colname | a column internal name. |
bool | is this column included in the output? |
|
protected |
Specify the column heading.
string | Column name for the heading |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Initializing table columns.
array | $wanted | Collection of column names |
string | $heading | The name of column that is set as heading |
|
protected |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Load the questions we need to display.
int | $page | page to display. |
int | $perpage | number of questions per page. |
moodle_recordset | questionid => data about each question. |
core_question\bank\view::new_sort_url | ( | $sort, | |
$newsortreverse | |||
) |
Get a URL to redisplay the page with a new sort for the question bank.
string | $sort | the column, or column_subsort to sort on. |
bool | $newsortreverse | whether to sort in reverse order. |
string | The new URL. |
|
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 ''.
string | $sort | the sort parameter to process. |
array | array($colname, $subsort). |
core_question\bank\view::preview_question_url | ( | $questiondata | ) |
Get the URL to preview a question.
stdClass | $questiondata | the data defining the question. |
moodle_url | the URL. |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
prints category information
stdClass | $category | the category row from the database. |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
Reimplemented in mod_quiz\question\bank\custom_view.
|
protected |
base URL for the current page.
Used as the basis for making URLs for actions that reload the page.
|
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.
|
protected |
these are all the 'columns' that are part of the display.
Array keys are the class name.
|
protected |
these are the 'columns' that are actually displayed as a column, in order.
Array keys are the class name.