MDL-51720 assign: Always fallback on userid as a default sort

Even when the table has no userid column (this is normally the edit column).
This commit is contained in:
Damyon Wiese 2015-10-14 14:01:28 +08:00
parent 4cef723c22
commit 85d0696dfa

View File

@ -402,8 +402,6 @@ class assign_grading_table extends table_sql implements renderable {
foreach ($extrauserfields as $extrafield) {
$this->column_class($extrafield, $extrafield);
}
// We require at least one unique column for the sort.
$this->sortable(true, 'userid');
$this->no_sorting('recordid');
$this->no_sorting('finalgrade');
$this->no_sorting('userid');
@ -1375,6 +1373,16 @@ class assign_grading_table extends table_sql implements renderable {
has_capability('moodle/grade:viewall', $context);
}
/**
* Always return a valid sort - even if the userid column is missing.
* @return array column name => SORT_... constant.
*/
public function get_sort_columns() {
$result = parent::get_sort_columns();
$result = array_merge($result, array('userid' => SORT_ASC));
return $result;
}
/**
* Override the table show_hide_link to not show for select column.
*