mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 16:13:28 +02:00
MDL-77328 qformat_xml: Avoid dynamic declaration for question_answer
Declare qformat_xml::answerfiles and qformat_xml::feedbackfiles instead of dynamically declaring answerfiles and feedbackfiles for the question_answer instance when exporting questions and answers to XML format.
This commit is contained in:
parent
185c14ad1a
commit
73259066c4
1 changed files with 10 additions and 4 deletions
|
@ -46,6 +46,12 @@ if (!class_exists('qformat_default')) {
|
||||||
*/
|
*/
|
||||||
class qformat_xml extends qformat_default {
|
class qformat_xml extends qformat_default {
|
||||||
|
|
||||||
|
/** @var array Array of files for question answers. */
|
||||||
|
protected $answerfiles = [];
|
||||||
|
|
||||||
|
/** @var array Array of files for feedback to question answers. */
|
||||||
|
protected $feedbackfiles = [];
|
||||||
|
|
||||||
public function provide_import() {
|
public function provide_import() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1203,9 +1209,9 @@ class qformat_xml extends qformat_default {
|
||||||
$contextid, 'question', 'generalfeedback', $question->id);
|
$contextid, 'question', 'generalfeedback', $question->id);
|
||||||
if (!empty($question->options->answers)) {
|
if (!empty($question->options->answers)) {
|
||||||
foreach ($question->options->answers as $answer) {
|
foreach ($question->options->answers as $answer) {
|
||||||
$answer->answerfiles = $fs->get_area_files(
|
$this->answerfiles[$answer->id] = $fs->get_area_files(
|
||||||
$contextid, 'question', 'answer', $answer->id);
|
$contextid, 'question', 'answer', $answer->id);
|
||||||
$answer->feedbackfiles = $fs->get_area_files(
|
$this->feedbackfiles[$answer->id] = $fs->get_area_files(
|
||||||
$contextid, 'question', 'answerfeedback', $answer->id);
|
$contextid, 'question', 'answerfeedback', $answer->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1593,10 +1599,10 @@ class qformat_xml extends qformat_default {
|
||||||
$output = '';
|
$output = '';
|
||||||
$output .= " <answer fraction=\"{$percent}\" {$this->format($answer->answerformat)}>\n";
|
$output .= " <answer fraction=\"{$percent}\" {$this->format($answer->answerformat)}>\n";
|
||||||
$output .= $this->writetext($answer->answer, 3);
|
$output .= $this->writetext($answer->answer, 3);
|
||||||
$output .= $this->write_files($answer->answerfiles);
|
$output .= $this->write_files($this->answerfiles[$answer->id]);
|
||||||
$output .= " <feedback {$this->format($answer->feedbackformat)}>\n";
|
$output .= " <feedback {$this->format($answer->feedbackformat)}>\n";
|
||||||
$output .= $this->writetext($answer->feedback, 4);
|
$output .= $this->writetext($answer->feedback, 4);
|
||||||
$output .= $this->write_files($answer->feedbackfiles);
|
$output .= $this->write_files($this->feedbackfiles[$answer->id]);
|
||||||
$output .= " </feedback>\n";
|
$output .= " </feedback>\n";
|
||||||
$output .= $extra;
|
$output .= $extra;
|
||||||
$output .= " </answer>\n";
|
$output .= " </answer>\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue