From: thepurpleblob Date: Thu, 28 Aug 2008 10:59:22 +0000 (+0000) Subject: MDL-16252 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=33ed59a2088ac25c3778f7318a6714facce0f904;p=moodle.git MDL-16252 Fixed some notices with essay questions when there is no feedback Merged from STABLE_19 --- diff --git a/question/format/xml/format.php b/question/format/xml/format.php index b203e1ae23..df5a6aaf6a 100755 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -397,10 +397,7 @@ class qformat_xml extends qformat_default { $qo->qtype = ESSAY; // get feedback - $qo->feedback = $this->import_text( $question['#']['answer'][0]['#']['feedback'][0]['#']['text'] ); - - // handle answer - $answer = $question['#']['answer'][0]; + $qo->feedback = $this->getpath( $question, array('#','answer',0,'#','feedback',0,'#','text',0,'#'), '', true ); // get fraction - tag is deprecated $qo->fraction = $this->getpath( $question, array('@','fraction'), 0 ) / 100; @@ -929,15 +926,16 @@ class qformat_xml extends qformat_default { } break; case ESSAY: - foreach ($question->options->answers as $answer) { - $percent = 100 * $answer->fraction; - $expout .= "\n"; - $expout .= " ".$this->writetext( $answer->feedback )."\n"; - // fraction tag is deprecated - // $expout .= " {$answer->fraction}\n"; - $expout .= "\n"; + if (!empty($question->options->answers)) { + foreach ($question->options->answers as $answer) { + $percent = 100 * $answer->fraction; + $expout .= "\n"; + $expout .= " ".$this->writetext( $answer->feedback )."\n"; + // fraction tag is deprecated + // $expout .= " {$answer->fraction}\n"; + $expout .= "\n"; + } } - break; case CALCULATED: foreach ($question->options->answers as $answer) {