Permalink
Browse files

Merge from HEAD MDL-17104 and MDL-17105 unused old questions are dele…

…ted more

correclty and take in account that the actual questiontype/save_question()
create a new question  when categorytomove is not set..
  • Loading branch information...
1 parent 5037cf7 commit bcc188577958d176465ba2569b3d601a1efd2d39 pichetp committed Nov 9, 2008
Showing with 9 additions and 3 deletions.
  1. +9 −3 question/type/multianswer/questiontype.php
@@ -112,16 +112,22 @@ function save_question_options($question) {
}
$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) ;
}
}

0 comments on commit bcc1885

Please sign in to comment.