MDL-28686 QE2 upgrade: recognize manually graded, deleted questions
authorHenning Bostelmann <henning.bostelmann@york.ac.uk>
Tue, 9 Aug 2011 16:24:09 +0000 (17:24 +0100)
committerHenning Bostelmann <henning.bostelmann@york.ac.uk>
Fri, 26 Aug 2011 13:38:50 +0000 (14:38 +0100)
question/engine/upgrade/upgradelib.php

index 5ba8e1c..6f0aac8 100644 (file)
@@ -342,6 +342,15 @@ class question_engine_attempt_upgrader {
     }
 
     protected function get_converter_class_name($question, $quiz, $qsessionid) {
+        global $DB;
+        if ($question->qtype == 'deleted') {
+            $where = '(question = :questionid OR '.$DB->sql_like('answer', ':randomid').') AND event = 7';
+            $params = array('questionid'=>$question->id, 'randomid'=>"random{$question->id}-%");
+            if ($DB->record_exists_select('question_states', $where, $params)) {
+                $this->logger->log_assumption("Assuming that deleted question {$question->id} was manually graded.");
+                return 'qbehaviour_manualgraded_converter';
+            }
+        }
         if ($question->qtype == 'essay') {
             return 'qbehaviour_manualgraded_converter';
         } else if ($question->qtype == 'description') {