]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes for quiztimer.
authorjulmis <julmis>
Sun, 20 Jun 2004 10:57:27 +0000 (10:57 +0000)
committerjulmis <julmis>
Sun, 20 Jun 2004 10:57:27 +0000 (10:57 +0000)
- Lets make cheating more complicated, more javascript based.
- Mark attempt to zero if time limit is exceeded over 60 seconds

mod/quiz/attempt.php
mod/quiz/jstimer.php
mod/quiz/lib.php

index b16adfeac6d1ae8f5fae0f9a178731b8acc0409c..2051fb0809b938b19a5de1a724190842344e0434 100644 (file)
             error("Could not grade your quiz attempt!");
         }
 
+        if($timelimit > 0) {
+            if(($timelimit + 60) <= $timesincestart) {
+                $result->sumgrades = 0;
+            }
+        }
+
         if ($attempt = quiz_save_attempt($quiz, $questions, $result, $attemptnumber)) {
             add_to_log($course->id, "quiz", "submit", 
                        "review.php?id=$cm->id&attempt=$attempt->id", "$quiz->id", $cm->id);
index 3d0b4585429a3eb9584a0e58bfcba96d3f1f2820..dec7ce5cf48b83a7114a516e317a5a581e47f2a4 100644 (file)
@@ -6,6 +6,10 @@
     ?>
 <script language="javascript" type="text/javascript">
 <!--
+function send_data() {
+    document.forms[0].submit();
+    return true;
+}
 
 var timesup = "<?php print_string("timesup","quiz");?>";
 var quizclose = <?php echo ($quiz->timeclose - time()) - $timerstartvalue; ?>; // in seconds
index 27da0de875ab909322d9d872d62be4d118116b1d..d22e6deecd3a1aa394876499f87b3b0aa2827518 100644 (file)
@@ -1187,7 +1187,7 @@ function quiz_print_quiz_questions($quiz, $results=NULL, $questions=NULL, $shuff
         // -->
         </script>
         <noscript>
-        <center><p><strong>Javascript must be enabled!</strong></p></center>
+        <center><p><strong><?php print_string("noscript","quiz"); ?></strong></p></center>
         </noscript>
         <?php
     } else {
@@ -1256,8 +1256,19 @@ function quiz_print_quiz_questions($quiz, $results=NULL, $questions=NULL, $shuff
             $shuffleorder = implode(',', $questionorder);
             echo "<input type=\"hidden\" name=\"shuffleorder\" value=\"$shuffleorder\" />\n";
         }
+        if($quiz->timelimit > 0) {
+            echo "<script language=\"javascript\" type=\"text/javascript\">\n";
+            echo "<!--\n";
+            echo "document.write('<center><input type=\"button\" value=\"".get_string("savemyanswers", "quiz")."\" onclick=\"return send_data();\" /></center>');\n";
+            echo "// -->\n";
+            echo "</script>\n";
+            echo "<noscript>\n";
+            echo "<center><strong>".get_string("noscript","quiz")."</strong></center>\n";
+            echo "</noscript>\n";
+        } else {
         echo "<center>\n<input type=\"submit\" value=\"".get_string("savemyanswers", "quiz")."\" />\n</center>";
     }
+    }
     echo "</form>";
 
     return true;