]> git.mjollnir.org Git - moodle.git/commitdiff
Many little fixes and cleanups for robustness
authormoodler <moodler>
Mon, 30 Dec 2002 05:10:01 +0000 (05:10 +0000)
committermoodler <moodler>
Mon, 30 Dec 2002 05:10:01 +0000 (05:10 +0000)
lang/en/quiz.php
mod/quiz/attempt.php
mod/quiz/category.php
mod/quiz/edit.php
mod/quiz/lib.php
mod/quiz/multichoice.html
mod/quiz/question.php
mod/quiz/shortanswer.html
mod/quiz/truefalse.html

index 220250fa102fa1ac0b0d43473bcad28eb4eabd44..e5eb1ace21a3f1cdacfa32836b53d61871427cee 100644 (file)
@@ -61,6 +61,8 @@ $string['guestsno'] = "Sorry, guests can not see or attempt quizzes";
 $string['imagedisplay'] = "Image to display";
 $string['introduction'] = "Introduction";
 $string['marks'] = "Marks";
+$string['missingname'] = "Missing question name";
+$string['missingquestiontext'] = "Missing question text";
 $string['multichoice'] = "Multiple Choice";
 $string['noanswers'] = "No answers were selected!";
 $string['noattempts'] = "No attempts have been made on this quiz";
index 3e92c67d10ad3cd74581ed61e45c7f4187774abb..a3831756545acfad9d8b56ad23eb68982d6d4598 100644 (file)
         }
     }
 
