mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
qformat_gift MDL-26059 fails to import truefalse questions with answer true.
This commit is contained in:
parent
5a7f931ee5
commit
2c00fa161e
2 changed files with 69 additions and 1 deletions
|
@ -392,7 +392,7 @@ class qformat_gift extends qformat_default {
|
||||||
list($answer, $wrongfeedback, $rightfeedback) =
|
list($answer, $wrongfeedback, $rightfeedback) =
|
||||||
$this->split_truefalse_comment($answertext, $question->questiontextformat);
|
$this->split_truefalse_comment($answertext, $question->questiontextformat);
|
||||||
|
|
||||||
if ($answer == "T" OR $answer == "TRUE") {
|
if ($answer['text'] == "T" OR $answer['text'] == "TRUE") {
|
||||||
$question->correctanswer = 1;
|
$question->correctanswer = 1;
|
||||||
$question->feedbacktrue = $rightfeedback;
|
$question->feedbacktrue = $rightfeedback;
|
||||||
$question->feedbackfalse = $wrongfeedback;
|
$question->feedbackfalse = $wrongfeedback;
|
||||||
|
|
|
@ -659,6 +659,74 @@ FALSE#42 is the Ultimate Answer.#You gave the right answer.}";
|
||||||
$this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
|
$this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_import_truefalse_true_answer1() {
|
||||||
|
$gift = "// name 0-11
|
||||||
|
::2-08 TSL::TSL is blablabla.{T}";
|
||||||
|
$lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
|
||||||
|
|
||||||
|
$importer = new qformat_gift();
|
||||||
|
$q = $importer->readquestion($lines);
|
||||||
|
|
||||||
|
$expectedq = (object) array(
|
||||||
|
'name' => '2-08 TSL',
|
||||||
|
'questiontext' => "TSL is blablabla.",
|
||||||
|
'questiontextformat' => FORMAT_MOODLE,
|
||||||
|
'generalfeedback' => '',
|
||||||
|
'generalfeedbackformat' => FORMAT_MOODLE,
|
||||||
|
'qtype' => 'truefalse',
|
||||||
|
'defaultgrade' => 1,
|
||||||
|
'penalty' => 1,
|
||||||
|
'length' => 1,
|
||||||
|
'correctanswer' => 1,
|
||||||
|
'feedbacktrue' => array(
|
||||||
|
'text' => '',
|
||||||
|
'format' => FORMAT_MOODLE,
|
||||||
|
'files' => array(),
|
||||||
|
),
|
||||||
|
'feedbackfalse' => array(
|
||||||
|
'text' => '',
|
||||||
|
'format' => FORMAT_MOODLE,
|
||||||
|
'files' => array(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_import_truefalse_true_answer2() {
|
||||||
|
$gift = "// name 0-11
|
||||||
|
::2-08 TSL::TSL is blablabla.{TRUE}";
|
||||||
|
$lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
|
||||||
|
|
||||||
|
$importer = new qformat_gift();
|
||||||
|
$q = $importer->readquestion($lines);
|
||||||
|
|
||||||
|
$expectedq = (object) array(
|
||||||
|
'name' => '2-08 TSL',
|
||||||
|
'questiontext' => "TSL is blablabla.",
|
||||||
|
'questiontextformat' => FORMAT_MOODLE,
|
||||||
|
'generalfeedback' => '',
|
||||||
|
'generalfeedbackformat' => FORMAT_MOODLE,
|
||||||
|
'qtype' => 'truefalse',
|
||||||
|
'defaultgrade' => 1,
|
||||||
|
'penalty' => 1,
|
||||||
|
'length' => 1,
|
||||||
|
'correctanswer' => 1,
|
||||||
|
'feedbacktrue' => array(
|
||||||
|
'text' => '',
|
||||||
|
'format' => FORMAT_MOODLE,
|
||||||
|
'files' => array(),
|
||||||
|
),
|
||||||
|
'feedbackfalse' => array(
|
||||||
|
'text' => '',
|
||||||
|
'format' => FORMAT_MOODLE,
|
||||||
|
'files' => array(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_export_truefalse() {
|
public function test_export_truefalse() {
|
||||||
$qdata = (object) array(
|
$qdata = (object) array(
|
||||||
'id' => 666 ,
|
'id' => 666 ,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue