]> git.mjollnir.org Git - moodle.git/commitdiff
Added timeopen and timeclose (instead of days) and did a few cleanups
authormoodler <moodler>
Tue, 15 Oct 2002 16:22:18 +0000 (16:22 +0000)
committermoodler <moodler>
Tue, 15 Oct 2002 16:22:18 +0000 (16:22 +0000)
lang/en/moodle.php
lang/en/quiz.php
mod/quiz/db/mysql.sql
mod/quiz/lib.php
mod/quiz/mod.html
mod/quiz/multichoice.html
mod/quiz/shortanswer.html
mod/quiz/truefalse.html
mod/quiz/view.php

index d705b48136c21e31b5fa7b81c5f0f7b1373cb15f..8d445678f62ae9e2177042f9fd9f8e0313681116 100644 (file)
@@ -337,7 +337,9 @@ $string['never'] = "Never";
 $string['no'] = "No";
 $string['nocoursesyet'] = "No courses in this category";
 $string['noexistingteachers'] = "No existing teachers";
+$string['nofilesyet'] = "No files have been uploaded to your course yet";
 $string['nograde'] = "No grade";
+$string['noimagesyet'] = "No images have been uploaded to your course yet";
 $string['none'] = "None";
 $string['nopotentialteachers'] = "No potential teachers";
 $string['normal'] = "Normal";
index 8bf38ff845e8e778b7228f1bd42b9185417ddda4..65e2ad4bb74747b2c73aea708c7e335b0714f8d3 100644 (file)
@@ -52,6 +52,11 @@ $string['nomoreattempts'] = "No more attempts are allowed";
 $string['noquestions'] = "No questions have been added yet";
 $string['question'] = "Question";
 $string['questionname'] = "Question name";
+$string['quizavailable'] = "The quiz is available until: \$a";
+$string['quizclose'] = "Close the quiz";
+$string['quizclosed'] = "This quiz closed on \$a";
+$string['quizopen'] = "Open the quiz";
+$string['quiznotavailable'] = "The quiz will not be available until: \$a";
 $string['rename'] = "Rename";
 $string['report'] = "Reports";
 $string['save'] = "Save";
index e76a618dadf01ace7e609b016e31d16598685f86..9755e761a71479e3be3fe265112c91aa5b2bf4da 100644 (file)
@@ -3,7 +3,7 @@
 # http://www.phpmyadmin.net/ (download page)
 #
 # Host: localhost
-# Generation Time: Oct 15, 2002 at 08:22 PM
+# Generation Time: Oct 16, 2002 at 12:20 AM
 # Server version: 3.23.49
 # PHP Version: 4.2.3
 # Database : `moodle`
