コード例 #1
0
    public function test_import_backslash()
    {
        // There was a bug (MDL-34171) where \\ in the import was getting changed
        // to \. This test checks for that.
        // We need \\\\ in the test code, because of PHPs string escaping rules.
        $gift = '
// essay
::double backslash:: A \\\\ B \\\\\\\\ C{}';
        $lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
        $importer = new qformat_gift();
        $q = $importer->readquestion($lines);
        $expectedq = (object) array('name' => 'double backslash', 'questiontext' => 'A \\ B \\\\ C', 'questiontextformat' => FORMAT_MOODLE, 'generalfeedback' => '', 'generalfeedbackformat' => FORMAT_MOODLE, 'qtype' => 'essay', 'defaultmark' => 1, 'penalty' => 0.3333333, 'length' => 1, 'responseformat' => 'editor', 'responsefieldlines' => 15, 'attachments' => 0, 'graderinfo' => array('text' => '', 'format' => FORMAT_HTML, 'files' => array()));
        $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
    }
コード例 #2
0
ファイル: testgiftformat.php プロジェクト: nigeldaley/moodle
    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',
            'defaultmark' => 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);
    }
コード例 #3
0
ファイル: giftformat_test.php プロジェクト: evltuma/moodle
    public function test_import_pre_content()
    {
        $gift = '
::Q001::[html]<p>What would running the test method print?</p>
<pre>
    public void test() \\{
        method1();
        method2();
        method3();
    \\}
</pre>
{}';
        $lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
        $importer = new qformat_gift();
        $q = $importer->readquestion($lines);
        $expectedq = (object) array('name' => 'Q001', 'questiontext' => '<p>What would running the test method print?</p>
<pre>
    public void test() {
        method1();
        method2();
        method3();
    }
</pre>', 'questiontextformat' => FORMAT_HTML, 'generalfeedback' => '', 'generalfeedbackformat' => FORMAT_HTML, 'qtype' => 'essay', 'defaultmark' => 1, 'penalty' => 0.3333333, 'length' => 1, 'responseformat' => 'editor', 'responsefieldlines' => 15, 'attachments' => 0, 'graderinfo' => array('text' => '', 'format' => FORMAT_HTML, 'files' => array()));
        $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
    }
コード例 #4
0
ファイル: testgiftformat.php プロジェクト: vuchannguyen/web
 public function test_import_truefalse()
 {
     $gift = "\n// true/false\n::Q1:: 42 is the Absolute Answer to everything.{\nFALSE#42 is the Ultimate Answer.#You gave the right answer.}";
     $lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
     $importer = new qformat_gift();
     $q = $importer->readquestion($lines);
     $expectedq = (object) array('name' => 'Q1', 'questiontext' => "42 is the Absolute Answer to everything.", 'questiontextformat' => FORMAT_MOODLE, 'generalfeedback' => '', 'generalfeedbackformat' => FORMAT_MOODLE, 'qtype' => 'truefalse', 'defaultgrade' => 1, 'penalty' => 1, 'length' => 1, 'correctanswer' => 0, 'feedbacktrue' => array('text' => '42 is the Ultimate Answer.', 'format' => FORMAT_MOODLE, 'files' => array()), 'feedbackfalse' => array('text' => 'You gave the right answer.', 'format' => FORMAT_MOODLE, 'files' => array()));
     $this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
 }