Put the default grade option onto question edit forms, see http://moodle.org/mod/forum/discuss.php?d=39371#181767
This commit is contained in:
@@ -877,6 +877,12 @@ function quiz_upgrade($oldversion) {
|
||||
table_column('quiz', '', 'delay2', 'integer', '10', 'unsigned', '0', 'not null', 'delay1');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021101) {
|
||||
// set defaultgrade field properly (probably not necessary, but better make sure)
|
||||
execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '1' WHERE defaultgrade = '0'", false);
|
||||
execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '0' WHERE qtype = '".DESCRIPTION."'", false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -972,6 +972,13 @@ function quiz_upgrade($oldversion) {
|
||||
table_column("quiz", "", "delay1", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "popup");
|
||||
table_column("quiz", "", "delay2", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "delay1");
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021101) {
|
||||
// set defaultgrade field properly (probably not necessary, but better make sure)
|
||||
execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '1' WHERE defaultgrade = '0'", false);
|
||||
execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '0' WHERE qtype = '".DESCRIPTION."'", false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,14 +132,9 @@ function quiz_add_quiz_question($id, &$modform) {
|
||||
|
||||
// update question grades
|
||||
$questionrecord = get_record("quiz_questions", "id", $id);
|
||||
if (!empty($questionrecord->defaultgrade)) {
|
||||
$modform->grades[$id] = $questionrecord->defaultgrade;
|
||||
} else if ($questionrecord->qtype == DESCRIPTION){
|
||||
$modform->grades[$id] = 0;
|
||||
} else {
|
||||
$modform->grades[$id] = 1;
|
||||
}
|
||||
$modform->grades[$id] = $questionrecord->defaultgrade;
|
||||
quiz_update_question_instance($modform->grades[$id], $id, $modform->instance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,15 +75,18 @@
|
||||
error("Quiz id $quizid does not exist");
|
||||
}
|
||||
|
||||
$quiz->id = 0; // just for safety
|
||||
$quiz->questions = $id;
|
||||
|
||||
// Load the question information
|
||||
if (!$questions = get_records('quiz_questions', 'id', $id)) {
|
||||
error('Could not load question');
|
||||
}
|
||||
$questions[$id]->quiz = 0;
|
||||
$questions[$id]->maxgrade = 1;
|
||||
if ($maxgrade = get_field('quiz_question_instances', 'grade', 'quiz', $quiz->id, 'question', $id)) {
|
||||
$questions[$id]->maxgrade = $maxgrade;
|
||||
} else {
|
||||
$questions[$id]->maxgrade = $questions[$id]->defaultgrade;
|
||||
}
|
||||
|
||||
$quiz->id = 0; // just for safety
|
||||
$quiz->questions = $id;
|
||||
|
||||
if (!$category = get_record("quiz_categories", "id", $questions[$id]->category)) {
|
||||
error("This question doesn't belong to a valid category!");
|
||||
|
||||
@@ -64,6 +64,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -73,6 +73,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<b><?php print_string("feedback", "quiz") ?>:</b>
|
||||
|
||||
@@ -62,6 +62,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -70,6 +70,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -64,6 +64,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -4,10 +4,8 @@
|
||||
/// RANDOMSAMATCH ///
|
||||
/////////////////////
|
||||
|
||||
/// The use of this question type together with the
|
||||
/// question type RANDOM within the same quiz can cause
|
||||
/// a shortanswer question to appear in a RANDOM question
|
||||
/// as well as one of the matcher questions in a question of this type
|
||||
/// TODO: Make sure short answer questions chosen by a randomsamatch question
|
||||
/// can not also be used by a random question
|
||||
|
||||
/// QUESTION TYPE CLASS //////////////////
|
||||
class quiz_randomsamatch_qtype extends quiz_match_qtype {
|
||||
|
||||
@@ -58,6 +58,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -73,6 +73,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -62,6 +62,14 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("defaultgrade", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="defaultgrade" size="3" value="<?php p($question->defaultgrade) ?>" alt="<?php print_string("defaultgrade", "quiz") ?>" />
|
||||
<?php helpbutton('defaultgrade', get_string('defaultgrade', 'quiz'), 'quiz'); ?>
|
||||
<?php if (isset($err["defaultgrade"])) formerr($err["defaultgrade"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("penaltyfactor", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006020801; // The (date) version of this module
|
||||
$module->version = 2006021102; // The (date) version of this module
|
||||
$module->requires = 2005021600; // Requires this Moodle version
|
||||
$module->cron = 0; // How often should cron check this module (seconds)?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user