From 239d185a75b6943bc4229a3914f550bd6ffc8c83 Mon Sep 17 00:00:00 2001 From: defacer Date: Thu, 10 Mar 2005 16:40:13 +0000 Subject: [PATCH] Updating the overview screen "sort by question grade" hack to work with the multiple sort column suppport. --- mod/quiz/report/overview/report.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index d18b7984e65..5dee9d511ac 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -136,14 +136,24 @@ class quiz_report extends quiz_default_report { } if($sort = $table->get_sql_sort()) { - if(substr($sort, 0, 1) == '$') { - $qnum = intval(substr($sort, 1)); - $where.= '('.sql_isnull('qr.question').' OR qr.question = '.$qnum.') AND '; - $sort = ' ORDER BY grade '.(strpos($sort, 'ASC')? 'ASC' : 'DESC'); - } - else { - $sort = ' ORDER BY '.$sort; + $sortparts = explode(',', $sort); + $newsort = array(); + $firsttime = true; + foreach($sortparts as $sortpart) { + $sortpart = trim($sortpart); + if(substr($sortpart, 0, 1) == '$') { + if($firsttime) { + $qnum = intval(substr($sortpart, 1)); + $where .= '('.sql_isnull('qr.question').' OR qr.question = '.$qnum.') AND '; + $newsort[] = 'grade '.(strpos($sortpart, 'ASC')? 'ASC' : 'DESC'); + $firsttime = false; + } + } + else { + $newsort[] = $sortpart; + } } + $sort = ' ORDER BY '.implode(', ', $newsort); } $select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uvsa, u.id AS userid, u.firstname, u.lastname, u.picture, qa.id AS attempt, qa.sumgrades, qa.timefinish, qa.timefinish - qa.timestart AS duration ';