Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added timeopen and timeclose (instead of days) and did a few cleanups

  • Loading branch information...
commit 49dcdd18005887972a7ba0342342372dd17e4d16 1 parent d197118
moodler authored
View
2  lang/en/moodle.php
@@ -337,7 +337,9 @@
$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";
View
5 lang/en/quiz.php
@@ -52,6 +52,11 @@
$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";
View
5 mod/quiz/db/mysql.sql
@@ -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',
View
9 mod/quiz/lib.php
@@ -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)) {
View
30 mod/quiz/mod.html
@@ -20,27 +20,29 @@
</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>
<?
View
7 mod/quiz/multichoice.html
@@ -23,7 +23,12 @@
<TR valign=top>
<TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>
<TD>
- <? choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>
+ <? if (!$images) {
+ print_string("noimagesyet");
+ } else {
+ choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
+ }
+ ?>
</TD>
</TR>
<TR valign=top>
View
7 mod/quiz/shortanswer.html
@@ -23,7 +23,12 @@
<TR valign=top>
<TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>
<TD>
- <? choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>
+ <? if (!$images) {
+ print_string("noimagesyet");
+ } else {
+ choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
+ }
+ ?>
</TD>
</TR>
<TR valign=top>
View
7 mod/quiz/truefalse.html
@@ -23,7 +23,12 @@
<TR valign=top>
<TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>
<TD>
- <? choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>
+ <? if (!$images) {
+ print_string("noimagesyet");
+ } else {
+ choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
+ }
+ ?>
</TD>
</TR>
View
23 mod/quiz/view.php
@@ -37,14 +37,8 @@
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
@@ -74,13 +68,12 @@
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)) {
Please sign in to comment.
Something went wrong with that request. Please try again.