Permalink
Browse files

Merge branch 'MDL-40370_25' of git://github.com/timhunt/moodle into M…

…OODLE_25_STABLE
  • Loading branch information...
2 parents c11621b + 33b4331 commit 75b8d4a1465e2f1178ffdc9a824ec0e573ab5a1b @stronk7 stronk7 committed Jul 1, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 question/type/shortanswer/db/upgrade.php
@@ -39,6 +39,25 @@ function xmldb_qtype_shortanswer_upgrade($oldversion) {
// Moodle v2.4.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2013011799) {
+ // Find duplicate rows before they break the 2013011803 step below.
+ $problemids = $DB->get_recordset_sql("
+ SELECT question, MIN(id) AS recordidtokeep
+ FROM {question_shortanswer}
+ GROUP BY question
+ HAVING COUNT(1) > 1
+ ");
+ foreach ($problemids as $problem) {
+ $DB->delete_records_select('question_shortanswer',
+ 'question = ? AND id > ?',
+ array($problem->question, $problem->recordidtokeep));
+ }
+ $problemids->close();
+
+ // Shortanswer savepoint reached.
+ upgrade_plugin_savepoint(true, 2013011799, 'qtype', 'shortanswer');
+ }
+
if ($oldversion < 2013011800) {
// Define field answers to be dropped from question_shortanswer.

0 comments on commit 75b8d4a

Please sign in to comment.