]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed backup and restore for match questions
authorgustav_delius <gustav_delius>
Sun, 19 Mar 2006 09:50:43 +0000 (09:50 +0000)
committergustav_delius <gustav_delius>
Sun, 19 Mar 2006 09:50:43 +0000 (09:50 +0000)
mod/quiz/backuplib.php
question/questiontypes/match/restorelib.php
question/restorelib.php

index 3a286ffe704053085664f5a474f956e157b8b12e..b2c9a2c6c9a844afd56e8ed9b88921bc4e85aa34 100644 (file)
                 $status = fwrite ($bf,start_tag("MATCH",7,true));
                 //Print match contents
                 fwrite ($bf,full_tag("ID",8,false,$match->id));
+                fwrite ($bf,full_tag("CODE",8,false,$match->code));
                 fwrite ($bf,full_tag("QUESTIONTEXT",8,false,$match->questiontext));
                 fwrite ($bf,full_tag("ANSWERTEXT",8,false,$match->answertext));
-                fwrite ($bf,full_tag("SHUFFLEANSWERS",8,false,$randomsamatch->shuffleanswers));
                 $status = fwrite ($bf,end_tag("MATCH",7,true));
             }
             $status = fwrite ($bf,end_tag("MATCHS",6,true));
index 382b69df0b5b163c703ea2bf0a94acd335f8bd53..e3d3026cfe047f87f47e45ee141947503e7d1e70 100644 (file)
 
             //Now, build the question_match_SUB record structure
             $match_sub->question = $new_question_id;
+            $match_sub->code = backup_todb($mat_info['#']['CODE']['0']['#']);
+            if (!$match_sub->code) {
+                $match_sub->code = $oldid;
+            }
             $match_sub->questiontext = backup_todb($mat_info['#']['QUESTIONTEXT']['0']['#']);
             $match_sub->answertext = backup_todb($mat_info['#']['ANSWERTEXT']['0']['#']);
 
index d9e7bd62ab797ae2ff0ceb4a2a500f5ffd66d7de..30add466659b9902c27f5aa0b7780053fede239a 100644 (file)
                         //Extract the match_sub for the question and the answer
                         $exploded = explode("-",$tok);
                         $match_question_id = $exploded[0];
-                        $match_answer_id = $exploded[1];
+                        $match_answer_code = $exploded[1];
                         //Get the match_sub from backup_ids (for the question)
                         if (!$match_que = backup_getid($restore->backup_unique_code,"question_match_sub",$match_question_id)) {
                             echo 'Could not recode question_match_sub '.$match_question_id.'<br />';
                         }
-                        //Get the match_sub from backup_ids (for the answer)
-                        if (!$match_ans = backup_getid($restore->backup_unique_code,"question_match_sub",$match_answer_id)) {
-                            echo 'Could not recode question_match_sub '.$match_answer_id.'<br />';
-                        }
-                        if ($match_que) {
-                            //It the question hasn't response, it must be 0
-                            if (!$match_ans and $match_answer_id == 0) {
-                                $match_ans->new_id = 0;
-                            }
-                            if ($in_first) {
-                                $answer_field .= $match_que->new_id."-".$match_ans->new_id;
-                                $in_first = false;
-                            } else {
-                                $answer_field .= ",".$match_que->new_id."-".$match_ans->new_id;
-                            }
+                        if ($in_first) {
+                            $answer_field .= $match_que->new_id."-".$match_answer_code;
+                            $in_first = false;
+                        } else {
+                            $answer_field .= ",".$match_que->new_id."-".$match_answer_code;
                         }
                         //check for next
                         $tok = strtok(",");