]> git.mjollnir.org Git - moodle.git/commitdiff
Now there is an option to see all attempts, even for users who have since unenrolled...
authorgustav_delius <gustav_delius>
Thu, 13 Apr 2006 00:02:36 +0000 (00:02 +0000)
committergustav_delius <gustav_delius>
Thu, 13 Apr 2006 00:02:36 +0000 (00:02 +0000)
lang/en_utf8/quiz_overview.php
mod/quiz/report/overview/report.php

index 04373eea482ad60de7b085759f5dad38a7654ff0..216686011ead1840b4b5d24b15ae61e8b2522e52 100644 (file)
@@ -2,4 +2,9 @@
 
 $string['overview'] = 'Overview';
 
+$string['attemptsonly'] = 'Show $a with attempts only';
+$string['allattempts'] = 'Show all attempts';
+$string['allstudents'] = 'Show all $a';
+$string['noattemptsonly'] = 'Show $a with no attempts only';
+
 ?>
index 0005d9a6ba9b72f05ed386734f021463a8117c75..98f7eebe6c505bfe340e35d5ab2f29d9fc542609 100644 (file)
@@ -11,10 +11,6 @@ class quiz_report extends quiz_default_report {
 
     /// Define some strings
         $strreallydel  = addslashes(get_string('deleteattemptcheck','quiz'));
-        $strnoattempts = get_string('noattempts','quiz');
-        $strnoattemptsonly = get_string('shownoattemptsonly', 'quiz');
-        $strattemptsonly = get_string('attemptsonly','quiz');
-        $strbothattempts = get_string('bothattempts','quiz');
         $strtimeformat = get_string('strftimedatetime');
         $strreviewquestion = get_string('reviewresponse', 'quiz');
 
@@ -267,11 +263,15 @@ class quiz_report extends quiz_default_report {
                 $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 (empty($noattempts)) {
-                    $where .= ' AND qa.userid IS NOT NULL'; // show ONLY attempts;
+                    $where .= ' AND qa.userid IS NOT NULL'; // show ONLY students with 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.
+                    $where .= ' AND qa.userid IS NULL'; // show ONLY students without attempts;
+                } elseif ($noattempts == 3) {
+                    // we want all attempts
+                    $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';
+                } // noattempts = 2 means we want all students, with or without attempts
             }
             $countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
         } else {
@@ -516,10 +516,11 @@ class quiz_report extends quiz_default_report {
         echo '</tr>';
         echo '<tr align="left">';
         echo '<td colspan="2">';
-        $options = array(0 => $strattemptsonly);
+        $options = array(0 => get_string('attemptsonly','quiz_overview', $course->students));
         if ($course->id != SITEID) {
-            $options[1] = $strnoattemptsonly;
-            $options[2] = $strbothattempts;
+            $options[1] = get_string('noattemptsonly', 'quiz_overview', $course->students);
+            $options[2] = get_string('allstudents','quiz_overview', $course->students);
+            $options[3] = get_string('allattempts','quiz_overview');
         }
         choose_from_menu($options,'noattempts',$noattempts,'');
         echo '</td></tr>';