From: jamiesensei Date: Wed, 10 Oct 2007 15:23:24 +0000 (+0000) Subject: fix for MDL-11692. There were notices about subquestions not being defined. This... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6f9ce92696ab5802bf6e9e25566cdc5f7685aaf0;p=moodle.git fix for MDL-11692. There were notices about subquestions not being defined. This seems to indicate that there is a problem elsewhere that somehow matching questions without subquestions are in the site db. But suppressed the notice by testing to see if subquestions is set before looping through the questions. --- diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index f300c45658..f4d9996dee 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -650,15 +650,18 @@ class question_match_qtype extends default_questiontype { function find_file_links($question, $courseid){ // find links in the question_match_sub table. $urls = array(); - foreach ($question->options->subquestions as $subquestion) { - $urls += question_find_file_links_from_html($subquestion->questiontext, $courseid); - } + if (isset($question->options->subquestions)){ + foreach ($question->options->subquestions as $subquestion) { + $urls += question_find_file_links_from_html($subquestion->questiontext, $courseid); + } - //set all the values of the array to the question object - if ($urls){ - $urls = array_combine(array_keys($urls), array_fill(0, count($urls), array($question->id))); + //set all the values of the array to the question object + if ($urls){ + $urls = array_combine(array_keys($urls), array_fill(0, count($urls), array($question->id))); + } } $urls = array_merge_recursive($urls, parent::find_file_links($question, $courseid)); + return $urls; }