Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Subclass to customise the view of the question bank for the quiz editing screen. More...
Public Member Functions | |
__construct ($contexts, $pageurl, $course, $cm, $quiz) | |
Constructor. | |
add_searchcondition ($searchcondition) | |
Add another search control to this view. | |
add_to_quiz_url ($questionid) | |
URL of add to quiz. | |
base_url () | |
Returns the base url. | |
copy_question_moodle_url ($questionid) | |
Get the URL for duplicating a question as a moodle url. | |
copy_question_url ($questionid) | |
Get the URL for duplicating a given question. | |
display ($pagevars, $tabname) | |
Shows the question bank interface. | |
edit_question_moodle_url ($questionid) | |
Get the URL for editing a question as a moodle url. | |
edit_question_url ($questionid) | |
Get the URL for editing a question as a HTML-escaped string. | |
get_aggregate_statistic (int $questionid, string $fieldname) | |
Get the aggregated value of a particular statistic for a particular question. | |
get_column_count () | |
Get the count of the columns. | |
get_courseid () | |
Get course id. | |
get_most_specific_context () | |
Get the context we are displaying the question bank for. | |
get_primary_sort_order ($sort) | |
Gets the primary sort order according to the default sort. | |
get_visiblecolumns () | |
Gets visible columns. | |
has_column ($colname) | |
Checks if the column included in the output. | |
is_listing_specific_versions () | |
Is this view showing separate versions of a question? | |
new_sort_url ($sort, $newsortreverse) | |
Get a URL to redisplay the page with a new sort for the question bank. | |
preview_question_url ($question) | |
Question preview url. | |
process_actions () | |
Process actions for the selected action. | |
process_actions_needing_ui () | |
Process actions with ui. | |
render ($pagevars, $tabname) | |
Renders the html question bank (same as display, but returns the result). | |
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. | |
wanted_filters ($cat, $tagids, $showhidden, $recurse, $editcontexts, $showquestiontext) | |
The filters for the question bank. | |
Public Attributes | |
array | $bulkactions = [] |
$bulkactions to identify the bulk actions for the api. | |
object cm_info null | $cm |
if we are in a module context, the cm. | |
object | $course |
the course we are within. | |
array | $customfilterobjects = null |
to pass custom filters instead of the specified ones. | |
bool | $enablefilters = true |
enable or disable filters while calling the API. | |
string | $returnurl |
url of the new question page. | |
int const | DEFAULT_PAGE_SIZE = 20 |
number of questions per page to show in the add from question bank modal. | |
const | MAX_SORTS = 3 |
Maximum number of sorts allowed. | |
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. | |
create_new_question_form ($category, $canadd) | |
Create a new question form. | |
default_sort () | |
Default sort for question data. | |
determine_required_statistics () | |
Work out the list of all the required statistics fields for this question bank view. | |
display_advanced_search_form ($advancedsearch) | |
Print the "advanced" UI elements for the form to select which questions. | |
display_bottom_controls (\context $catcontext) | |
Display the controls at the bottom of the list of questions. | |
display_bottom_pagination ($pagination, $totalnumber, $perpage, $pageurl) | |
Display bottom pagination bar. | |
display_options_form ($showquestiontext) | |
Display the form with options for which questions are displayed and how they are displayed. | |
display_question_bank_header () | |
Override the base implementation in core_question\local\bank\view because we don't want to print the headers in the fragment for the modal. | |
display_question_list ($pageurl, $categoryandcontext, $recurse=1, $page=0, $perpage=null, $addcontexts=[]) | |
Prints the table of questions in a category with interactions. | |
display_questions ($questions) | |
Display the questions. | |
display_showtext_checkbox ($showquestiontext) | |
Display the checkbox UI for toggling the display of the question text in the list. | |
display_top_pagnation ($pagination) | |
Display the top pagination bar. | |
end_table () | |
End of the table html. | |
get_column_type ($columnname) | |
Check a column object from its name and get the object for sort. | |
get_current_category ($categoryandcontext) | |
Gets current selected category. | |
get_question_bank_plugins () | |
Get the list of qbank plugins with available objects for features. | |
get_question_count () | |
Get the number of questions. | |
get_row_classes ($question, $rowcount) | |
Gets the classes for the row. | |
heading_column () | |
Specify the column heading. | |
init_bulk_actions () | |
Initialize bulk actions. | |
init_columns ($wanted, $heading='') | |
Initializing table columns. | |
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 () | |
Initialise sorting. | |
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. | |
load_page_questions ($page, $perpage) | |
Load the questions we need to display. | |
load_required_statistics (array $questions) | |
Load the aggregate statistics that all the columns require. | |
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. | |
print_choose_category_message () | |
Print the text if category id not available. | |
print_table ($questions) | |
Prints the actual table with question. | |
print_table_headers () | |
Print table headers from child classes. | |
print_table_row ($question, $rowcount) | |
Prints the table row from child classes. | |
sort_to_params ($sorts) | |
Sort to parameters. | |
start_table () | |
Start of the table html. | |
wanted_columns () | |
Loads all the available columns. | |
Protected Attributes | |
moodle_url | $baseurl |
base URL for the current page. | |
core_question local bank question_edit_contexts | $contexts |
string | $countsql |
SQL to count the number of questions matching the current search conditions. | |
moodle_url | $editquestionurl |
used as a basis for URLs that edit a question. | |
column_base[] | $extrarows |
these are the 'columns' that are actually displayed as an additional row (e.g. | |
int null | $lastchangedid |
id of the a question to highlight in the list (if present). | |
array | $loadedstatistics = null |
Stores all the average statistics that this question bank view needs. | |
string | $loadsql |
SQL to actually load the question data to display. | |
int | $pagesize = DEFAULT_QUESTIONS_PER_PAGE |
page size to use (when we are not showing all questions). | |
stdClass | $quiz = false |
$quiz the quiz settings. | |
bool | $quizhasattempts = false |
$quizhasattempts whether the quiz this is used by has been attemptd. | |
column_base[] | $requiredcolumns |
these are all the 'columns' that are part of the display. | |
condition[] | $searchconditions = [] |
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). | |
column_base[] | $visiblecolumns |
these are the 'columns' that are actually displayed as a column, in order. | |
Subclass to customise the view of the question bank for the quiz editing screen.
mod_quiz\question\bank\custom_view::__construct | ( | $contexts, | |
$pageurl, | |||
$course, | |||
$cm, | |||
$quiz ) |
Constructor.
core_question\local\bank\question_edit_contexts | $contexts | |
moodle_url | $pageurl | |
stdClass | $course | course settings |
stdClass | $cm | activity settings. |
stdClass | $quiz | quiz settings. |
|
inherited |
Add another search control to this view.
condition | $searchcondition | the condition to add. |
mod_quiz\question\bank\custom_view::add_to_quiz_url | ( | $questionid | ) |
|
protected |
Create the SQL query to retrieve the indicated questions, based on core_question\bank\search\condition filters.
Reimplemented from core_question\local\bank\view.
|
inherited |
Get the URL for duplicating a question as a moodle url.
int | $questionid | the question id. |
moodle_url | the URL. |
|
inherited |
Get the URL for duplicating a given question.
int | $questionid | the question id. |
string | the URL, HTML-escaped. |
|
protected |
Create a new question form.
false | mixed | stdClass | $category | |
bool | $canadd |
Reimplemented from core_question\local\bank\view.
|
protected |
Default sort for question data.
int[] |
Reimplemented from core_question\local\bank\view.
|
protectedinherited |
Work out the list of all the required statistics fields for this question bank view.
This gathers all the required fields from all columns, so they can all be loaded at once.
string[] | the names of all the required fields for this question bank view. |
|
inherited |
Shows the question bank 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 params: $tabname question bank edit tab name, for permission checking $pagevars current list of page variables
string | $tabname | |
array | $pagevars |
|
protectedinherited |
Print the "advanced" UI elements for the form to select which questions.
Hidden by default.
array | $advancedsearch |
Reimplemented in qbank_history\question_history_view.
|
protected |
Display the controls at the bottom of the list of questions.
context | $catcontext | The context of the category being displayed. |
Reimplemented from core_question\local\bank\view.
|
protectedinherited |
Display bottom pagination bar.
string | $pagination | |
int | $totalnumber | |
int | $perpage | |
moodle_url | $pageurl |
|
protectedinherited |
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. |
|
protected |
Override the base implementation in core_question\local\bank\view because we don't want to print the headers in the fragment for the modal.
Reimplemented from core_question\local\bank\view.
|
protectedinherited |
Prints the table of questions in a category with interactions.
moodle_url | $pageurl | The URL to reload this page. |
string | $categoryandcontext | 'categoryID,contextID'. |
int | $recurse | Whether to include subcategories. |
int | $page | The number of the page to be displayed |
int | null | $perpage | Number of questions to show per page |
array | $addcontexts | contexts where the user is allowed to add new questions. |
|
protectedinherited |
Display the questions.
array | $questions |
|
protectedinherited |
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. |
|
protectedinherited |
Display the top pagination bar.
object | $pagination |
|
inherited |
Get the URL for editing a question as a moodle url.
int | $questionid | the question id. |
moodle_url | the URL, HTML-escaped. |
|
inherited |
Get the URL for editing a question as a HTML-escaped string.
int | $questionid | the question id. |
string | the URL, HTML-escaped. |
|
protectedinherited |
|
inherited |
Get the aggregated value of a particular statistic for a particular question.
You can only get values for the questions on the current page of the question bank view, and only if you declared the need for this statistic in the get_required_statistics_fields() method of your question bank column.
int | $questionid | the id of a question |
string | $fieldname | the name of a statistics field, e.g. 'facility'. |
float|null | the average (across all users) of this statistic for this question. Null if the value is not available right now. |
|
inherited |
Get the count of the columns.
int | The number of columns in the table. |
|
protectedinherited |
Check a column object from its name and get the object for sort.
string | $columnname |
|
inherited |
Get course id.
mixed |
|
protectedinherited |
Gets current selected category.
string | $categoryandcontext |
false|mixed|stdClass |
|
inherited |
Get the context we are displaying the question bank for.
context | context object. |
|
inherited |
Gets the primary sort order according to the default sort.
string | $sort | a column or column_subsort name. |
int | the current sort order for this column -1, 0, 1 |
|
protected |
Get the list of qbank plugins with available objects for features.
array |
Reimplemented from core_question\local\bank\view.
|
protectedinherited |
Get the number of questions.
int |
|
protectedinherited |
Gets the classes for the row.
stdClass | $question | |
int | $rowcount |
array |
|
inherited |
Gets visible columns.
array | Visible columns. |
|
inherited |
Checks if the column included in the output.
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 from core_question\local\bank\view.
|
protectedinherited |
Initializing table columns.
array | $wanted | Collection of column names |
string | $heading | The name of column that is set as heading |
|
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\local\bank\view.
|
inherited |
Is this view showing separate versions of a question?
bool |
Reimplemented in qbank_history\question_history_view.
|
protectedinherited |
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. |
|
protectedinherited |
Load the aggregate statistics that all the columns require.
stdClass[] | $questions | the questions that will be displayed indexed by question id. |
|
inherited |
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. |
|
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 ''.
string | $sort | the sort parameter to process. |
array | [$colname, $subsort]. |
mod_quiz\question\bank\custom_view::preview_question_url | ( | $question | ) |
Question preview url.
stdClass | $question |
moodle_url |
Reimplemented from core_question\local\bank\view.
|
protectedinherited |
Prints the actual table with question.
array | $questions |
|
protectedinherited |
Prints the table row from child classes.
stdClass | $question | |
int | $rowcount |
|
inherited |
Process actions for the selected action.
|
inherited |
mod_quiz\question\bank\custom_view::render | ( | $pagevars, | |
$tabname ) |
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.
array | $pagevars | |
string | $tabname |
string | HTML code for the form |
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.
bool | $quizhasattempts | whether the quiz has attempts. |
|
protectedinherited |
Sort to parameters.
array | $sorts |
array |
|
protectedinherited |
|
protectedinherited |
Loads all the available columns.
array |
Reimplemented in qbank_history\question_history_view.
mod_quiz\question\bank\custom_view::wanted_filters | ( | $cat, | |
$tagids, | |||
$showhidden, | |||
$recurse, | |||
$editcontexts, | |||
$showquestiontext ) |
The filters for the question bank.
string | $cat | 'categoryid,contextid' |
array | $tagids | current list of selected tags |
bool | $showhidden | whether deleted questions should be displayed |
int | $recurse | Whether to include subcategories |
array | $editcontexts | parent contexts |
bool | $showquestiontext | whether the text of each question should be shown in the list |
Reimplemented from core_question\local\bank\view.
|
protectedinherited |
base URL for the current page.
Used as the basis for making URLs for actions that reload the page.
|
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.
|
protectedinherited |
Stores all the average statistics that this question bank view needs.
This field gets initialised in {
|
protectedinherited |
these are all the 'columns' that are part of the display.
Array keys are the class name.
|
protectedinherited |
these are the 'columns' that are actually displayed as a column, in order.
Array keys are the class name.