]> git.mjollnir.org Git - moodle.git/commitdiff
fixing some problems with multichoice file link find and replace code for multichoice...
authorjamiesensei <jamiesensei>
Fri, 17 Aug 2007 10:50:52 +0000 (10:50 +0000)
committerjamiesensei <jamiesensei>
Fri, 17 Aug 2007 10:50:52 +0000 (10:50 +0000)
question/type/multichoice/questiontype.php

index 042b632e24d106e78ece65fa6ebce15a0190c2a0..744816c6a7ecf90d6791d04f62ca91d2293f2012 100644 (file)
@@ -623,11 +623,12 @@ class question_multichoice_qtype extends default_questiontype {
 
     function find_file_links($question, $courseid){
         $urls = array();
-        $urls = parent::find_file_links($question, $courseid);
-        // find links in the question_match_sub table.
-        foreach ($question->options->subquestions as $subquestion) {
-            $urls += question_find_file_links_from_html($subquestion->questiontext, $courseid);
-
+        // find links in the answers table.
+        $urls +=  question_find_file_links_from_html($question->options->correctfeedback, $courseid);
+        $urls +=  question_find_file_links_from_html($question->options->partiallycorrectfeedback, $courseid);
+        $urls +=  question_find_file_links_from_html($question->options->incorrectfeedback, $courseid);
+        foreach ($question->options->answers as $answer) {
+            $urls += question_find_file_links_from_html($answer->answer, $courseid);
         }
         //set all the values of the array to the question id
         if ($urls){
@@ -649,6 +650,15 @@ class question_multichoice_qtype extends default_questiontype {
                 error('Couldn\'t update \'question_multichoice\' record '.$question->options->id);
             }
         }
+        $answerchanged = false;
+        foreach ($question->options->answers as $answer) {
+            $answer->answer = question_replace_file_links_in_html($answer->answer, $fromcourseid, $tocourseid, $url, $destination, $answerchanged);
+            if ($answerchanged){
+                if (!update_record('question_answers', addslashes_recursive($answer))){
+                    error('Couldn\'t update \'question_answers\' record '.$answer->id);
+                }
+            }
+        }
     }
 }