]> git.mjollnir.org Git - moodle.git/commitdiff
First version of code to implement new "Random Matching" type
authormoodler <moodler>
Mon, 24 Feb 2003 10:37:56 +0000 (10:37 +0000)
committermoodler <moodler>
Mon, 24 Feb 2003 10:37:56 +0000 (10:37 +0000)
of questions.  These use 2 or more short answer questions at
random to construct a questions where you have to match
answers to questions.  Only lightly tested so far.

Quiz questions can now be edited with Richtext editor.

Sundry little fixes along the way.

16 files changed:
lang/en/help/quiz/randommatch.html [new file with mode: 0644]
lang/en/quiz.php
mod/quiz/attempt.php
mod/quiz/db/mysql.php
mod/quiz/db/mysql.sql
mod/quiz/edit.php
mod/quiz/format/default.php
mod/quiz/format/missingword.php
mod/quiz/lib.php
mod/quiz/multichoice.html
mod/quiz/pix/rm.gif [new file with mode: 0755]
mod/quiz/question.php
mod/quiz/randommatch.html [new file with mode: 0644]
mod/quiz/shortanswer.html
mod/quiz/truefalse.html
mod/quiz/version.php

diff --git a/lang/en/help/quiz/randommatch.html b/lang/en/help/quiz/randommatch.html
new file mode 100644 (file)
index 0000000..23f8efc
--- /dev/null
@@ -0,0 +1,10 @@
+<p align=center><b>Random Matching questions</b></p>
+
+<p>In response to a question (that may include a image) the respondent 
+   is presented with several questions and several answers.  There is one 
+   correct answer for each question.
+   
+<p>The respondent selects the answers that match each question.
+
+<p>The questions and answers are randomly drawn from the pool of 
+   "Short Answer" questions in the current category.
index dedd0f12b96c8d0583e7b88e0307f0bac7ce8f8b..7a8bb211be0eac2fd585160652b009fc7b1aece2 100644 (file)
@@ -47,6 +47,7 @@ $string['editingquestion'] = "Editing a question";
 $string['editingshortanswer'] = "Editing a short answer question";
 $string['editingtruefalse'] = "Editing a true/false question";
 $string['editingmultichoice'] = "Editing a multiple choice question";
+$string['editingrandommatch'] = "Editing a random matching question";
 $string['false'] = "False";
 $string['feedback'] = "Feedback";
 $string['filloutoneanswer'] = "You must fill out at least one possible answer.  Answers left blank will not be used.";
@@ -88,6 +89,9 @@ $string['quizclosed'] = "This quiz closed on \$a";
 $string['quizopen'] = "Open the quiz";
 $string['quiznotavailable'] = "The quiz will not be available until: \$a";
 $string['random'] = "Random set";
+$string['randommatch'] = "Random Match";
+$string['randommatchintro'] = "For each of the following questions, select the matching answer from the menu.";
+$string['randommatchnumber'] = "Number of questions to select";
 $string['readytosend'] = "You are about to send your whole quiz to be graded.  Are you sure you want to continue?";
 $string['regrade'] = "Regrade all attempts";
 $string['regradecomplete'] = "All attempts have been regraded";
index 5fb9188a5b736e1db1e1390e92a49a2efd7ed1e6..8e426222aa0613565f2268de1ef8fe837f4efe6b 100644 (file)
             error("No questions found!");
         }
 
