Merge branch 'MDL-28512' of git://github.com/timhunt/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 22 Jan 2013 00:02:12 +0000 (01:02 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 22 Jan 2013 00:02:12 +0000 (01:02 +0100)
question/type/essay/db/upgrade.php
question/type/essay/questiontype.php
question/type/essay/version.php

index 69ecb56..6f3a66f 100644 (file)
@@ -107,6 +107,15 @@ function xmldb_qtype_essay_upgrade($oldversion) {
     // Moodle v2.4.0 release upgrade line
     // Put any upgrade step following this
 
+    if ($oldversion < 2013011800) {
+        // Then we delete the old question_answers rows for essay questions.
+        $DB->delete_records_select('qtype_essay_options', "NOT EXISTS (
+                SELECT 1 FROM {question} WHERE qtype = 'essay' AND
+                    {question}.id = {qtype_essay_options}.questionid)");
+
+        // Essay savepoint reached.
+        upgrade_plugin_savepoint(true, 2013011800, 'qtype', 'essay');
+    }
 
     return true;
 }
index dac965e..10a1346 100644 (file)
@@ -80,6 +80,13 @@ class qtype_essay extends question_type {
         $question->graderinfoformat = $questiondata->options->graderinfoformat;
     }
 
+    public function delete_question($questionid, $contextid) {
+        global $DB;
+
+        $DB->delete_records('qtype_essay_options', array('questionid' => $questionid));
+        parent::delete_question($questionid, $contextid);
+    }
+
     /**
      * @return array the different response formats that the question type supports.
      * internal name => human-readable name.
index 997941c..67a0d8e 100644 (file)
@@ -26,7 +26,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->component = 'qtype_essay';
-$plugin->version   = 2012112900;
+$plugin->version   = 2013011800;
 
 $plugin->requires  = 2012112900;