-    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);
 
 /// Check to see if they are submitting answers
     if (match_referer() && isset($HTTP_POST_VARS)) {
index 8186c16e75800372aa325cb6f8bd4002c2b3991a..eb55e6521b386c0951e1a7f329b6f53fddddefcf 100644 (file)
@@ -83,7 +83,7 @@
 
     echo "<P ALIGN=CENTER><FONT SIZE=3>";
     echo $streditcategories;
-    helpbutton("categories", $strcategories, "quiz");
+    helpbutton("categories", $streditcategories, "quiz");
     echo "</FONT></P>";
 
 /// If data submitted, then process and store.
index dd186ed3fa97da9371a803fe4876eb4d66a691cc..511055b1183f32fbe28342de7c2af549c9402fce 100644 (file)
@@ -5,10 +5,14 @@
 
     require_login();
 
+    if (empty($destination)) {
+        $destination = "";
+    }
+
     if (match_referer($destination) && isset($course) && isset($HTTP_POST_VARS)) {    // form submitted from mod.html
         $modform = (object)$HTTP_POST_VARS;
 
-        if (!$modform->name or !$modform->intro) {
+        if (empty($modform->name) or empty($modform->intro)) {
             error(get_string("filloutallfields"), $HTTP_REFERER);
         }
 
         error("You can't modify this course!");
     }
 
-    if (! $modform->grades) {  // Construct an array to hold all the grades.
+    if (empty($modform->grades)) {  // Construct an array to hold all the grades.
         $modform->grades = quiz_get_all_question_grades($modform->questions, $modform->instance);
     }
 
 
     // Now, check for commands on this page and modify variables as necessary
 
-    if ($up) { /// Move the given question up a slot
+    if (!empty($up)) { /// Move the given question up a slot
         $questions = explode(",", $modform->questions);
         if ($questions[0] <> $up) {
             foreach ($questions as $key => $question) {
@@ -56,7 +60,7 @@
         }
     }
 
-    if ($down) { /// Move the given question down a slot
+    if (!empty($down)) { /// Move the given question down a slot
         $questions = explode(",", $modform->questions);
         if ($questions[count($questions)-1] <> $down) {
             foreach ($questions as $key => $question) {
@@ -71,9 +75,9 @@
         }
     }
 
-    if ($add) { /// Add a question to the current quiz
+    if (!empty($add)) { /// Add a question to the current quiz
         $rawquestions = $HTTP_POST_VARS;
-        if ($modform->questions) {
+        if (!empty($modform->questions)) {
             $questions = explode(",", $modform->questions);
         }
         foreach ($rawquestions as $key => $value) {    // Parse input for question ids
                 $modform->grades[$key] = 1;   // default score
             }
         }
-        if ($questions) {
+        if (!empty($questions)) {
             $modform->questions = implode(",", $questions);
         } else {
             $modform->questions = "";
         }
     }
 
-    if ($delete) { /// Delete a question from the list 
+    if (!empty($delete)) { /// Delete a question from the list 
         $questions = explode(",", $modform->questions);
         foreach ($questions as $key => $question) {
             if ($question == $delete) {
         $modform->questions = implode(",", $questions);
     }
 
-    if ($setgrades) { /// The grades have been updated, so update our internal list
+    if (!empty($setgrades)) { /// The grades have been updated, so update our internal list
         $rawgrades = $HTTP_POST_VARS;
         unset($modform->grades);
         foreach ($rawgrades as $key => $value) {    // Parse input for question -> grades
         }
     }
 
-    if ($cat) { //-----------------------------------------------------------
+    if (!empty($cat)) { //-----------------------------------------------------------
         $modform->category = $cat;
     }
 
+    if (empty($modform->category)) {
+        $modform->category = "";
+    }
+
     $modform->sumgrades = 0;
-    if ($modform->grades) {
+    if (!empty($modform->grades)) {
         foreach ($modform->grades as $grade) {
             $modform->sumgrades += $grade;
         }
index 853ecb3018bff2281473b7eaec59c7849bf1245a..241d31b54e401b65fbeb7445b9f083f728f3c284 100644 (file)
@@ -34,9 +34,9 @@ function quiz_add_instance($quiz) {
     $quiz->created      = time();
     $quiz->timemodified = time();
     $quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, 
-                                     $quiz->openhour, $quiz->openminute, $quiz->opensecond);
+                                     $quiz->openhour, $quiz->openminute, 0);
     $quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, 
-                                      $quiz->closehour, $quiz->closeminute, $quiz->closesecond);
+                                      $quiz->closehour, $quiz->closeminute, 0);
 
     if (!$quiz->id = insert_record("quiz", $quiz)) {
         return false;  // some error occurred
@@ -68,9 +68,9 @@ function quiz_update_instance($quiz) {
 
     $quiz->timemodified = time();
     $quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, 
-                                     $quiz->openhour, $quiz->openminute, $quiz->opensecond);
+                                     $quiz->openhour, $quiz->openminute, 0);
     $quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, 
-                                      $quiz->closehour, $quiz->closeminute, $quiz->closesecond);
+                                      $quiz->closehour, $quiz->closeminute, 0);
     $quiz->id = $quiz->instance;
 
     if (!update_record("quiz", $quiz)) {
index 01794f7cac1c0b9cfc545faad8332ca90249c5a0..942da9df3499e211ec759b195b3ad5d543e3d5d4 100644 (file)
     <TD align=right><P><B><? print_string("questionname", "quiz") ?>:</B></P></TD>\r
     <TD>\r
         <INPUT type="text" name="name" size=40 value="<? p($question->name) ?>">\r
+        <? if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
 <TR valign=top>\r
     <TD align=right><P><B><? print_string("question", "quiz") ?>:</B></P></TD>\r
     <TD>\r
+        <? if (isset($err["questiontext"])) {\r
+               formerr($err["questiontext"]); \r
+               echo "<BR \>";\r
+           }\r
+        ?>\r
         <textarea name="questiontext" rows=5 cols=50 wrap="virtual"><? p($question->questiontext)?></textarea>\r
         <? helpbutton("text", get_string("helptext")); ?>\r
     </TD>\r
     <TD align=right><P><B><? print_string("answerhowmany", "quiz") ?>:</B></P></TD>\r
     <TD>\r
     <?\r
-        unset($menu);\r
         $menu[0] = get_string("answersingleno", "quiz");\r
         $menu[1] = get_string("answersingleyes", "quiz");\r
         choose_from_menu($menu, "single", "$options->single", "");\r
+        unset($menu);\r
      ?>\r
     </TD>\r
 </TR>\r
index 75e5379c34d7cf5fa8250b7f99d789cdcc11f3c4..1806adfa97017f8f011ee2de952eff052177a38a 100644 (file)
@@ -51,7 +51,7 @@
 
     print_header("$course->shortname: $streditingquestion", "$course->shortname: $streditingquestion",
                  "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
-                  -> <A HREF=\"$HTTP_REFERER\">$streditingquiz</A> -> $streditingquestion");
+                  -> <A HREF=\"edit.php\">$streditingquiz</A> -> $streditingquestion");
 
     if (isset($delete)) {
         if (isset($confirm)) {
         $question->image        = $form->image;
         $question->category     = $form->category;
 
-        if ($question->id) { // Question already exists
-            if (!update_record("quiz_questions", $question)) {
-                error("Could not update question!");
-            }
-        } else {         // Question is a new one
-            if (!$question->id = insert_record("quiz_questions", $question)) {
-                error("Could not insert new question!");
-            }
-        }
-
-        // Now to save all the answers and type-specific options
-
-        switch ($question->type) {
-            case SHORTANSWER:
-                // Delete all the old answers
-                delete_records("quiz_answers", "question", $question->id);
-                delete_records("quiz_shortanswer", "question", $question->id);
-
-                $answers = array();
-                $maxfraction = -1;
-
-                // Insert all the new answers
-                foreach ($form->answer as $key => $formanswer) {
-                    if ($formanswer) {
-                        unset($answer);
-                        $answer->answer   = $formanswer;
-                        $answer->question = $question->id;
-                        $answer->fraction = $fraction[$key];
-                        $answer->feedback = $feedback[$key];
-                        if (!$answer->id = insert_record("quiz_answers", $answer)) {
-                            error("Could not insert quiz answer!");
-                        }
-                        $answers[] = $answer->id;
-                        if ($fraction[$key] > $maxfraction) {
-                            $maxfraction = $fraction[$key];
-                        }
-                    }
-                }
+        if (!$err = formcheck($question)) {
 
-                unset($options);
-                $options->question = $question->id;
-                $options->answers = implode(",",$answers);
-                $options->usecase = $form->usecase;
-                if (!insert_record("quiz_shortanswer", $options)) {
-                    error("Could not insert quiz shortanswer options!");
+            if (!empty($question->id)) { // Question already exists
+                if (!update_record("quiz_questions", $question)) {
+                    error("Could not update question!");
                 }
-
-                /// Perform sanity checks on fractional grades
-                if ($maxfraction != 1) {
-                    $maxfraction = $maxfraction * 100;
-                    notice_yesno(get_string("fractionsnomax", "quiz", $maxfraction), "question.php?id=$question->id", "edit.php");
-                    print_footer($course);
-                    exit;
-                }
-            break;
-            case TRUEFALSE:
-                delete_records("quiz_answers", "question", $question->id);
-                delete_records("quiz_truefalse", "question", $question->id);
-
-                $true->answer   = get_string("true", "quiz");
-                $true->question = $question->id;
-                $true->fraction = $form->answer;
-                $true->feedback = $form->feedbacktrue;
-                if (!$true->id = insert_record("quiz_answers", $true)) {
-                    error("Could not insert quiz answer \"true\")!");
-                }
-
-                $false->answer   = get_string("false", "quiz");
-                $false->question = $question->id;
-                $false->fraction = 1 - (int)$form->answer;
-                $false->feedback = $form->feedbackfalse;
-                if (!$false->id = insert_record("quiz_answers", $false)) {
-                    error("Could not insert quiz answer \"false\")!");
+            } else {         // Question is a new one
+                if (!$question->id = insert_record("quiz_questions", $question)) {
+                    error("Could not insert new question!");
                 }
-
-                unset($options);
-                $options->question = $question->id;
-                $options->true     = $true->id;
-                $options->false    = $false->id;
-                if (!insert_record("quiz_truefalse", $options)) {
-                    error("Could not insert quiz truefalse options!");
-                }
-            break;
-            case MULTICHOICE:
-                delete_records("quiz_answers", "question", $question->id);
-                delete_records("quiz_multichoice", "question", $question->id);
-
-                $totalfraction = 0;
-                $maxfraction = -1;
-
-                $answers = array();
-
-                // Insert all the new answers
-                foreach ($form->answer as $key => $formanswer) {
-                    if ($formanswer) {
-                        unset($answer);
-                        $answer->answer   = $formanswer;
-                        $answer->question = $question->id;
-                        $answer->fraction = $fraction[$key];
-                        $answer->feedback = $feedback[$key];
-                        if (!$answer->id = insert_record("quiz_answers", $answer)) {
-                            error("Could not insert quiz answer!");
-                        }
-                        $answers[] = $answer->id;
-
-                        if ($fraction[$key] > 0) {                 // Sanity checks
-                            $totalfraction += $fraction[$key];
-                        }
-                        if ($fraction[$key] > $maxfraction) {
-                            $maxfraction = $fraction[$key];
+            }
+    
+            // Now to save all the answers and type-specific options
+    
+            switch ($question->type) {
+                case SHORTANSWER:
+                    // Delete all the old answers
+                    delete_records("quiz_answers", "question", $question->id);
+                    delete_records("quiz_shortanswer", "question", $question->id);
+    
+                    $answers = array();
+                    $maxfraction = -1;
+    
+                    // Insert all the new answers
+                    foreach ($form->answer as $key => $formanswer) {
+                        if ($formanswer) {
+                            unset($answer);
+                            $answer->answer   = $formanswer;
+                            $answer->question = $question->id;
+                            $answer->fraction = $fraction[$key];
+                            $answer->feedback = $feedback[$key];
+                            if (!$answer->id = insert_record("quiz_answers", $answer)) {
+                                error("Could not insert quiz answer!");
+                            }
+                            $answers[] = $answer->id;
+                            if ($fraction[$key] > $maxfraction) {
+                                $maxfraction = $fraction[$key];
+                            }
                         }
                     }
-                }
-
-                unset($options);
-                $options->question = $question->id;
-                $options->answers = implode(",",$answers);
-                $options->single = $form->single;
-                if (!insert_record("quiz_multichoice", $options)) {
-                    error("Could not insert quiz multichoice options!");
-                }
-
-                /// Perform sanity checks on fractional grades
-                if ($options->single) {
+    
+                    unset($options);
+                    $options->question = $question->id;
+                    $options->answers = implode(",",$answers);
+                    $options->usecase = $form->usecase;
+                    if (!insert_record("quiz_shortanswer", $options)) {
+                        error("Could not insert quiz shortanswer options!");
+                    }
+    
+                    /// Perform sanity checks on fractional grades
                     if ($maxfraction != 1) {
                         $maxfraction = $maxfraction * 100;
                         notice_yesno(get_string("fractionsnomax", "quiz", $maxfraction), "question.php?id=$question->id", "edit.php");
                         print_footer($course);
                         exit;
                     }
-                } else {
-                    $totalfraction = round($totalfraction,2);
-                    if ($totalfraction != 1) {
-                        $totalfraction = $totalfraction * 100;
-                        notice_yesno(get_string("fractionsaddwrong", "quiz", $totalfraction), "question.php?id=$question->id", "edit.php");
-                        print_footer($course);
-                        exit;
+                break;
+                case TRUEFALSE:
+                    delete_records("quiz_answers", "question", $question->id);
+                    delete_records("quiz_truefalse", "question", $question->id);
+    
+                    $true->answer   = get_string("true", "quiz");
+                    $true->question = $question->id;
+                    $true->fraction = $form->answer;
+                    $true->feedback = $form->feedbacktrue;
+                    if (!$true->id = insert_record("quiz_answers", $true)) {
+                        error("Could not insert quiz answer \"true\")!");
                     }
-                }
-            break;
-            case RANDOM:
-                echo "<P>Not supported yet</P>";
-            break;
-            default:
-                error("Non-existent question type!");
-            break;
+    
+                    $false->answer   = get_string("false", "quiz");
+                    $false->question = $question->id;
+                    $false->fraction = 1 - (int)$form->answer;
+                    $false->feedback = $form->feedbackfalse;
+                    if (!$false->id = insert_record("quiz_answers", $false)) {
+                        error("Could not insert quiz answer \"false\")!");
+                    }
+    
+                    unset($options);
+                    $options->question = $question->id;
+                    $options->true     = $true->id;
+                    $options->false    = $false->id;
+                    if (!insert_record("quiz_truefalse", $options)) {
+                        error("Could not insert quiz truefalse options!");
+                    }
+                break;
+                case MULTICHOICE:
+                    delete_records("quiz_answers", "question", $question->id);
+                    delete_records("quiz_multichoice", "question", $question->id);
+    
+                    $totalfraction = 0;
+                    $maxfraction = -1;
+    
+                    $answers = array();
+    
+                    // Insert all the new answers
+                    foreach ($form->answer as $key => $formanswer) {
+                        if ($formanswer) {
+                            unset($answer);
+                            $answer->answer   = $formanswer;
+                            $answer->question = $question->id;
+                            $answer->fraction = $fraction[$key];
+                            $answer->feedback = $feedback[$key];
+                            if (!$answer->id = insert_record("quiz_answers", $answer)) {
+                                error("Could not insert quiz answer!");
+                            }
+                            $answers[] = $answer->id;
+    
+                            if ($fraction[$key] > 0) {                 // Sanity checks
+                                $totalfraction += $fraction[$key];
+                            }
+                            if ($fraction[$key] > $maxfraction) {
+                                $maxfraction = $fraction[$key];
+                            }
+                        }
+                    }
+    
+                    unset($options);
+                    $options->question = $question->id;
+                    $options->answers = implode(",",$answers);
+                    $options->single = $form->single;
+                    if (!insert_record("quiz_multichoice", $options)) {
+                        error("Could not insert quiz multichoice options!");
+                    }
+    
+                    /// Perform sanity checks on fractional grades
+                    if ($options->single) {
+                        if ($maxfraction != 1) {
+                            $maxfraction = $maxfraction * 100;
+                            notice_yesno(get_string("fractionsnomax", "quiz", $maxfraction), "question.php?id=$question->id", "edit.php");
+                            print_footer($course);
+                            exit;
+                        }
+                    } else {
+                        $totalfraction = round($totalfraction,2);
+                        if ($totalfraction != 1) {
+                            $totalfraction = $totalfraction * 100;
+                            notice_yesno(get_string("fractionsaddwrong", "quiz", $totalfraction), "question.php?id=$question->id", "edit.php");
+                            print_footer($course);
+                            exit;
+                        }
+                    }
+                break;
+                case RANDOM:
+                    echo "<P>Not supported yet</P>";
+                break;
+                default:
+                    error("Non-existent question type!");
+                break;
+            }
+    
+            redirect("edit.php");
         }
-
-        redirect("edit.php");
-
     } 
 
     $grades = array(1,0.9,0.8,0.75,0.70,0.66666,0.60,0.50,0.40,0.33333,0.30,0.25,0.20,0.10,0.05,0);
 
     // Print the question editing form
 
+    if (empty($question->id)) {
+        $question->id = "";
+    }
+    if (empty($question->name)) {
+        $question->name = "";
+    }
+    if (empty($question->questiontext)) {
+        $question->questiontext = "";
+    }
+    if (empty($question->image)) {
+        $question->image = "";
+    }
+
+
     switch ($type) {
         case SHORTANSWER:
-            $options = get_record("quiz_shortanswer", "question", "$question->id");// OK to fail
-            $answersraw = get_records_list("quiz_answers", "id", "$options->answers");// OK to fail
-            print_heading_with_help(get_string("editingshortanswer", "quiz"), "shortanswer", "quiz");
-            if ($answersraw) {
+            if (!empty($question->id)) {
+                $options = get_record("quiz_shortanswer", "question", $question->id);
+            } else {
+                $options->usecase = 0;
+            }
+            if (!empty($options->answers)) {
+                $answersraw = get_records_list("quiz_answers", "id", $options->answers);
+            }
+            for ($i=0; $i<6; $i++) {
+                $answers[] = "";   // Make answer slots, default as blank
+            }
+            if (!empty($answersraw)) {
+                $i=0;
                 foreach ($answersraw as $answer) {
-                    $answers[] = $answer;   // to renumber index 0,1,2...
+                    $answers[$i] = $answer;   // insert answers into slots
+                    $i++;
                 }
             }
+            print_heading_with_help(get_string("editingshortanswer", "quiz"), "shortanswer", "quiz");
             require("shortanswer.html");
         break;
 
         case TRUEFALSE:
-            $options = get_record("quiz_truefalse", "question", "$question->id");  // OK to fail
-            $true    = get_record("quiz_answers", "id", "$options->true");         // OK to fail
-            $false   = get_record("quiz_answers", "id", "$options->false");        // OK to fail
+            if (!empty($question->id)) {
+                $options = get_record("quiz_truefalse", "question", "$question->id");
+            }
+            if (!empty($options->true)) {
+                $true    = get_record("quiz_answers", "id", "$options->true");
+            } else {
+                $true->fraction = 1;
+                $true->feedback = "";
+            }
+            if (!empty($options->false)) {
+                $false   = get_record("quiz_answers", "id", "$options->false");
+            } else {
+                $false->fraction = 0;
+                $false->feedback = "";
+            }
+
             if ($true->fraction > $false->fraction) {
                 $question->answer = 1;
             } else {
                 $question->answer = 0;
             }
+
             print_heading_with_help(get_string("editingtruefalse", "quiz"), "truefalse", "quiz");
             require("truefalse.html");
         break;
 
         case MULTICHOICE:
-            $options = get_record("quiz_multichoice", "question", "$question->id");// OK to fail
-            $answersraw = get_records_list("quiz_answers", "id", "$options->answers");// OK to fail
-            if ($answersraw) {
+            if (!empty($question->id)) {
+                $options = get_record("quiz_multichoice", "question", $question->id);
+            } else {
+                $options->single = "";
+            }
+            if (!empty($options->answers)) {
+                $answersraw = get_records_list("quiz_answers", "id", $options->answers);
+            }
+            for ($i=0; $i<6; $i++) {
+                $answers[] = "";   // Make answer slots, default as blank
+            }
+            if (!empty($answersraw)) {
+                $i=0;
                 foreach ($answersraw as $answer) {
-                    $answers[] = $answer;   // to renumber index 0,1,2...
+                    $answers[$i] = $answer;   // insert answers into slots
+                    $i++;
                 }
             }
             print_heading_with_help(get_string("editingmultichoice", "quiz"), "multichoice", "quiz");
     }
 
     print_footer($course);
+
+
+function formcheck($question) {
+   $err = array();
+
+   if (empty($question->name)) {
+       $err["name"] = get_string("missingname", "quiz");
+   }
+   if (empty($question->questiontext)) {
+       $err["questiontext"] = get_string("missingquestiontext", "quiz");
+   }
+   return $err;
+}
+
 ?>
index 733dfe3ed142ccd01aec51f8f487b15d52a77245..0f1f92da0944c8c5dade8e51debf70ddae083cc8 100644 (file)
     <TD align=right><P><B><? print_string("questionname", "quiz") ?>:</B></P></TD>\r
     <TD>\r
         <INPUT type="text" name="name" size=50 value="<? p($question->name) ?>">\r
+        <? if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
 <TR valign=top>\r
     <TD align=right><P><B><? print_string("question", "quiz") ?>:</B></P></TD>\r
     <TD>\r
+        <? if (isset($err["questiontext"])) {\r
+               formerr($err["questiontext"]); \r
+               echo "<BR \>";\r
+           }\r
+        ?>\r
         <textarea name="questiontext" rows=6 cols=50 wrap="virtual"><? p($question->questiontext)?></textarea>\r
         <? helpbutton("text", get_string("helptext")); ?>\r
     </TD>\r
index 86616b5ee6c1d1b152ba1b02ea776997895718d9..308f66b246c531f0f212d5860d6b0701ebcc6b71 100644 (file)
     <TD align=right><P><B><? print_string("questionname", "quiz") ?>:</B></P></TD>\r
     <TD>\r
         <INPUT type="text" name="name" size=50 value="<? p($question->name) ?>">\r
+        <? if (isset($err["name"])) formerr($err["name"]); ?>\r
     </TD>\r
 </TR>\r
 <TR valign=top>\r
     <TD align=right><P><B><? print_string("question", "quiz") ?>:</B></P></TD>\r
     <TD>\r
+        <? if (isset($err["questiontext"])) {\r
+               formerr($err["questiontext"]); \r
+               echo "<BR \>";\r
+           }\r
+        ?>\r
         <textarea name="questiontext" rows=6 cols=50 wrap="virtual"><? p($question->questiontext)?></textarea>\r
         <? helpbutton("text", get_string("helptext")); ?>\r
     </TD>\r