From 78517b5a6bb16cb46e967766cecf57289b496206 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Wed, 12 Apr 2006 22:48:58 +0000 Subject: [PATCH] Don't show users who have unenrolled. Show display options also when current options lead to empty table. --- mod/quiz/report/overview/report.php | 78 ++++++++++++++--------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index 9f03e554a9..e364170b78 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -256,17 +256,14 @@ class quiz_report extends quiz_default_report { // noattempts = 1 means only no attempts, so make the left join ask for only records where the right is null (no attempts) $where .= ' AND qa.userid IS NULL'; // show ONLY no attempts; } // no else, the left join is not filtered, which means we get both back. - } else if (empty($currentgroup) && empty($noattempts)) { - // We don't care about group, and we only want to see students WITH attempts. - // So just do a striaght inner join on attempts, don't worry about the groups_members table - $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid '; - $where = ' WHERE qa.quiz = '.$quiz->id.' AND qa.preview = 0'; - } else if (empty($currentgroup) && !empty($noattempts)) { + } else if (empty($currentgroup)) { // We don't care about group, and we to do something funky with attempts // So do a left join on attempts $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id; - $where = ' WHERE us.course = '.$course->id; - if ($noattempts == 1) { + $where = " WHERE us.course = '$course->id'"; + if (empty($noattempts)) { + $where .= ' AND qa.userid IS NOT NULL'; // show ONLY attempts; + } elseif ($noattempts == 1) { // noattempts = 1 means only no attempts, so make the left join ask for only records where the right is null (no attempts) $where .= ' AND qa.userid IS NULL'; // show ONLY no attempts; } // no else, the left join is not filtered, which means we get both back. @@ -462,38 +459,6 @@ class quiz_report extends quiz_default_report { } /// Close form echo ''; - /// Print display options - echo '
'; - echo '
'; - echo '

'.get_string('displayoptions', 'quiz').':

'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'; - $options = array(0 => $strattemptsonly); - if ($course->id != SITEID) { - $options[1] = $strnoattemptsonly; - $options[2] = $strbothattempts; - } - choose_from_menu($options,'noattempts',$noattempts,''); - echo '
'; - echo '
'; - echo ''; - echo '
'; - echo '
'; - echo '
'; - echo "\n"; if (!empty($attempts)) { echo ''; @@ -530,6 +495,39 @@ class quiz_report extends quiz_default_report { $table->print_html(); } } + /// Print display options + echo '
'; + echo '
'; + echo '

'.get_string('displayoptions', 'quiz').':

'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + $options = array(0 => $strattemptsonly); + if ($course->id != SITEID) { + $options[1] = $strnoattemptsonly; + $options[2] = $strbothattempts; + } + choose_from_menu($options,'noattempts',$noattempts,''); + echo '
'; + echo '
'; + echo ''; + echo '
'; + echo ''; + echo ''; + echo "\n"; + return true; } } -- 2.39.5