$this->sess->sortby = array_slice($this->sess->sortby, 0, $this->maxsortkeys);
}
- // If we didn't sort just now, then use the default sort order if one is defined and the column exists
- if (empty($this->sess->sortby) && !empty($this->sort_default_column)) {
- $this->sess->sortby = array ($this->sort_default_column => ($this->sort_default_order == SORT_DESC ? SORT_DESC : SORT_ASC));
+ // MDL-35375 - If a default order is defined and it is not in the current list of order by columns, add it at the end.
+ // This prevents results from being returned in a random order if the only order by column contains equal values.
+ if (!empty($this->sort_default_column)) {
+ if (!array_key_exists($this->sort_default_column, $this->sess->sortby)) {
+ $defaultsort = array($this->sort_default_column => $this->sort_default_order);
+ $this->sess->sortby = array_merge($this->sess->sortby, $defaultsort);
+ }
}
$ilast = optional_param($this->request[TABLE_VAR_ILAST], null, PARAM_RAW);
$headers = array();
// Select
- $columns[] = 'select';
- $headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
-
- // Edit links
if (!$this->is_downloading()) {
- $columns[] = 'edit';
+ $columns[] = 'select';
+ $headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
+
+ // We have to call this column userid so we can use userid as a default sortable column.
+ $columns[] = 'userid';
$headers[] = get_string('edit');
}
// set the columns
$this->define_columns($columns);
$this->define_headers($headers);
+ // We require at least one unique column for the sort.
+ $this->sortable(true, 'userid');
$this->no_sorting('finalgrade');
- $this->no_sorting('edit');
+ $this->no_sorting('userid');
$this->no_sorting('select');
$this->no_sorting('outcomes');
* @param stdClass $row
* @return string
*/
- function col_edit(stdClass $row) {
+ function col_userid(stdClass $row) {
$edit = '';
if ($this->rownum < 0) {
$this->rownum = $this->currpage * $this->pagesize;