From: pichetp Date: Sun, 9 Nov 2008 21:55:58 +0000 (+0000) Subject: MDL-17104 and MDL-17105 unused old questions are deleted more correclty and take in X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=26053641176199c614407353b2f62c2830ebce7a;p=moodle.git MDL-17104 and MDL-17105 unused old questions are deleted more correclty and take in account that the actual questiontype/save_question() create a new question when categorytomove is not set.. --- diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index adab307b07..9df39188c1 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -128,16 +128,22 @@ class embedded_cloze_qtype extends default_questiontype { } $wrapped->name = $question->name; $wrapped->parent = $question->id; + $previousid = $wrapped->id ; $wrapped->category = $question->category . ',1'; // save_question strips this extra bit off again. $wrapped = $QTYPES[$wrapped->qtype]->save_question($wrapped, $wrapped, $question->course); $sequence[] = $wrapped->id; + if ($previousid != 0 && $previousid != $wrapped->id ) { + // for some reasons a new question has been created + // so delete the old one + delete_question($previousid) ; + } } // Delete redundant wrapped questions - if(is_array($oldwrappedids) && count($oldwrappedids)){ - foreach ($oldwrappedids as $id) { - delete_question($id) ; + if(is_array($oldwrappedquestions) && count($oldwrappedquestions)){ + foreach ($oldwrappedquestions as $oldwrappedquestion) { + delete_question($oldwrappedquestion->id) ; } }