]> git.mjollnir.org Git - moodle.git/commitdiff
Questions now have a defaultgrade column (which defaults to 1)
authormoodler <moodler>
Mon, 3 Mar 2003 17:43:13 +0000 (17:43 +0000)
committermoodler <moodler>
Mon, 3 Mar 2003 17:43:13 +0000 (17:43 +0000)
... this grade is used as the default grade when adding questions
to a quiz.

At the moment it's just so that some imported questions can have
different defaults, but a field should be added to all question
editing pages.

mod/quiz/db/mysql.php
mod/quiz/db/mysql.sql
mod/quiz/db/postgres7.php
mod/quiz/db/postgres7.sql
mod/quiz/edit.php
mod/quiz/format/missingword.php
mod/quiz/import.php
mod/quiz/lib.php
mod/quiz/version.php

index d9fe4baabbfcdcd861875551b75ce5211c0d779f..3fbc7fc9f68219916b08fc7f107f65239f0bfaf1 100644 (file)
@@ -50,6 +50,10 @@ function quiz_upgrade($oldversion) {
                           );");
     }
 
+    if ($oldversion < 2003030302) {
+        table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
+    }
+
     return true;
 }
 
index 0e35e92f58bf2fc27497c824a09a6f66d393a866..f85d83838a097e2bd463a8bf2a98a47f1f4fc192 100644 (file)
@@ -143,6 +143,7 @@ CREATE TABLE `prefix_quiz_questions` (
   `name` varchar(255) NOT NULL default '',
   `questiontext` text NOT NULL,
   `image` varchar(255) NOT NULL default '',
+  `defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL,
   `qtype` smallint(6) NOT NULL default '0',
   PRIMARY KEY  (`id`)
 ) TYPE=MyISAM COMMENT='The quiz questions themselves';
index 4a26f8ee9c5ef5df274af7218d26d4f36d281579..1e424afb79887aab71a222c1cd3fe77029b74db5 100644 (file)
@@ -23,6 +23,9 @@ function quiz_upgrade($oldversion) {
                                   choose integer NOT NULL default '4',
                               );");
     }
+    if ($oldversion < 2003030302) {
+        table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
+    }
 
     return true;
 }
index 3b140b1fdb29fc4bc155b97e5ac4ff988f23a024..7d49ec4a5ea829ae1c778f89e135329478291629 100644 (file)
@@ -124,6 +124,7 @@ CREATE TABLE prefix_quiz_questions (
   name varchar(255) NOT NULL default '',
   questiontext text NOT NULL default '',
   image varchar(255) NOT NULL default '',
+  defaultgrade integer NOT NULL default '1'
   qtype integer NOT NULL default '0'
 );
 # --------------------------------------------------------
index 1699981556cd8e1ff9b9dc4cd567e63585b21649..c2ebdd927032747e4e8f4d0397b4205d3f9d9fb6 100644 (file)
                     }
                 }
                 $questions[] = $key;
-                $modform->grades[$key] = QUIZ_DEFAULT_SCORE; 
+
+                $questionrecord = get_record("quiz_questions", "id", $key);
+                if (!empty($questionrecord->defaultgrade)) {
+                    $modform->grades[$key] = $questionrecord->defaultgrade; 
+                } else {
+                    $modform->grades[$key] = 1; 
+                }
             }
         }
         if (!empty($questions)) {
index b10cdac0f0b87d922d87981854fd34e791ecf0a4..92d648a1da862fe71891ceb4bd9405e48fecadb8 100644 (file)
@@ -78,6 +78,7 @@ class quiz_file_format extends quiz_default_format {
                 $question->feedback[] = "";
     
                 $question->usecase = 0;  // Ignore case
+                $question->defaultgrade = 1; 
                 $question->image = "";   // No images with this format
                 return $question;
 
@@ -97,6 +98,7 @@ class quiz_file_format extends quiz_default_format {
                     $question->feedback[$key] = "";
                 }
     
+                $question->defaultgrade = 1; 
                 $question->single = 1;   // Only one answer is allowed
                 $question->image = "";   // No images with this format
                 return $question;
index 169cdc50c6072e60ad2e6b50fc97747bdbc62e95..f2eb618328788fe3fe87f7779f7c208517cb7406 100644 (file)
 
             if (!empty($form->createrandom)) {   /// Create a number of random questions
 
+                $rm->choose = 4;                 /// Always 4, for now.
                 $rm->category = $category->id;
                 $rm->questiontext =  get_string("randommatchintro", "quiz");
                 $rm->image = "";
                 $rm->qtype =  RANDOMMATCH;
-                $rm->choose = 4;                 /// Always 4, for now.
+                $rm->defaultgrade = $rm->choose; 
 
                 echo "<hr>";
 
                 for ($i=1; $i<=$form->createrandom; $i++) {
                     $rm->name =  get_string("randommatch", "quiz") . " $i ($rm->choose $strquestions)";
 
+                    $db->debug = true;
                     if (!$rm->id = insert_record("quiz_questions", $rm)) {
                         error("Could not insert new question!");
                     }
index 560e36dc0bc309428b36248842ac5e8384f36e0c..8edeffc9520112f944660da13a4d23d88127e7d4 100644 (file)
@@ -32,8 +32,6 @@ $QUIZ_FILE_FORMAT = array ( "custom"   => get_string("custom", "quiz"),
 
 define("QUIZ_PICTURE_DEFAULT_HEIGHT", "200");
 
-define("QUIZ_DEFAULT_SCORE", "1");
-
 /// FUNCTIONS ///////////////////////////////////////////////////////////////////
 
 function quiz_add_instance($quiz) {
index 1eb49a5c2e2ece78e526acfb6dd4434425ae7683..d5ea2d9938c0ee6e68982223fcf300088800d2c8 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003022303;   // The (date) version of this module
+$module->version  = 2003030302;   // The (date) version of this module
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
 ?>