From dbf8f55057cc6ecb0a0b8d3ac2c1c5e3393e1f13 Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 25 May 2005 17:54:58 +0000 Subject: [PATCH] Er, fix for bug 3334 once more. If at first you don't succeed... --- mod/quiz/attempts.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mod/quiz/attempts.php b/mod/quiz/attempts.php index 801df791998..f884fbfd169 100644 --- a/mod/quiz/attempts.php +++ b/mod/quiz/attempts.php @@ -234,12 +234,17 @@ $select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, qa.id AS attempt, u.id AS userid, u.firstname, u.lastname, u.picture, '. 'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration '; - $from = 'FROM mdl_user u LEFT JOIN mdl_quiz_attempts qa ON u.id = qa.userid '; - $where = 'WHERE u.id IN ('.implode(',', array_keys($users)).') AND ('.($noattempts ? sql_isnull('qa.quiz').' OR ' : '') . 'qa.quiz = '.$quiz->id.') '; + $from = 'FROM mdl_user u LEFT JOIN mdl_quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = '.$quiz->id.') '; + $where = 'WHERE u.id IN ('.implode(',', array_keys($users)).') '; + + // Add extra limits if we 're not interested in students without attempts + if(!$noattempts) { + $where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 '; + } // Add extra limits due to initials bar if($table->get_sql_where()) { - $where .= ' AND '.$table->get_sql_where(); + $where .= 'AND '.$table->get_sql_where(); } // Count the records NOW, before funky question grade sorting messes up $from