From 88c8015ea0910a3180639eb2a6db30526239a5e4 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Fri, 17 Aug 2007 10:50:52 +0000 Subject: [PATCH] fixing some problems with multichoice file link find and replace code for multichoice qtype. --- question/type/multichoice/questiontype.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index 042b632e24..744816c6a7 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -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); + } + } + } } } -- 2.39.5