Merge branch 'MDL-77328-master-fix' of https://github.com/junpataleta/moodle
This commit is contained in:
@@ -26,6 +26,9 @@ namespace core_question\local\bank;
|
||||
*/
|
||||
abstract class view_component {
|
||||
|
||||
/** @var view Question bank view. */
|
||||
protected $qbank;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param view $qbank the question bank view we are helping to render.
|
||||
|
||||
@@ -46,6 +46,12 @@ if (!class_exists('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() {
|
||||
return true;
|
||||
}
|
||||
@@ -1203,9 +1209,9 @@ class qformat_xml extends qformat_default {
|
||||
$contextid, 'question', 'generalfeedback', $question->id);
|
||||
if (!empty($question->options->answers)) {
|
||||
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);
|
||||
$answer->feedbackfiles = $fs->get_area_files(
|
||||
$this->feedbackfiles[$answer->id] = $fs->get_area_files(
|
||||
$contextid, 'question', 'answerfeedback', $answer->id);
|
||||
}
|
||||
}
|
||||
@@ -1593,10 +1599,10 @@ class qformat_xml extends qformat_default {
|
||||
$output = '';
|
||||
$output .= " <answer fraction=\"{$percent}\" {$this->format($answer->answerformat)}>\n";
|
||||
$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 .= $this->writetext($answer->feedback, 4);
|
||||
$output .= $this->write_files($answer->feedbackfiles);
|
||||
$output .= $this->write_files($this->feedbackfiles[$answer->id]);
|
||||
$output .= " </feedback>\n";
|
||||
$output .= $extra;
|
||||
$output .= " </answer>\n";
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
This file describes API changes in /question/type/calculated/*.
|
||||
|
||||
=== 4.3 ===
|
||||
* \qtype_calculated answers are now of the type \qtype_calculated\qtype_calculated_answer which extends \qtype_numerical_answer.
|
||||
Plugins extending \qtype_calculated and still reference \qtype_numerical_answer in their code (e.g. in test helper functions)
|
||||
should update their code to reference \qtype_calculated\qtype_calculated_answer instead.
|
||||
@@ -64,9 +64,9 @@ class qtype_calculatedmulti_test_helper extends question_test_helper {
|
||||
$q->incorrectfeedbackformat = FORMAT_HTML;
|
||||
$q->shownumcorrect = 1;
|
||||
$q->answers = array(
|
||||
13 => new question_answer(13, '{={a} + {b}}', 1.0, 'Very good.', FORMAT_HTML),
|
||||
14 => new question_answer(14, '{={a} - {b}}', 0.0, 'Add. not subtract!', FORMAT_HTML),
|
||||
17 => new question_answer(17, '{={a} + 2 * {b}}', 0.0, 'Just add.', FORMAT_HTML),
|
||||
13 => new \qtype_calculated\qtype_calculated_answer(13, '{={a} + {b}}', 1.0, 'Very good.', FORMAT_HTML, 0),
|
||||
14 => new \qtype_calculated\qtype_calculated_answer(14, '{={a} - {b}}', 0.0, 'Add. not subtract!', FORMAT_HTML, 0),
|
||||
17 => new \qtype_calculated\qtype_calculated_answer(17, '{={a} + 2 * {b}}', 0.0, 'Just add.', FORMAT_HTML, 0),
|
||||
);
|
||||
$q->answers[13]->correctanswerlength = 2;
|
||||
$q->answers[13]->correctanswerformat = 1;
|
||||
@@ -107,10 +107,10 @@ class qtype_calculatedmulti_test_helper extends question_test_helper {
|
||||
$q->incorrectfeedbackformat = FORMAT_HTML;
|
||||
$q->shownumcorrect = 1;
|
||||
$q->answers = array(
|
||||
13 => new qtype_numerical_answer(13, '{a} + {b}!', 0.5, 'Good', FORMAT_HTML, 0),
|
||||
14 => new qtype_numerical_answer(14, '{={a} + {b}}', 0.5, 'Good',
|
||||
13 => new \qtype_calculated\qtype_calculated_answer(13, '{a} + {b}!', 0.5, 'Good', FORMAT_HTML, 0),
|
||||
14 => new \qtype_calculated\qtype_calculated_answer(14, '{={a} + {b}}', 0.5, 'Good',
|
||||
FORMAT_HTML, 0),
|
||||
17 => new qtype_numerical_answer(17, '{={a} - {b}}', -0.5, 'Wrong.', FORMAT_HTML, 0),
|
||||
17 => new \qtype_calculated\qtype_calculated_answer(17, '{={a} - {b}}', -0.5, 'Wrong.', FORMAT_HTML, 0),
|
||||
);
|
||||
$q->answers[13]->correctanswerlength = 2;
|
||||
$q->answers[13]->correctanswerformat = 1;
|
||||
|
||||
@@ -54,10 +54,10 @@ class qtype_calculatedsimple_test_helper extends question_test_helper {
|
||||
$q->generalfeedback = 'Generalfeedback: {={a} + {b}} is the right answer.';
|
||||
|
||||
$q->answers = array(
|
||||
13 => new qtype_numerical_answer(13, '{a} + {b}', 1.0, 'Very good.', FORMAT_HTML, 0),
|
||||
14 => new qtype_numerical_answer(14, '{a} - {b}', 0.0, 'Add. not subtract!.',
|
||||
13 => new \qtype_calculated\qtype_calculated_answer(13, '{a} + {b}', 1.0, 'Very good.', FORMAT_HTML, 0),
|
||||
14 => new \qtype_calculated\qtype_calculated_answer(14, '{a} - {b}', 0.0, 'Add. not subtract!.',
|
||||
FORMAT_HTML, 0),
|
||||
17 => new qtype_numerical_answer(17, '*', 0.0, 'Completely wrong.', FORMAT_HTML, 0),
|
||||
17 => new \qtype_calculated\qtype_calculated_answer(17, '*', 0.0, 'Completely wrong.', FORMAT_HTML, 0),
|
||||
);
|
||||
foreach ($q->answers as $answer) {
|
||||
$answer->correctanswerlength = 2;
|
||||
|
||||
Reference in New Issue
Block a user