]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed display of information about existing attempts.
authorgustav_delius <gustav_delius>
Wed, 12 Apr 2006 23:24:58 +0000 (23:24 +0000)
committergustav_delius <gustav_delius>
Wed, 12 Apr 2006 23:24:58 +0000 (23:24 +0000)
lang/en_utf8/quiz.php
mod/quiz/edit.php
mod/quiz/index.php
mod/quiz/report/overview/report.php
mod/quiz/view.php

index 97ee55342a1dea6673f082e72d9636cf08cde052..76280224976ef47a31bb71aa8240ddaed1bf8ade 100644 (file)
@@ -47,7 +47,7 @@ $string['attempts'] = 'Attempts';
 $string['attemptsonly'] = 'Show only students with attempts';
 $string['attemptsallowed'] = 'Attempts allowed';
 $string['attemptselection'] = 'Select which attempts to analyze per user: ';
-$string['attemptsexist'] = 'This quiz has already been attempted.<br />You can no longer add or remove questions.';
+$string['attemptsexist'] = 'You can no longer add or remove questions.';
 $string['attemptsunlimited'] = 'Unlimited attempts';
 $string['back'] = 'Back to preview question';
 $string['backtoquiz'] = 'Back to quiz editing';
@@ -305,6 +305,7 @@ $string['notavailabletostudents'] = 'Note: This quiz is not currently available
 $string['notenoughanswers'] = 'This type of question requires at least $a answers';
 $string['notenoughsubquestions'] = 'Not enough sub-questions have been defined!<br />Do you want to go back and fix this question?';
 $string['notimedependentitems'] = 'Time dependent items are not currently supported by the quiz module. As a work around, set a time limit for the whole quiz. Do you wish to choose a different item (or use the current item regardless)?';
+$string['numattempts'] = '$a->studentnum $a->studentstring have made $a->attemptnum attempts';
 $string['numberabbr'] = '#';
 $string['numerical'] = 'Numerical';
 $string['none']= 'None';
index 45ab9cc08a276fe2a7adf2e2e88ee8c0810609cc..81a7391ee5a5a89e065f183d50e5cfa140d6db70 100644 (file)
@@ -322,17 +322,14 @@ if (self.name == 'editquestion') {
 
         print_simple_box_start("center");
 
-        $attemptcount = count_records('quiz_attempts', 'quiz', $modform->instance, 'preview', 0);
-
-        $strviewallanswers  = get_string("viewallanswers","quiz",$attemptcount);
-        $strattemptsexist  = get_string("attemptsexist","quiz");
-        $usercount = count_records_select('quiz_attempts', "quiz = '$modform->id' AND preview = '0'", 'COUNT(DISTINCT userid)');
-        $strusers  = $course->students;
+        $a->attemptnum = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0);
+        $a->studentnum = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)');
+        $a->studentstring  = $course->students;
         if (! $cm = get_coursemodule_from_instance("quiz", $modform->instance, $course->id)) {
             error("Course Module ID was incorrect");
         }
         echo "<center>\n";
-        echo "$strattemptsexist<br /><a href=\"report.php?mode=overview&amp;id=$cm->id\">$strviewallanswers ($usercount $strusers)</a>";
+        echo "<a href=\"report.php?mode=overview&amp;id=$cm->id\">".get_string('numattempts', 'quiz', $a)."</a><br />".get_string("attemptsexist","quiz");
         echo "</center><br/ >\n";
 
         $sumgrades = quiz_print_question_list($modform, false, $SESSION->quiz_showbreaks, $SESSION->quiz_reordertool);
index cd3ce6a3dd667f3eccacf844f4b98c53c1fef0c1..71c0f335375d64b265dd506ec528ff70501d0b38 100644 (file)
         $closequiz = $quiz->timeclose ? userdate($quiz->timeclose) : '';
 
         if (isteacher($course->id)) {
-            if ($usercount = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)')) {
-                $attemptcount = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0);
-                $strviewallreports  = get_string('viewallreports', 'quiz', $attemptcount);
-                $gradecol = "<a href=\"report.php?mode=overview&amp;q=$quiz->id\">$strviewallreports ($usercount $strusers)</a>";
+            if ($a->attemptnum = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0)) {
+                $a->studentnum = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)');
+                $a->studentstring  = $course->students;
+                $gradecol = "<a href=\"report.php?mode=overview&amp;q=$quiz->id\">".get_string('numattempts', 'quiz', $a).'</a>';
             } else {
-                $answercount = 0;
                 $gradecol = "";
             }
         } else {
index 1dfdbd39315de1a1507fc05004419ff6ec697be4..0005d9a6ba9b72f05ed386734f021463a8117c75 100644 (file)
@@ -62,7 +62,13 @@ class quiz_report extends quiz_default_report {
                 }
             break;
         }
-
+    /// Print information on the number of existing attempts
+        if ($a->attemptnum = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0)) {
+            $a->studentnum = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)');
+            $a->studentstring  = $course->students;
+    
+            notify(get_string('numattempts', 'quiz', $a));
+        }
     /// Check to see if groups are being used in this quiz
         if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
             if (!$download) {
index fac72b62b56f133aaccb0bd217c1c07af2001bf8..daf996974850eb7acfdeddd143ace5a3ee0ec79c 100644 (file)
 
     // This is all the teacher will get
     if ($isteacher) {
-        
-        if ($attemptcount = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0)) {
-
-            $strviewallanswers  = get_string("viewallanswers", "quiz", $attemptcount);
-            $usercount = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)');
-            $strusers  = $course->students;
+        if ($a->attemptnum = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0)) {
+            $a->studentnum = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)');
+            $a->studentstring  = $course->students;
     
-            notify("<a href=\"report.php?mode=overview&amp;id=$cm->id\">$strviewallanswers ($usercount $strusers)</a>");
+            notify("<a href=\"report.php?mode=overview&amp;id=$cm->id\">".get_string('numattempts', 'quiz', $a).'</a>');
         }
         
         echo '</td></tr></table>';