Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-28015 workshop - fixed unique list of columns in ORDER BY clause

MSSQL requires that the columns in the ORDER BY clause list must be
unique. The patch populates the list of fields by combining an array of
explicit sort definition with an array of implicit (default) sort
definition.
  • Loading branch information...
commit 308e53f572c5823e3d849226482193f391643f22 1 parent 020f0ff
David Mudrák mudrd8mz authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 mod/workshop/locallib.php
7 mod/workshop/locallib.php
View
@@ -1331,7 +1331,12 @@ public function prepare_grading_report_data($userid, $groups, $page, $perpage, $
list($participantids, $params) = $DB->get_in_or_equal(array_keys($participants), SQL_PARAMS_NAMED);
$params['workshopid1'] = $this->id;
$params['workshopid2'] = $this->id;
- $sqlsort = $sortby . ' ' . $sorthow . ',u.lastname,u.firstname,u.id';
+ $sqlsort = array();
+ $sqlsortfields = array($sortby => $sorthow) + array('lastname' => 'ASC', 'firstname' => 'ASC', 'u.id' => 'ASC');
+ foreach ($sqlsortfields as $sqlsortfieldname => $sqlsortfieldhow) {
+ $sqlsort[] = $sqlsortfieldname . ' ' . $sqlsortfieldhow;
+ }
+ $sqlsort = implode(',', $sqlsort);
$sql = "SELECT u.id AS userid,u.firstname,u.lastname,u.picture,u.imagealt,u.email,
s.title AS submissiontitle, s.grade AS submissiongrade, ag.gradinggrade
FROM {user} u
Please sign in to comment.
Something went wrong with that request. Please try again.