-        foreach ($rawanswers as $key => $value) {    // Parse input for question -> answers
+        foreach ($rawanswers as $key => $value) {       // Parse input for question -> answers
             if (substr($key, 0, 1) == "q") {
                 $key = substr($key,1);
-                if (!isset($questions[$key])) {
-                    if (substr_count($key, "a")) {   // checkbox style multiple answers
-                        $check = explode("a", $key);
-                        $key   = $check[0];
-                        $value = $check[1];
-                    } else {
-                        error("Answer received for non-existent question ($key)!");
-                    }
+                if (isset($questions[$key])) {          // It's a real question number, not a coded one
+                    $questions[$key]->answer[] = trim($value);
+
+                } else if (substr_count($key, "a")) {   // Checkbox style multiple answers
+                    $check = explode("a", $key);
+                    $key   = $check[0];                 // The main question number
+                    $value = $check[1];                 // The actual answer
+                    $questions[$key]->answer[] = trim($value);  
+
+                } else if (substr_count($key, "r")) {   // Random-style questions
+                    $check = explode("r", $key);
+                    $key   = $check[0];                 // The main question
+                    $rand  = $check[1];                 // The random sub-question
+                    $questions[$key]->answer[] = "$rand-$value";
+
+                } else {
+                    error("Answer received for non-existent question ($key)!");
                 }
-                $questions[$key]->answer[] = trim($value);  // Store answers in array (whitespace trimmed)
             }
         }
 
index ccc5c766519526483811df2730a4fb90445dde92..d9fe4baabbfcdcd861875551b75ce5211c0d779f 100644 (file)
@@ -41,6 +41,15 @@ function quiz_upgrade($oldversion) {
         table_column("quiz_questions", "type", "qtype", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
     }
 
+    if ($oldversion < 2003022303) {
+        modify_database ("", "CREATE TABLE `prefix_quiz_randommatch` (
+                             `id` int(10) unsigned NOT NULL auto_increment,
+                             `question` int(10) unsigned NOT NULL default '0',
+                             `choose` INT UNSIGNED DEFAULT '4' NOT NULL,
+                             PRIMARY KEY ( `id` )
+                          );");
+    }
+
     return true;
 }
 
index c601b5d90668182f1237c177fba23d5e3b8f9e8b..0e35e92f58bf2fc27497c824a09a6f66d393a866 100644 (file)
@@ -122,6 +122,17 @@ CREATE TABLE `prefix_quiz_question_grades` (
 ) TYPE=MyISAM COMMENT='The grade for a question in a quiz';
 # --------------------------------------------------------
 
+#
+# Table structure for table `quiz_randommatch`
+#
+
+CREATE TABLE `prefix_quiz_randommatch` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `question` int(10) unsigned NOT NULL default '0',
+  `choose` INT UNSIGNED DEFAULT '4' NOT NULL,
+  PRIMARY KEY ( `id` )
+) TYPE=MyISAM COMMENT='Info about a random matching question';
+
 #
 # Table structure for table `quiz_questions`
 #
index 49622409523f3b62072afa88c6d63ae9c3d2700a..6ad776b50cbf33cba2f791f61dfdb696b30576e9 100644 (file)
@@ -84,7 +84,7 @@
         foreach ($rawquestions as $key => $value) {    // Parse input for question ids
             if (substr($key, 0, 1) == "q") {
                 $key = substr($key,1);
-                if ($questions) {
+                if (!empty($questions)) {
                     foreach ($questions as $question) {
                         if ($question == $key) {
                             continue 2;
index 0f7b70c91ed61b4246dd606142417d5089cf9d26..5dded33387c404c50cccb688372ed87fa3d3666b 100644 (file)
@@ -61,21 +61,6 @@ class quiz_default_format {
     }
 
 
-    function swapshuffle($array) {
-    /// Given a simple array, shuffles it up just like shuffle()
-    /// Unlike PHP's shuffle() ihis function works on any machine.
-
-        srand ((double) microtime() * 10000000);
-        $last = count($array) - 1;
-        for ($i=0;$i<=$last;$i++) {
-            $from = rand(0,$last);
-            $curr = $array[$i];
-            $array[$i] = $array[$from];
-            $array[$from] = $curr;
-        }  
-        return $array;
-    }
-
 }
 
 ?>
index 1dd4a063880446e23d0e916309a3a9cf4f69dfcb..b10cdac0f0b87d922d87981854fd34e791ecf0a4 100644 (file)
@@ -57,38 +57,51 @@ class quiz_file_format extends quiz_default_format {
         /// Parse the answers
         $answers = explode("~", $answertext);
 
-        if (! count($answers)) {
-            if ($this->displayerrors) {
-                echo "<P>No answers found in $answertext";
-            }
-            return false;
+        $countanswers = count($answers);
+
+        switch ($countanswers) {
+            case 0:  // invalid question
+                if ($this->displayerrors) {
+                    echo "<P>No answers found in $answertext";
+                }
+                return false;
+
+            case 1:
+                $question->qtype = SHORTANSWER;
+
+                $answer = trim($answers[0]);
+                if ($answer[0] == "=") {
+                    $answer = substr($answer, 1);
+                }
+                $question->answer[]   = addslashes($answer);
+                $question->fraction[] = 1;
+                $question->feedback[] = "";
+    
+                $question->usecase = 0;  // Ignore case
+                $question->image = "";   // No images with this format
+                return $question;
+
+            default:
+                $question->qtype = MULTICHOICE;
+
+                $answers = swapshuffle($answers);
+                foreach ($answers as $key => $answer) {
+                    $answer = trim($answer);
+                    if ($answer[0] == "=") {
+                        $question->fraction[$key] = 1;
+                        $answer = substr($answer, 1);
+                    } else {
+                        $question->fraction[$key] = 0;
+                    }
+                    $question->answer[$key]   = addslashes($answer);
+                    $question->feedback[$key] = "";
+                }
+    
+                $question->single = 1;   // Only one answer is allowed
+                $question->image = "";   // No images with this format
+                return $question;
         }
-
-        if (count($answers) == 1) {
-            return false;
-        }
-
-        $answers = $this->swapshuffle($answers);
-
-        foreach ($answers as $key => $answer) {
-            $answer = trim($answer);
-            if ($answer[0] == "=") {
-                $question->fraction[$key] = 1;
-                $answer = substr($answer, 1);
-            } else {
-                $question->fraction[$key] = 0;
-            }
-            $question->answer[$key]   = addslashes($answer);
-            $question->feedback[$key] = "";
-        }
-
-        $question->qtype = MULTICHOICE;
-        $question->single = 1;   // Only one answer is allowed
-        $question->image = "";   // No images with this format
-
-        return $question;
     }
-
 }
 
 ?>
index ebfd1e5150ea7d2a488c51af81c1e6e1669981f6..8935cbcfea17d685de64230bf37686d76387bd18 100644 (file)
@@ -17,9 +17,13 @@ define("SHORTANSWER", "1");
 define("TRUEFALSE",   "2");
 define("MULTICHOICE", "3");
 define("RANDOM",      "4");
+define("MATCH",       "5");
+define("RANDOMMATCH", "6");
+
 $QUIZ_QUESTION_TYPE = array ( MULTICHOICE => get_string("multichoice", "quiz"),
                               TRUEFALSE   => get_string("truefalse", "quiz"),
-                              SHORTANSWER => get_string("shortanswer", "quiz") );
+                              SHORTANSWER => get_string("shortanswer", "quiz"),
+                              RANDOMMATCH => get_string("randommatch", "quiz") );
 
 $QUIZ_FILE_FORMAT = array ( "custom"   => get_string("custom", "quiz"),
                             "webct"    => get_string("webct", "quiz"),
@@ -245,8 +249,9 @@ function quiz_get_grade_records($quiz) {
 function quiz_get_answers($question) {
 // Given a question, returns the correct answers and grades
     global $CFG;
+
     switch ($question->qtype) {
-        case SHORTANSWER;       // Could be multiple answers
+        case SHORTANSWER:       // Could be multiple answers
             return get_records_sql("SELECT a.*, sa.usecase, g.grade
                                       FROM {$CFG->prefix}quiz_shortanswer sa,  
                                            {$CFG->prefix}quiz_answers a,  
@@ -256,7 +261,7 @@ function quiz_get_answers($question) {
                                        AND sa.question = g.question");
             break;
 
-        case TRUEFALSE;         // Should be always two answers
+        case TRUEFALSE:         // Should be always two answers
             return get_records_sql("SELECT a.*, g.grade
                                       FROM {$CFG->prefix}quiz_answers a, 
                                            {$CFG->prefix}quiz_question_grades g
@@ -264,7 +269,7 @@ function quiz_get_answers($question) {
                                        AND a.question = g.question");
             break;
 
-        case MULTICHOICE;       // Should be multiple answers
+        case MULTICHOICE:       // Should be multiple answers
             return get_records_sql("SELECT a.*, mc.single, g.grade
                                       FROM {$CFG->prefix}quiz_multichoice mc, 
                                            {$CFG->prefix}quiz_answers a, 
@@ -274,10 +279,21 @@ function quiz_get_answers($question) {
                                        AND mc.question = g.question");
             break;
 
-       case RANDOM:
+        case RANDOM:
            return false;  // Not done yet
            break;
 
+        case RANDOMMATCH:       // Could be any of many answers, return them all
+            return get_records_sql("SELECT a.*, g.grade
+                                      FROM {$CFG->prefix}quiz_questions q,  
+                                           {$CFG->prefix}quiz_answers a,  
+                                           {$CFG->prefix}quiz_question_grades g
+                                     WHERE q.category = '$question->category' 
+                                       AND q.qtype = ".SHORTANSWER."
+                                       AND q.id = a.question
+                                       AND g.question = '$question->id'");
+            break;
+
         default:
             return false;
     }
@@ -290,7 +306,7 @@ function quiz_get_attempt_responses($attempt) {
 // for regrading using quiz_grade_attempt_results()
     global $CFG;
    
-    if (!$responses = get_records_sql("SELECT q.id, q.qtype, r.answer 
+    if (!$responses = get_records_sql("SELECT q.id, q.qtype, q.category, r.answer 
                                         FROM {$CFG->prefix}quiz_responses r, 
                                              {$CFG->prefix}quiz_questions q
                                        WHERE r.attempt = '$attempt->id' 
@@ -343,6 +359,9 @@ function quiz_print_question_icon($question) {
         case RANDOM:
             echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/rs.gif\">";
             break;
+        case RANDOMMATCH:
+            echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/rm.gif\">";
+            break;
     }
     echo "</A>\n";
 }
@@ -504,6 +523,93 @@ function quiz_print_question($number, $questionid, $grade, $courseid,
            echo "<P>Random questions not supported yet</P>";
            break;
 
+       case RANDOMMATCH: 
+           if (!$options = get_record("quiz_randommatch", "question", $question->id)) {
+               notify("Error: Missing question options!");
+           }
+           echo text_to_html($question->questiontext);
+           if ($question->image) {
+               print_file_picture($question->image, $courseid, QUIZ_PICTURE_DEFAULT_HEIGHT);
+           }
+
+           /// First, get all the questions available
+
+           $allquestions = get_records_select("quiz_questions", 
+                                              "category = $question->category AND qtype = ".SHORTANSWER);
+           if (count($allquestions) < $options->choose) {
+               notify("Error: could not find enough Short Answer questions in the database!");
+               notify("Found ".count($allquestions).", need $options->choose.");
+               break;
+           }
+
+           if (empty($response)) {  // Randomly pick the questions
+               if (!$randomquestions = draw_rand_array($allquestions, $options->choose)) {
+                   notify("Error choosing $options->choose random questions");
+                   break;
+               }
+           } else {                 // Use existing questions
+               $randomquestions = array();
+               foreach ($response as $key => $rrr) {
+                   $rrr = explode("-", $rrr);
+                   $randomquestions[$key] = $allquestions[$key];
+                   $responseanswer[$key] = $rrr[1];
+               }
+           }
+    
+           /// For each selected, find the best matching answers
+
+           foreach ($randomquestions as $randomquestion) {
+               $shortanswerquestion = get_record("quiz_shortanswer", "question", $randomquestion->id);
+               $questionanswers = get_records_list("quiz_answers", "id", $shortanswerquestion->answers);
+               $bestfraction = 0;
+               $bestanswer = NULL;
+               foreach ($questionanswers as $questionanswer) {
+                   if ($questionanswer->fraction > $bestfraction) {
+                       $bestanswer = $questionanswer;
+                   }
+               }
+               if (empty($bestanswer)) {
+                   notify("Error: Could not find the best answer for question: ".$randomquestions->name);
+                   break;
+               }
+               $randomanswers[$bestanswer->id] = trim($bestanswer->answer);
+           }
+
+           if (!$randomanswers = draw_rand_array($randomanswers, $options->choose)) {  // Mix them up
+               notify("Error randomising answers!");
+               break;
+           }
+
+           echo "<table border=0 cellpadding=10>";
+           foreach ($randomquestions as $key => $randomquestion) {
+               echo "<tr><td align=left valign=top>";
+               echo $randomquestion->questiontext;
+               echo "</td>";
+               echo "<td align=right valign=top>";
+               if (empty($response)) {
+                   choose_from_menu($randomanswers, "q$question->id"."r$randomquestion->id");
+               } else {
+                   if (!empty($correct[$key])) {
+                       if ($randomanswers[$responseanswer[$key]] == $correct[$key]) {
+                           echo "<span=highlight>";
+                           choose_from_menu($randomanswers, "q$question->id"."r$randomquestion->id", $responseanswer[$key]);
+                           echo "</span><br \>";
+                       } else {
+                           choose_from_menu($randomanswers, "q$question->id"."r$randomquestion->id", $responseanswer[$key]);
+                           quiz_print_correctanswer($correct[$key]);
+                       }
+                   } else {
+                       choose_from_menu($randomanswers, "q$question->id"."r$randomquestion->id", $responseanswer[$key]);
+                   }
+                   if (!empty($feedback[$key])) {
+                       quiz_print_comment($feedback[$key]);
+                   }
+               }
+               echo "</td></tr>";
+           }
+           echo "</table>";
+           break;
+
 
        default: 
            notify("Error: Unknown question type!");
@@ -693,6 +799,9 @@ function quiz_print_question_list($questionlist, $grades) {
     echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2 WIDTH=\"100%\">";
     echo "<TR><TH WIDTH=\"*\" COLSPAN=3 NOWRAP>$strorder</TH><TH align=left WIDTH=\"100%\" NOWRAP>$strquestionname</TH><TH width=\"*\" NOWRAP>$strtype</TH><TH WIDTH=\"*\" NOWRAP>$strgrade</TH><TH WIDTH=\"*\" NOWRAP>$stredit</TH></TR>";
     foreach ($order as $qnum) {
+        if (empty($questions[$qnum])) {
+            continue;
+        }
         $count++;
         echo "<TR BGCOLOR=\"$THEME->cellcontent\">";
         echo "<TD>$count</TD>";
@@ -1087,24 +1196,47 @@ function quiz_grade_attempt_results($quiz, $questions) {
                     if (!empty($question->answer)) {
                         foreach ($question->answer as $questionanswer) {
                             if ($questionanswer == $answer->id) {
+                                $response[$answer->id] = true;
                                 if ($answer->single) {
                                     $grade = (float)$answer->fraction * $answer->grade;
-                                    $response[$answer->id] = true;
                                     continue;
                                 } else {
                                     $grade += (float)$answer->fraction * $answer->grade;
-                                    $response[$answer->id] = true;
                                 }
                             }
                         }
                     }
                 }
                 break;
-            case RANDOM:
-                          // Not done yet
+
+            case RANDOMMATCH:
+                $bestanswer = array();
+                foreach ($answers as $answer) {  // Loop through them all looking for correct answers
+                    if (empty($bestanswer[$answer->question])) {
+                        $bestanswer[$answer->question] = 0;
+                        $correct[$answer->question] = "";
+                    }
+                    if ($answer->fraction > $bestanswer[$answer->question]) {
+                        $bestanswer[$answer->question] = $answer->fraction;
+                        $correct[$answer->question] = $answer->answer;
+                    }
+                }
+                $answerfraction = 1.0 / (float) count($question->answer);
+                foreach ($question->answer as $questionanswer) {  // For each random answered question
+                    $rqarr = explode('-', $questionanswer);   // Extract question/answer.
+                    $rquestion = $rqarr[0];
+                    $ranswer = $rqarr[1];
+                    $response[$rquestion] = $questionanswer;
+                    if (isset($answers[$ranswer])) {         // If the answer exists in the list
+                        $answer = $answers[$ranswer];         
+                        $feedback[$rquestion] = $answer->feedback;
+                        if ($answer->question == $rquestion) {    // Check that this answer matches the question
+                            $grade += (float)$answer->fraction * $answer->grade * $answerfraction;
+                        }
+                    }
+                }
                 break;
 
-            
         }
         if ($grade < 0.0) {   // No negative grades
             $grade = 0.0;
@@ -1272,6 +1404,24 @@ function quiz_save_question_options($question) {
                 }
             }
         break;
+
+        case RANDOMMATCH:
+            $options->question = $question->id;
+            $options->choose = $question->choose;
+            if ($existing = get_record("quiz_randommatch", "question", $options->question)) {
+                $options->id = $existing->id;
+                if (!update_record("quiz_randommatch", $options)) {
+                    $result->error = "Could not update quiz randommatch options!";
+                    return $result;
+                }
+            } else {
+                if (!insert_record("quiz_randommatch", $options)) {
+                    $result->error = "Could not insert quiz randommatch options!";
+                    return $result;
+                }
+            }
+        break;
+
         default:
             $result->error = "Unsupported question type ($question->qtype)!";
             return $result;
@@ -1281,4 +1431,6 @@ function quiz_save_question_options($question) {
 }
 
 
+
+
 ?>
index 0b95a1409b0fe69264665359eee01360cc095df4..5f437700d9618457b31d1d8b07f858e889ae8d03 100644 (file)
@@ -1,4 +1,4 @@
-<FORM name="theform" method="post" action="question.php">\r
+<FORM name="theform" method="post" <?=$onsubmit ?> action="question.php">\r
 <CENTER>\r
 <TABLE cellpadding=5>\r
 <TR valign=top>\r
                formerr($err["questiontext"]); \r
                echo "<BR \>";\r
            }\r
+           print_textarea($usehtmleditor, 15, 60, 595, 300, "questiontext", $question->questiontext);\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle");\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
 </TR>\r
 <TR valign=top>\r
 \r
 </CENTER>\r
 </FORM>\r
+<? \r
+   if ($usehtmleditor) { \r
+       print_richedit_javascript("theform", "questiontext", "no");\r
+   }\r
+?>\r
diff --git a/mod/quiz/pix/rm.gif b/mod/quiz/pix/rm.gif
new file mode 100755 (executable)
index 0000000..8618687
Binary files /dev/null and b/mod/quiz/pix/rm.gif differ
index 7cd5df1afdac8d14ffe7e53e6112923d83213ffe..df70c28a20ae1acb209187ab31849bfabdc94d28 100644 (file)
         $question->image = "";
     }
 
+    // Set up some Richtext editing if necessary
+    if ($usehtmleditor = can_use_richtext_editor()) {
+        $defaultformat = FORMAT_HTML;
+        $onsubmit = "onsubmit=\"copyrichtext(theform.questiontext);\"";
+    } else {
+        $defaultformat = FORMAT_MOODLE;
+        $onsubmit = "";
+    }
 
     switch ($qtype) {
         case SHORTANSWER:
             print_continue("edit.php");
         break;
 
+        case RANDOMMATCH:
+            if (!empty($question->id)) {
+                $options = get_record("quiz_randommatch", "question", $question->id);
+            } else {
+                $options->choose = "";
+            }
+            $numberavailable = count_records("quiz_questions", "category", $category->id, "qtype", SHORTANSWER);
+            print_heading_with_help(get_string("editingrandommatch", "quiz"), "randommatch", "quiz");
+            require("randommatch.html");
+        break;
+
         default:
             error("Invalid question type");
         break;
diff --git a/mod/quiz/randommatch.html b/mod/quiz/randommatch.html
new file mode 100644 (file)
index 0000000..e8006cc
--- /dev/null
@@ -0,0 +1,74 @@
+<FORM name="theform" method="post" <?=$onsubmit ?> action="question.php">\r
+<CENTER>\r
+<TABLE cellpadding=5>\r
+<TR valign=top>\r
+    <TD align=right><P><B><? print_string("category", "quiz") ?>:</B></P></TD>\r
+    <TD>\r
+    <?PHP echo $categories[$question->category]; ?>\r
+    <input type="hidden" name="category" value="<?PHP echo "$question->category"; ?>">\r
+    </TD>\r
+</TR>\r
+<TR valign=top>\r
+    <TD align=right><P><B><? print_string("questionname", "quiz") ?>:</B></P></TD>\r
+    <TD>\r
+        <?PHP\r
+           if (empty($question->name)) {\r
+               $question->name =  get_string("randommatch", "quiz");\r
+           }\r
+        ?>\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("introduction", "quiz") ?>:</B></P></TD>\r
+    <TD>\r
+        <? if (isset($err["questiontext"])) {\r
+               formerr($err["questiontext"]); \r
+               echo "<BR \>";\r
+           }\r
+           if (empty($question->questiontext)) {\r
+               $question->questiontext =  get_string("randommatchintro", "quiz");\r
+           }\r
+           print_textarea($usehtmleditor, 15, 60, 595, 300, "questiontext", $question->questiontext);\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle");\r
+           }\r
+        ?>\r
+    </TD>\r
+</TR>\r
+<TR valign=top>\r
+    <TD align=right><P><B><? print_string("randommatchnumber", "quiz") ?>:</B></P></TD>\r
+    <TD>\r
+    <?\r
+        if ($numberavailable < 2) {\r
+            echo "ERROR";\r
+        } else if ($numberavailable < 6) {\r
+            $maxrandom = $numberavailable;\r
+        } else {\r
+            $maxrandom = 6;\r
+        }\r
+\r
+        for ($i=2;$i<=$maxrandom;$i++) {\r
+            $menu[$i] = $i;\r
+        }\r
+        choose_from_menu($menu, "choose", "$options->choose", "");\r
+        unset($menu);\r
+     ?>\r
+    </TD>\r
+</TR>\r
+</TABLE>\r
+\r
+<INPUT type="hidden" name=id value="<? p($question->id) ?>">\r
+<INPUT type="hidden" name=qtype value="<? p($question->qtype) ?>">\r
+<INPUT type="submit" value="<? print_string("savechanges") ?>">\r
+\r
+</CENTER>\r
+</FORM>\r
+<? \r
+   if ($usehtmleditor) { \r
+       print_richedit_javascript("theform", "questiontext", "no");\r
+   }\r
+?>\r
index 03fcd781600763f1aecf41efb446fffbe665dcff..8337b5658fdd0658a5dc64115698451d67f8547e 100644 (file)
@@ -1,4 +1,4 @@
-<FORM name="theform" method="post" action="question.php">\r
+<FORM name="theform" method="post" <?=$onsubmit ?> action="question.php">\r
 <CENTER>\r
 <TABLE cellpadding=5>\r
 <TR valign=top>\r
                formerr($err["questiontext"]); \r
                echo "<BR \>";\r
            }\r
+           print_textarea($usehtmleditor, 15, 60, 595, 300, "questiontext", $question->questiontext);\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle");\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
 </TR>\r
 <TR valign=top>\r
 \r
 </CENTER>\r
 </FORM>\r
+<? \r
+   if ($usehtmleditor) { \r
+       print_richedit_javascript("theform", "questiontext", "no");\r
+   }\r
+?>\r
index cf87b47feb5c2b1fa2eb20303e891798b38fd110..a8480dc2bfed01d6df2044a42516e9691b2c4627 100644 (file)
@@ -1,4 +1,4 @@
-<FORM name="theform" method="post" action="question.php">\r
+<FORM name="theform" method="post" <?=$onsubmit ?> action="question.php">\r
 <CENTER>\r
 <TABLE cellpadding=5>\r
 <TR valign=top>\r
                formerr($err["questiontext"]); \r
                echo "<BR \>";\r
            }\r
+           print_textarea($usehtmleditor, 15, 60, 595, 300, "questiontext", $question->questiontext);\r
+           if ($usehtmleditor) {\r
+               helpbutton("richtext", get_string("helprichtext"), "moodle");\r
+           } else {\r
+               helpbutton("text", get_string("helptext"), "moodle");\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
 </TR>\r
 <TR valign=top>\r
@@ -67,3 +71,8 @@
 \r
 </CENTER>\r
 </FORM>\r
+<? \r
+   if ($usehtmleditor) { \r
+       print_richedit_javascript("theform", "questiontext", "no");\r
+   }\r
+?>\r
index 2c47acbdb53297a3f0d52e693394615ee9962c34..1eb49a5c2e2ece78e526acfb6dd4434425ae7683 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003021600;   // The (date) version of this module
+$module->version  = 2003022303;   // The (date) version of this module
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
 ?>