From: tjhunt Date: Fri, 15 Aug 2008 11:15:08 +0000 (+0000) Subject: MDL-7308 - Check all the DB columns used to store grades, and make sure they all... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f9a2cf86a9c7a77bd0be1c17eca9260f0833f45e;p=moodle.git MDL-7308 - Check all the DB columns used to store grades, and make sure they all use a consistent type. --- diff --git a/lib/db/install.xml b/lib/db/install.xml index 61bf12a08d..55417de27c 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -973,8 +973,8 @@ - - + + @@ -998,7 +998,7 @@ - + @@ -1025,9 +1025,9 @@ - - - + + + @@ -1042,7 +1042,7 @@ - + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 1c59600ea5..9994486abf 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -617,6 +617,56 @@ function xmldb_main_upgrade($oldversion=0) { upgrade_main_savepoint($result, 2008080701); } +/// Changing the type of all the columns that the question bank uses to store grades to be NUMBER(12, 7). + if ($result && $oldversion < 2008081500) { + $table = new xmldb_table('question'); + $field = new xmldb_field('defaultgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'generalfeedback'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081500); + } + + if ($result && $oldversion < 2008081501) { + $table = new xmldb_table('question'); + $field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'defaultgrade'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081501); + } + + if ($result && $oldversion < 2008081502) { + $table = new xmldb_table('question_answers'); + $field = new xmldb_field('fraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'answer'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081502); + } + + if ($result && $oldversion < 2008081503) { + $table = new xmldb_table('question_sessions'); + $field = new xmldb_field('sumpenalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'newgraded'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081503); + } + + if ($result && $oldversion < 2008081504) { + $table = new xmldb_table('question_states'); + $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'event'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081504); + } + + if ($result && $oldversion < 2008081505) { + $table = new xmldb_table('question_states'); + $field = new xmldb_field('raw_grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'grade'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081505); + } + + if ($result && $oldversion < 2008081506) { + $table = new xmldb_table('question_states'); + $field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'raw_grade'); + $dbman->change_field_type($table, $field); + upgrade_main_savepoint($result, 2008081506); + } + return $result; } diff --git a/mod/quiz/db/install.xml b/mod/quiz/db/install.xml index f0f997fc88..a78bc5c647 100755 --- a/mod/quiz/db/install.xml +++ b/mod/quiz/db/install.xml @@ -23,8 +23,8 @@ - - + + @@ -48,7 +48,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -93,13 +93,13 @@ - +
- - + + diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php index 8bb8473650..6a0b0420f7 100644 --- a/mod/quiz/db/upgrade.php +++ b/mod/quiz/db/upgrade.php @@ -119,6 +119,56 @@ function xmldb_quiz_upgrade($oldversion=0) { upgrade_mod_savepoint($result, 2008081500, 'quiz'); } + /// Changing the type of all the columns that store grades to be NUMBER(10, 5) or similar. + if ($result && $oldversion < 2008081501) { + $table = new xmldb_table('quiz'); + $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'questions'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081501, 'quiz'); + } + + if ($result && $oldversion < 2008081502) { + $table = new xmldb_table('quiz'); + $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'sumgrades'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081502, 'quiz'); + } + + if ($result && $oldversion < 2008081503) { + $table = new xmldb_table('quiz_attempts'); + $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'attempt'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081503, 'quiz'); + } + + if ($result && $oldversion < 2008081504) { + $table = new xmldb_table('quiz_feedback'); + $field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'feedbacktext'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081504, 'quiz'); + } + + if ($result && $oldversion < 2008081505) { + $table = new xmldb_table('quiz_feedback'); + $field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'mingrade'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081505, 'quiz'); + } + + if ($result && $oldversion < 2008081506) { + $table = new xmldb_table('quiz_grades'); + $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'userid'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081506, 'quiz'); + } + + if ($result && $oldversion < 2008081507) { + $table = new xmldb_table('quiz_question_instances'); + $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'question'); + $dbman->change_field_type($table, $field); + upgrade_mod_savepoint($result, 2008081507, 'quiz'); + } + return $result; } diff --git a/mod/quiz/report/statistics/db/install.xml b/mod/quiz/report/statistics/db/install.xml index 89f61b7098..13cb5fd317 100644 --- a/mod/quiz/report/statistics/db/install.xml +++ b/mod/quiz/report/statistics/db/install.xml @@ -40,7 +40,7 @@ - + diff --git a/mod/quiz/report/statistics/db/upgrade.php b/mod/quiz/report/statistics/db/upgrade.php index 10489e9b65..e8e007870f 100644 --- a/mod/quiz/report/statistics/db/upgrade.php +++ b/mod/quiz/report/statistics/db/upgrade.php @@ -51,7 +51,16 @@ function xmldb_quizreport_statistics_upgrade($oldversion=0) { } } - + + if ($result && $oldversion < 2008081500) { + /// Changing type of field maxgrade on table quiz_question_statistics to number + $table = new xmldb_table('quiz_question_statistics'); + $field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'subquestions'); + + /// Launch change of type for field maxgrade + $dbman->change_field_type($table, $field); + } + return $result; } diff --git a/mod/quiz/report/statistics/version.php b/mod/quiz/report/statistics/version.php index 406f977934..4e37fd381a 100644 --- a/mod/quiz/report/statistics/version.php +++ b/mod/quiz/report/statistics/version.php @@ -1,4 +1,4 @@ version = 2008072801; // The (date) version of this module +$plugin->version = 2008081500; // The (date) version of this module ?> \ No newline at end of file diff --git a/mod/quiz/version.php b/mod/quiz/version.php index a65c89176b..5d214239f9 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2008081500; // The (date) version of this module +$module->version = 2008081507; // The (date) version of this module $module->requires = 2008072401; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 5a6aeb7ceb..ad1147f758 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -188,12 +188,12 @@ $table->align = array('center', 'left'); $table->size = array('', ''); if ($markcolumn) { - $table->head[] = get_string('marks', 'quiz') . " / $quiz->sumgrades"; + $table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades); $table->align[] = 'center'; $table->size[] = ''; } if ($gradecolumn) { - $table->head[] = get_string('grade') . " / $quiz->grade"; + $table->head[] = get_string('grade') . ' / ' . quiz_format_grade($quiz, $quiz->grade); $table->align[] = 'center'; $table->size[] = ''; } diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 7e68c0e0e9..f6c627e70f 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -861,7 +861,7 @@ class default_questiontype { $grade = '--/'; } } - $grade .= $question->maxgrade; + $grade .= question_format_grade($cmoptions, $question->maxgrade); } $comment = $state->manualcomment; @@ -993,7 +993,7 @@ class default_questiontype { // Display the grading details from the last graded state $grade = new stdClass; $grade->cur = question_format_grade($cmoptions, $state->last_graded->grade); - $grade->max = $question->maxgrade; + $grade->max = question_format_grade($cmoptions, $question->maxgrade); $grade->raw = question_format_grade($cmoptions, $state->last_graded->raw_grade); // let student know wether the answer was correct @@ -1018,7 +1018,7 @@ class default_questiontype { if ('' !== $state->last_graded->penalty && ((float)$state->last_graded->penalty) > 0.0) { // A penalty was applied so display it echo ' '; - print_string('gradingdetailspenalty', 'quiz', $state->last_graded->penalty); + print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $state->last_graded->penalty)); } else { /* No penalty was applied even though the answer was not correct (eg. a syntax error) so tell the student diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index 5e700df4c9..3322cd8e30 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -401,7 +401,7 @@ class question_shortanswer_qtype extends default_questiontype { // Display the grading details from the last graded state $grade = new stdClass; $grade->cur = question_format_grade($cmoptions, $state->last_graded->grade); - $grade->max = $question->maxgrade; + $grade->max = question_format_grade($cmoptions, $question->maxgrade); $grade->raw = question_format_grade($cmoptions, $state->last_graded->raw_grade); // let student know wether the answer was correct diff --git a/version.php b/version.php index 7ec204b03e..75731f35bf 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2008081200; // YYYYMMDD = date of the last version bump + $version = 2008081506; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20080815)'; // Human-friendly version name