Questions now have a defaultgrade column (which defaults to 1)
... 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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
# --------------------------------------------------------
|
||||
|
||||
+7
-1
@@ -91,7 +91,13 @@
|
||||
}
|
||||
}
|
||||
$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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-1
@@ -86,17 +86,19 @@
|
||||
|
||||
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!");
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)?
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user