mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-25791 PULL-125 reverting commits that create null problems during upgrade
This commit is contained in:
parent
1f50b85867
commit
2f20e23ba6
2 changed files with 9 additions and 125 deletions
|
@ -20,10 +20,6 @@
|
||||||
// Please do not forget to use upgrade_set_timeout()
|
// Please do not forget to use upgrade_set_timeout()
|
||||||
// before any action that may take longer time to finish.
|
// before any action that may take longer time to finish.
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $oldversion
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function xmldb_quiz_upgrade($oldversion) {
|
function xmldb_quiz_upgrade($oldversion) {
|
||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
|
|
||||||
|
@ -121,49 +117,49 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||||
/// Changing the type of all the columns that store grades to be NUMBER(10, 5) or similar.
|
/// Changing the type of all the columns that store grades to be NUMBER(10, 5) or similar.
|
||||||
if ($oldversion < 2008081501) {
|
if ($oldversion < 2008081501) {
|
||||||
$table = new xmldb_table('quiz');
|
$table = new xmldb_table('quiz');
|
||||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'questions');
|
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'questions');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081501, 'quiz');
|
upgrade_mod_savepoint(true, 2008081501, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2008081502) {
|
if ($oldversion < 2008081502) {
|
||||||
$table = new xmldb_table('quiz');
|
$table = new xmldb_table('quiz');
|
||||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'sumgrades');
|
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'sumgrades');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081502, 'quiz');
|
upgrade_mod_savepoint(true, 2008081502, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2008081503) {
|
if ($oldversion < 2008081503) {
|
||||||
$table = new xmldb_table('quiz_attempts');
|
$table = new xmldb_table('quiz_attempts');
|
||||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'attempt');
|
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'attempt');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081503, 'quiz');
|
upgrade_mod_savepoint(true, 2008081503, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2008081504) {
|
if ($oldversion < 2008081504) {
|
||||||
$table = new xmldb_table('quiz_feedback');
|
$table = new xmldb_table('quiz_feedback');
|
||||||
$field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'feedbacktext');
|
$field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'feedbacktext');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081504, 'quiz');
|
upgrade_mod_savepoint(true, 2008081504, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2008081505) {
|
if ($oldversion < 2008081505) {
|
||||||
$table = new xmldb_table('quiz_feedback');
|
$table = new xmldb_table('quiz_feedback');
|
||||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'mingrade');
|
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'mingrade');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081505, 'quiz');
|
upgrade_mod_savepoint(true, 2008081505, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2008081506) {
|
if ($oldversion < 2008081506) {
|
||||||
$table = new xmldb_table('quiz_grades');
|
$table = new xmldb_table('quiz_grades');
|
||||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'userid');
|
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'userid');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081506, 'quiz');
|
upgrade_mod_savepoint(true, 2008081506, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2008081507) {
|
if ($oldversion < 2008081507) {
|
||||||
$table = new xmldb_table('quiz_question_instances');
|
$table = new xmldb_table('quiz_question_instances');
|
||||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, '0', 'question');
|
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'question');
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
upgrade_mod_savepoint(true, 2008081507, 'quiz');
|
upgrade_mod_savepoint(true, 2008081507, 'quiz');
|
||||||
}
|
}
|
||||||
|
@ -255,7 +251,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||||
if ($oldversion < 2009031000) {
|
if ($oldversion < 2009031000) {
|
||||||
/// Add new questiondecimaldigits setting, separate form the overall decimaldigits one.
|
/// Add new questiondecimaldigits setting, separate form the overall decimaldigits one.
|
||||||
$table = new xmldb_table('quiz');
|
$table = new xmldb_table('quiz');
|
||||||
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '-2', 'decimalpoints');
|
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '2', 'decimalpoints');
|
||||||
if (!$dbman->field_exists($table, $field)) {
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
$dbman->add_field($table, $field);
|
$dbman->add_field($table, $field);
|
||||||
}
|
}
|
||||||
|
@ -378,118 +374,6 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||||
upgrade_mod_savepoint(true, 2010102000, 'quiz');
|
upgrade_mod_savepoint(true, 2010102000, 'quiz');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldversion < 2011011400) {
|
|
||||||
// Fix quiz in the post table after upgrade from 1.9
|
|
||||||
$table = new xmldb_table('quiz');
|
|
||||||
$columns = $DB->get_columns('quiz');
|
|
||||||
|
|
||||||
if (array_key_exists('questiondecimalpoints', $columns) && $columns['questiondecimalpoints']->default_value != '-2') {
|
|
||||||
// questiondecimalpoints should be default -2
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, -2, 'decimalpoints');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('sumgrades', $columns) && empty($columns['sumgrades']->not_null)) {
|
|
||||||
// sumgrades should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'questions');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('grade', $columns) && empty($columns['grade']->not_null)) {
|
|
||||||
// grade should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'sumgrades');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrade_mod_savepoint(true, 2011011400, 'quiz');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($oldversion < 2011011401) {
|
|
||||||
// Fix quiz_attempts in the post table after upgrade from 1.9
|
|
||||||
$table = new xmldb_table('quiz_attempts');
|
|
||||||
$columns = $DB->get_columns('quiz_attempts');
|
|
||||||
|
|
||||||
if (array_key_exists('sumgrades', $columns) && empty($columns['sumgrades']->not_null)) {
|
|
||||||
// sumgrades should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'attempt');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrade_mod_savepoint(true, 2011011401, 'quiz');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($oldversion < 2011011402) {
|
|
||||||
// Fix quiz_feedback in the post table after upgrade from 1.9
|
|
||||||
$table = new xmldb_table('quiz_feedback');
|
|
||||||
$columns = $DB->get_columns('quiz_feedback');
|
|
||||||
|
|
||||||
if (array_key_exists('mingrade', $columns) && empty($columns['mingrade']->not_null)) {
|
|
||||||
// mingrade should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'feedbacktextformat');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('maxgrade', $columns) && empty($columns['maxgrade']->not_null)) {
|
|
||||||
// maxgrade should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'mingrade');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrade_mod_savepoint(true, 2011011402, 'quiz');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($oldversion < 2011011403) {
|
|
||||||
// Fix quiz_grades in the post table after upgrade from 1.9
|
|
||||||
$table = new xmldb_table('quiz_grades');
|
|
||||||
$columns = $DB->get_columns('quiz_grades');
|
|
||||||
|
|
||||||
if (array_key_exists('grade', $columns) && empty($columns['grade']->not_null)) {
|
|
||||||
// grade should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'userid');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrade_mod_savepoint(true, 2011011403, 'quiz');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($oldversion < 2011011404) {
|
|
||||||
// Fix quiz_question_instances in the post table after upgrade from 1.9
|
|
||||||
$table = new xmldb_table('quiz_question_instances');
|
|
||||||
$columns = $DB->get_columns('quiz_question_instances');
|
|
||||||
|
|
||||||
if (array_key_exists('grade', $columns) && empty($columns['grade']->not_null)) {
|
|
||||||
// grade should be NOT NULL DEFAULT '0.0000000',
|
|
||||||
// Fixed in earlier upgrade code
|
|
||||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, '0', 'question');
|
|
||||||
if ($dbman->field_exists($table, $field)) {
|
|
||||||
$dbman->change_field_default($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrade_mod_savepoint(true, 2011011404, 'quiz');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$module->version = 2011011404; // The (date) version of this module
|
$module->version = 2010111904; // The (date) version of this module
|
||||||
$module->requires = 2010080300; // Requires this Moodle version
|
$module->requires = 2010080300; // Requires this Moodle version
|
||||||
$module->cron = 0; // How often should cron check this module (seconds)?
|
$module->cron = 0; // How often should cron check this module (seconds)?
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue