Base class to make it easier to implement actions that are menuable_actions.
More...
|
static | from_column_name (view $view, string $columnname, bool $ingoremissing=false) |
| Return an instance of this column, based on the column name.
|
|
|
bool | $isvisible = true |
| determine whether the column is visible
|
|
string const | ID_SEPARATOR = '-' |
| A separator for joining column attributes together into a unique ID string.
|
|
int const | MENU_POSITION_NOT_SET = 6666 |
| value we return from get_menu_position here.
|
|
|
| display_content ($question, $rowclasses) |
| Output the contents of this column.
|
|
| display_end ($question, $rowclasses) |
| Output the closing column tag.
|
|
| display_start ($question, $rowclasses) |
| Output the opening column tag.
|
|
| get_classes () |
| The CSS classes to apply to every cell in this column.
|
|
| get_sort_icon ($reverse) |
| Get an icon representing the corrent sort state.
|
|
| get_url_icon_and_label (\stdClass $question) |
| Get the information required to display this action either as a menu item or a separate action column.
|
|
| init () |
| A chance for subclasses to initialise themselves, for example to load lang strings, without having to override the constructor.
|
|
| make_sort_link ($sortname, $title, $tip, $defaultreverse=false) |
| Get a link that changes the sort order, and indicates the current sort state.
|
|
| print_icon ($icon, $title, $url) |
|
| sortorder ($reverse) |
| Helper method for building sort clauses.
|
|
|
bool | $isheading = false |
| determine whether the column is td or th.
|
|
view | $qbank |
| $qbank the question bank view we are helping to render.
|
|
Base class to make it easier to implement actions that are menuable_actions.
Use this class if your action is simple (defined by just a URL, label and icon). If your action is not simple enough to fit into the pattern that this class implements, then you will have to implement the menuable_action interface yourself.
- Copyright
- 2019 Tim Hunt
- Author
- 2021 Safat Shahin safat.nosp@m.shah.nosp@m.in@ca.nosp@m.taly.nosp@m.st-au.nosp@m..net
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- Deprecated
- Since Moodle 4.3 MDL-75125 - Use question_action_base instead.
- Todo
- MDL-78090 This class will be deleted in Moodle 4.7
◆ display()
core_question\local\bank\column_base::display |
( |
| $question, |
|
|
| $rowclasses ) |
|
inherited |
Output this column.
- Parameters
-
object | $question | the row from the $question table, augmented with extra information. |
string | $rowclasses | CSS class names that should be applied to this row of output. |
◆ display_content()
core_question\local\bank\menu_action_column_base::display_content |
( |
| $question, |
|
|
| $rowclasses ) |
|
protected |
Output the contents of this column.
- Parameters
-
object | $question | the row from the $question table, augmented with extra information. |
string | $rowclasses | CSS class names that should be applied to this row of output. |
Reimplemented from core_question\local\bank\column_base.
◆ display_end()
core_question\local\bank\column_base::display_end |
( |
| $question, |
|
|
| $rowclasses ) |
|
protectedinherited |
◆ display_header()
core_question\local\bank\column_base::display_header |
( |
array | $columnactions = [], |
|
|
string | $width = '' ) |
|
inherited |
Output the column header cell.
- Parameters
-
column_action_base[] | $columnactions | A list of column actions to include in the header. |
string | $width | A CSS width property value. |
Reimplemented in core_question\local\bank\checkbox_column.
◆ display_preview()
core_question\local\bank\column_base::display_preview |
( |
\stdClass | $question, |
|
|
string | $rowclasses ) |
|
inherited |
◆ display_start()
core_question\local\bank\column_base::display_start |
( |
| $question, |
|
|
| $rowclasses ) |
|
protectedinherited |
Output the opening column tag.
If it is set as heading, it will use
tag instead of
- Parameters
-
stdClass | $question | |
string | $rowclasses | |
Reimplemented in core_question\local\bank\row_base.
◆ from_column_name()
static core_question\local\bank\column_base::from_column_name |
( |
view | $view, |
|
|
string | $columnname, |
|
|
bool | $ingoremissing = false ) |
|
staticinherited |
Return an instance of this column, based on the column name.
In the case of the base class, we don't actually use the column name since the class represents one specific column. However, sub-classes may use the column name as an additional constructor to the parameter.
- Parameters
-
view | $view | Question bank view |
string | $columnname | The column name for this instance, as returned by { |
- See also
- get_column_name()}
- Parameters
-
bool | $ingoremissing | Whether to ignore if the class does not exist. |
- Return values
-
column_base|null | An instance of this class. |
Reimplemented in qbank_customfields\custom_field_column.
◆ get_action_menu_link()
core_question\local\bank\menu_action_column_base::get_action_menu_link |
( |
\stdClass | $question | ) |
|
Return the appropriate action menu link, or null if it does not apply to this question.
- Parameters
-
stdClass | $question | data about the question being displayed in this row. |
- Return values
-
action_menu_link|null | the action, if applicable to this question. |
- Deprecated
- Since Moodle 4.3
Implements core_question\local\bank\menuable_action.
◆ get_classes()
core_question\local\bank\column_base::get_classes |
( |
| ) |
|
|
protectedinherited |
The CSS classes to apply to every cell in this column.
- Return values
-
◆ get_column_id()
core_question\local\bank\column_base::get_column_id |
( |
| ) |
|
|
finalinherited |
Return a unique ID for this column object.
This is constructed using the class name and get_column_name(), which must be unique.
The combination of these attributes allows the object to be reconstructed, by splitting the ID into its constituent parts then calling {
- See also
- from_column_name()}, like this: [$class, $columnname] = explode(column_base\ID_SEPARATOR, $columnid, 2); $column = $class\from_column_name($qbank, $columnname); Including 2 as the $limit parameter for explode() is a good idea for safely, in case a plugin defines a column with the ID_SEPARATOR in the column name.
- Return values
-
◆ get_column_name()
core_question\local\bank\column_base::get_column_name |
( |
| ) |
|
|
inherited |
Get the name of this column.
This must be unique. When using the inherited class to make many columns from one parent, ensure each instance returns a unique value.
- Return values
-
Reimplemented in qbank_customfields\custom_field_column.
◆ get_default_width()
core_question\local\bank\column_base::get_default_width |
( |
| ) |
|
|
inherited |
◆ get_extra_classes()
core_question\local\bank\action_column_base::get_extra_classes |
( |
| ) |
|
|
inherited |
◆ get_extra_joins()
core_question\local\bank\action_column_base::get_extra_joins |
( |
| ) |
|
|
inherited |
◆ get_menu_position()
core_question\local\bank\view_component::get_menu_position |
( |
| ) |
|
|
inherited |
Return an integer to indicate the desired position in the menu for this link, smaller at the top.
The standard menu items in Moodle core return these numbers: 100 preview_action 200 edit_action 250 copy_action 300 tags_action 400 delete_action 500 history_action 600 export_xml_action (So, if you want your action at a particular place in the order, there should be space.)
If two actions get the same order number, then the tie-break on the sort is plugin name, then the order returned by get_question_actions for that plugin.
- Return values
-
int | desired position. Smallest at the top. |
Reimplemented in qbank_deletequestion\delete_action, qbank_editquestion\copy_action, qbank_editquestion\edit_action, qbank_exporttoxml\export_xml_action, qbank_history\history_action, qbank_previewquestion\preview_action, and qbank_tagquestion\tags_action.
◆ get_name()
core_question\local\bank\column_base::get_name |
( |
| ) |
|
|
abstractinherited |
Get the internal name for this column.
Used as a CSS class name, and to store information about the current sort. Must match PARAM_ALPHA.
- Return values
-
Reimplemented in core_question\local\bank\checkbox_column, core_question\local\bank\edit_menu_column, mod_quiz\question\bank\add_action_column, mod_quiz\question\bank\preview_action_column, mod_quiz\question\bank\question_name_column, mod_quiz\question\bank\question_name_text_column, qbank_comment\comment_count_column, qbank_customfields\custom_field_column, qbank_editquestion\question_status_column, qbank_history\version_number_column, qbank_statistics\columns\discrimination_index, qbank_statistics\columns\discriminative_efficiency, qbank_statistics\columns\facility_index, qbank_usage\question_last_used_column, qbank_usage\question_usage_column, qbank_viewcreator\creator_name_column, qbank_viewcreator\modifier_name_column, qbank_viewquestionname\question_name_idnumber_tags_column, qbank_viewquestionname\viewquestionname_column_helper, qbank_viewquestiontext\question_text_row, and qbank_viewquestiontype\question_type_column.
◆ get_preference_key()
core_question\local\bank\column_base::get_preference_key |
( |
| ) |
|
|
inherited |
◆ get_required_fields()
core_question\local\bank\action_column_base::get_required_fields |
( |
| ) |
|
|
inherited |
◆ get_required_statistics_fields()
core_question\local\bank\column_base::get_required_statistics_fields |
( |
| ) |
|
|
inherited |
◆ get_sort_icon()
core_question\local\bank\column_base::get_sort_icon |
( |
| $reverse | ) |
|
|
protectedinherited |
Get an icon representing the corrent sort state.
- Parameters
-
bool | $reverse | sort is descending, not ascending. |
- Return values
-
◆ get_title()
core_question\local\bank\action_column_base::get_title |
( |
| ) |
|
|
inherited |
◆ get_title_tip()
core_question\local\bank\column_base::get_title_tip |
( |
| ) |
|
|
inherited |
◆ get_url_icon_and_label()
core_question\local\bank\menu_action_column_base::get_url_icon_and_label |
( |
\stdClass | $question | ) |
|
|
abstractprotected |
Get the information required to display this action either as a menu item or a separate action column.
If this action cannot apply to this question (e.g. because the user does not have permission, then return [null, null, null].
- Parameters
-
stdClass | $question | the row from the $question table, augmented with extra information. |
- Return values
-
array | with three elements. $url - the URL to perform the action. $icon - the icon for this action. E.g. 't/delete'. $label - text label to display in the UI (either in the menu, or as a tool-tip on the icon) |
◆ has_preference()
core_question\local\bank\column_base::has_preference |
( |
| ) |
|
|
inherited |
◆ help_icon()
core_question\local\bank\column_base::help_icon |
( |
| ) |
|
|
inherited |
◆ init()
core_question\local\bank\view_component::init |
( |
| ) |
|
|
protectedinherited |
A chance for subclasses to initialise themselves, for example to load lang strings, without having to override the constructor.
Reimplemented in core_question\local\bank\column_action_base, mod_quiz\question\bank\add_action_column, qbank_columnsortorder\local\bank\column_action_move, qbank_columnsortorder\local\bank\column_action_remove, qbank_columnsortorder\local\bank\column_action_resize, qbank_comment\comment_count_column, qbank_deletequestion\delete_action, qbank_editquestion\copy_action, qbank_editquestion\edit_action, qbank_exporttoxml\export_xml_action, qbank_history\history_action, qbank_previewquestion\preview_action, qbank_tagquestion\tags_action, qbank_usage\question_usage_column, and qbank_viewquestiontext\question_text_row.
◆ is_extra_row()
core_question\local\bank\column_base::is_extra_row |
( |
| ) |
|
|
inherited |
◆ is_sortable()
core_question\local\bank\column_base::is_sortable |
( |
| ) |
|
|
inherited |
Can this column be sorted on? You can return either:
- false for no (the default),
- a field name, if sorting this column corresponds to sorting on that datbase field.
- an array of subnames to sort on as follows return [ 'firstname' => ['field' => 'uc.firstname', 'title' => get_string('firstname')], 'lastname' => ['field' => 'uc.lastname', 'title' => get_string('lastname')], ]; As well as field, and field, you can also add 'revers' => 1 if you want the default sort order to be DESC.
- Return values
-
Reimplemented in mod_quiz\question\bank\question_name_column, qbank_viewcreator\creator_name_column, qbank_viewcreator\modifier_name_column, qbank_viewquestionname\question_name_idnumber_tags_column, qbank_viewquestionname\viewquestionname_column_helper, and qbank_viewquestiontype\question_type_column.
◆ load_additional_data()
core_question\local\bank\column_base::load_additional_data |
( |
array | $questions | ) |
|
|
inherited |
◆ load_question_tags()
core_question\local\bank\column_base::load_question_tags |
( |
array | $questions | ) |
|
|
inherited |
Load the tags for each question.
Helper that can be used from {
- See also
- load_additional_data()};
- Parameters
-
◆ make_sort_link()
core_question\local\bank\column_base::make_sort_link |
( |
| $sortname, |
|
|
| $title, |
|
|
| $tip, |
|
|
| $defaultreverse = false ) |
|
protectedinherited |
Get a link that changes the sort order, and indicates the current sort state.
- Parameters
-
string | $sortname | the column to sort on. |
string | $title | the link text. |
string | $tip | the link tool-tip text. If empty, defaults to title. |
bool | $defaultreverse | whether the default sort order for this column is descending, rather than ascending. |
- Return values
-
◆ print_icon()
core_question\local\bank\action_column_base::print_icon |
( |
| $icon, |
|
|
| $title, |
|
|
| $url ) |
|
protectedinherited |
◆ sort_expression()
core_question\local\bank\column_base::sort_expression |
( |
| $reverse, |
|
|
| $subsort ) |
|
inherited |
Sorts the expressions.
- Parameters
-
bool | $reverse | Whether to sort in the reverse of the default sort order. |
string | $subsort | if is_sortable returns an array of subnames, then this will be one of those. Otherwise will be empty. |
- Return values
-
string | some SQL to go in the order by clause. |
◆ sortorder()
core_question\local\bank\column_base::sortorder |
( |
| $reverse | ) |
|
|
protectedinherited |
Helper method for building sort clauses.
- Parameters
-
bool | $reverse | whether the normal direction should be reversed. |
- Return values
-
◆ MENU_POSITION_NOT_SET
int const core_question\local\bank\view_component::MENU_POSITION_NOT_SET = 6666 |
|
inherited |
value we return from get_menu_position here.
Subclasses should override this.
The documentation for this class was generated from the following file:
- question/classes/local/bank/menu_action_column_base.php