Permalink
Browse files

MDL-17104 better delete of unused sub questions, merge from HEAD

  • Loading branch information...
1 parent 79c5abb commit c589f054b464a3b270194e237c853104b035cbbd pichetp committed Nov 15, 2008
Showing with 10 additions and 4 deletions.
  1. +10 −4 question/type/multianswer/questiontype.php
@@ -113,16 +113,22 @@ function save_question_options($question) {
}
$wrapped->name = $question->name;
$wrapped->parent = $question->id;
- $wrapped->category = $question->category;
+ $previousid = $wrapped->id ;
+ $wrapped->category = $question->category ;
$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 c589f05

Please sign in to comment.