@@ -18,7 +18,8 @@ CREATE TABLE `quiz` (
   `course` int(10) unsigned NOT NULL default '0',
   `name` varchar(255) NOT NULL default '',
   `intro` text NOT NULL,
-  `days` smallint(6) NOT NULL default '0',
+  `timeopen` int(10) unsigned NOT NULL default '0',
+  `timeclose` int(10) unsigned NOT NULL default '0',
   `attempts` smallint(6) NOT NULL default '0',
   `feedback` tinyint(4) NOT NULL default '0',
   `correctanswers` tinyint(4) NOT NULL default '1',
index 3489c5bd1e8c5594429ca8fb2b99ea6886a675d4..06fda944b25195d5bfa02a9939eb4b11562db137 100644 (file)
@@ -30,7 +30,12 @@ function quiz_add_instance($quiz) {
 /// will create a new instance and return the id number 
 /// of the new instance.
 
+    $quiz->created      = time();
     $quiz->timemodified = time();
+    $quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, 
+                                     $quiz->openhour, $quiz->openminute, $quiz->opensecond);
+    $quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, 
+                                      $quiz->closehour, $quiz->closeminute, $quiz->closesecond);
 
     if (!$quiz->id = insert_record("quiz", $quiz)) {
         return false;  // some error occurred
@@ -61,6 +66,10 @@ function quiz_update_instance($quiz) {
 /// will update an existing instance with new data.
 
     $quiz->timemodified = time();
+    $quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, 
+                                     $quiz->openhour, $quiz->openminute, $quiz->opensecond);
+    $quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, 
+                                      $quiz->closehour, $quiz->closeminute, $quiz->closesecond);
     $quiz->id = $quiz->instance;
 
     if (!update_record("quiz", $quiz)) {
index 2a6f29cf7080742321f516350e840759c065b129..5fb1ccc0307055ba4ef7549ace1cc81818153391 100644 (file)
     </TD>
 </TR>
 <TR valign=top>
-    <TD align=right><P><B><? print_string("daysavailable", "quiz") ?>:</B></P></TD>
+    <TD align=right><P><B><? print_string("quizopen", "quiz") ?>:</B></P></TD>
     <TD>
     <?
-        $options = array();
-        $options[0] = get_string("alwaysavailable", "quiz");
-        for ($i=1;$i<=13;$i++) {
-            $options[$i] = get_string("numdays", "", $i);
-        }
-        for ($i=2;$i<=16;$i++) {
-            $days = $i * 7;
-            $options[$days] = get_string("numweeks", "", $i);
-        }
-        $options[365] = get_string("numweeks", "", 52);
-        if ($form->days == "") {
-            $form->days == "14";
+        if (!$form->timeopen and $course->format == "weeks") {
+            $form->timeopen  = $course->startdate + (($form->section - 1) * 608400);
         }
-        choose_from_menu($options, "days", "$form->days", "");
+        print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
+        print_time_selector("openhour", "openminute", $form->timeopen);
      ?>
     </TD>
 </TR>
+<TR valign=top>
+    <TD align=right><P><B><? print_string("quizclose", "quiz") ?>:</B></P></TD>
+    <TD>
+    <?
+        if (!$form->timeclose and $course->format == "weeks") {
+            $form->timeclose  = $course->startdate + (($form->section) * 608400);
+        }
+        print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
+        print_time_selector("closehour", "closeminute", $form->timeclose);
+     ?>
+    </TD>
 <TR valign=top>
     <TD align=right><P><B><? print_string("attemptsallowed", "quiz") ?>:</B></P></TD>
     <TD>
index e727ff0bcbf378cc4f1498b4b6fc64904b9e5bd5..a6b8e57df64e7d1325d5f2f2ccf9506267edc42f 100644 (file)
 <TR valign=top>\r
     <TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
-    <?  choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>\r
+    <?  if (!$images) {\r
+            print_string("noimagesyet");\r
+        } else {\r
+            choose_from_menu($images, "image", "$question->image", get_string("none"),"","");\r
+        }\r
+    ?>\r
     </TD>\r
 </TR>\r
 <TR valign=top>\r
index 703921ccc2b8971f227e599d0884051e9796a6e8..0fd7a112571d405a0acf5df4714fd8aeb4208872 100644 (file)
 <TR valign=top>\r
     <TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
-    <?  choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>\r
+    <?  if (!$images) {\r
+            print_string("noimagesyet");\r
+        } else {\r
+            choose_from_menu($images, "image", "$question->image", get_string("none"),"","");\r
+        }\r
+    ?>\r
     </TD>\r
 </TR>\r
 <TR valign=top>\r
index 7ec480a697e704bca625255645fe13fdfebe9ca1..fd2184c10dda3e8ed5963443bf81876cbacb6561 100644 (file)
 <TR valign=top>\r
     <TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>\r
     <TD>\r
-    <?  choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>\r
+    <?  if (!$images) {\r
+            print_string("noimagesyet");\r
+        } else {\r
+            choose_from_menu($images, "image", "$question->image", get_string("none"),"","");\r
+        }\r
+    ?>\r
     </TD>\r
 </TR>\r
 \r
index dfdb4d95ce37506757b97f6225fed0fdfe37fadd..191895545453e06c0a154e49565df38794c938d7 100644 (file)
 
     add_to_log($course->id, "quiz", "view", "view.php?id=$cm->id", "$quiz->id");
 
-    if ($course->format == "weeks" and $quiz->days) {
-        $timenow = time();
-        $timestart = $course->startdate + (($cw->section - 1) * 608400);
-        $timefinish = $timestart + (3600 * 24 * $quiz->days);
-        $available = ($timestart < $timenow and $timenow < $timefinish);
-    } else {
-        $available = true;
-    }
+    $timenow = time();
+    $available = ($quiz->timeopen < $timenow and $timenow < $quiz->timeclose);
 
 // Print the page header
 
 
     print_simple_box($quiz->intro, "CENTER");
 
-    if (isset($timestart) and isset($timefinish)) {
-        if ($available) {
-            echo "<P ALIGN=CENTER>The quiz is available: ";
-        } else {
-            echo "<P ALIGN=CENTER>The quiz is not available: ";
-        }
-        echo userdate($timestart)." - ".userdate($timefinish)." </P>";
+    if ($available) {
+        echo "<P ALIGN=CENTER>".get_string("quizavailable", "quiz", userdate($quiz->timeclose));
+    } else if ($timenow < $quiz->timeopen) {
+        echo "<P ALIGN=CENTER>".get_string("quiznotavailable", "quiz", userdate($quiz->timeopen));
+    } else {
+        echo "<P ALIGN=CENTER>".get_string("quizclosed", "quiz", userdate($quiz->timeclose));
     }
 
     if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) {