Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Base class for representing a column in a {@link question_bank_view}.

Copyright: 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 346 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: column_base  - X-Ref

Base class for representing a column in a {@link question_bank_view}.

__construct(view $qbank)   X-Ref
Constructor.

param: view $qbank the question bank view we are helping to render.

init()   X-Ref
A chance for subclasses to initialise themselves, for example to load lang strings,
without having to override the constructor.


set_as_heading()   X-Ref
Set the column as heading


is_extra_row()   X-Ref
No description

display_header()   X-Ref
Output the column header cell.


get_title_tip()   X-Ref

return: string a fuller version of the name. Use this when get_title() returns

make_sort_link($sort, $title, $tip, $defaultreverse = false)   X-Ref
Get a link that changes the sort order, and indicates the current sort state.

param: string $sort the column to sort on.
param: string $title the link text.
param: string $tip the link tool-tip text. If empty, defaults to title.
param: bool $defaultreverse whether the default sort order for this column is descending, rather than ascending.
return: string HTML fragment.

get_sort_icon($reverse)   X-Ref
Get an icon representing the corrent sort state.

param: bool $reverse sort is descending, not ascending.
return: string HTML image tag.

display($question, $rowclasses)   X-Ref
Output this column.

param: object $question the row from the $question table, augmented with extra information.
param: string $rowclasses CSS class names that should be applied to this row of output.

display_start($question, $rowclasses)   X-Ref
Output the opening column tag.  If it is set as heading, it will use <th> tag instead of <td>

param: \stdClass $question
param: string $rowclasses

get_classes()   X-Ref

return: string the CSS classes to apply to every cell in this column.

get_extra_classes()   X-Ref

return: array any extra class names you would like applied to every cell in this column.

display_end($question, $rowclasses)   X-Ref
Output the closing column tag

param: object $question
param: string $rowclasses

get_extra_joins()   X-Ref
Return an array 'table_alias' => 'JOIN clause' to bring in any data that
this column required.

The return values for all the columns will be checked. It is OK if two
columns join in the same table with the same alias and identical JOIN clauses.
If to columns try to use the same alias with different joins, you get an error.
The only table included by default is the question table, which is aliased to 'q'.

It is importnat that your join simply adds additional data (or NULLs) to the
existing rows of the query. It must not cause additional rows.

return: array 'table_alias' => 'JOIN clause'

get_required_fields()   X-Ref

return: array fields required. use table alias 'q' for the question table, or one of the

load_additional_data(array $questions)   X-Ref
If this column needs extra data (e.g. tags) then load that here.

The extra data should be added to the question object in the array.
Probably a good idea to check that another column has not already
loaded the data you want.

param: \stdClass[] $questions the questions that will be displayed.

load_question_tags(array $questions)   X-Ref
Load the tags for each question.

Helper that can be used from {@link load_additional_data()};

param: array $questions

is_sortable()   X-Ref
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 array(
'firstname' => array('field' => 'uc.firstname', 'title' => get_string('firstname')),
'lastname' => array('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: mixed as above.

sortorder($reverse)   X-Ref
Helper method for building sort clauses.

param: bool $reverse whether the normal direction should be reversed.
return: string 'ASC' or 'DESC'

sort_expression($reverse, $subsort)   X-Ref

param: bool $reverse Whether to sort in the reverse of the default sort order.
param: string $subsort if is_sortable returns an array of subnames, then this will be
return: string some SQL to go in the order by clause.