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...
1 parent 020f0ff commit 308e53f572c5823e3d849226482193f391643f22 @mudrd8mz mudrd8mz committed Jul 7, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 mod/workshop/locallib.php
View
7 mod/workshop/locallib.php
@@ -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

0 comments on commit 308e53f

Please sign in to comment.