diff --git a/mod/quiz/report/statistics/db/install.php b/mod/quiz/report/statistics/db/install.php index bb8880948d6..82f4cf453f0 100644 --- a/mod/quiz/report/statistics/db/install.php +++ b/mod/quiz/report/statistics/db/install.php @@ -33,10 +33,17 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_quiz_statistics_install() { global $DB; + $dbman = $DB->get_manager(); + $record = new stdClass(); $record->name = 'statistics'; $record->displayorder = 8000; $record->cron = 18000; $record->capability = 'quiz/statistics:view'; - $DB->insert_record('quiz_reports', $record); + + if ($dbman->table_exists('quiz_reports')) { + $DB->insert_record('quiz_reports', $record); + } else { + $DB->insert_record('quiz_report', $record); + } } diff --git a/question/type/match/db/upgrade.php b/question/type/match/db/upgrade.php index 42d9fa54d04..5703b811100 100644 --- a/question/type/match/db/upgrade.php +++ b/question/type/match/db/upgrade.php @@ -74,11 +74,18 @@ function xmldb_qtype_match_upgrade($oldversion) { // Define field correctfeedback to be added to question_match $table = new xmldb_table('question_match'); - $field = new xmldb_field('correctfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'shuffleanswers'); + $field = new xmldb_field('correctfeedback', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'shuffleanswers'); // Conditionally launch add field correctfeedback if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); + + // Now fill it with ''; + $DB->set_field('question_match', 'correctfeedback', ''); + + // Now add the not null constraint. + $field = new xmldb_field('correctfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'shuffleanswers'); + $dbman->change_field_notnull($table, $field); } // match savepoint reached @@ -104,11 +111,18 @@ function xmldb_qtype_match_upgrade($oldversion) { // Define field partiallycorrectfeedback to be added to question_match $table = new xmldb_table('question_match'); - $field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'correctfeedbackformat'); + $field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, '', 'correctfeedbackformat'); // Conditionally launch add field partiallycorrectfeedback if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); + + // Now fill it with ''; + $DB->set_field('question_match', 'partiallycorrectfeedback', ''); + + // Now add the not null constraint. + $field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'correctfeedbackformat'); + $dbman->change_field_notnull($table, $field); } // match savepoint reached @@ -139,6 +153,13 @@ function xmldb_qtype_match_upgrade($oldversion) { // Conditionally launch add field incorrectfeedback if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); + + // Now fill it with ''; + $DB->set_field('question_match', 'incorrectfeedback', ''); + + // Now add the not null constraint. + $field = new xmldb_field('incorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'partiallycorrectfeedbackformat'); + $dbman->change_field_notnull($table, $field); } // match savepoint reached