Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 25... Línea 25...
25
 * Test for question_definition base classes.
25
 * Test for question_definition base classes.
26
 *
26
 *
27
 * @package   core_question
27
 * @package   core_question
28
 * @copyright  2015 The Open University
28
 * @copyright  2015 The Open University
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
30
 * @covers     \question_definition
30
 */
31
 */
31
class question_definition_test extends \advanced_testcase {
32
final class question_definition_test extends \advanced_testcase {
32
    public function test_make_html_inline(): void {
33
    public function test_make_html_inline(): void {
33
        // Base class is abstract, so we need to pick one qusetion type to test this method.
34
        // Base class is abstract, so we need to pick one qusetion type to test this method.
34
        $mc = \test_question_maker::make_a_multichoice_single_question();
35
        $mc = \test_question_maker::make_a_multichoice_single_question();
35
        $this->assertEquals('Frog', $mc->make_html_inline('<p>Frog</p>'));
36
        $this->assertEquals('Frog', $mc->make_html_inline('<p>Frog</p>'));
36
        $this->assertEquals('Frog', $mc->make_html_inline('<p>Frog<br /></p>'));
37
        $this->assertEquals('Frog', $mc->make_html_inline('<p>Frog<br /></p>'));
Línea 42... Línea 43...
42
                $mc->make_html_inline(" <p> Frog </p> \n\r
43
                $mc->make_html_inline(" <p> Frog </p> \n\r
43
                    <p> XXX <img src='http://example.com/pic.png' alt='Graph' /> </p> "));
44
                    <p> XXX <img src='http://example.com/pic.png' alt='Graph' /> </p> "));
44
        $this->assertEquals('Frog', $mc->make_html_inline('<p>Frog</p><p></p>'));
45
        $this->assertEquals('Frog', $mc->make_html_inline('<p>Frog</p><p></p>'));
45
        $this->assertEquals('Frog<br />†', $mc->make_html_inline('<p>Frog</p><p>†</p>'));
46
        $this->assertEquals('Frog<br />†', $mc->make_html_inline('<p>Frog</p><p>†</p>'));
46
    }
47
    }
-
 
48
 
-
 
49
    public function test_check_file_access_hints(): void {
-
 
50
        // Prepare a shortanswer question with a hint plus default display options.
-
 
51
        $question = \test_question_maker::make_question('shortanswer', 'frogtoad');
-
 
52
        $question->id = 42;
-
 
53
        $question->hints[] = new \question_hint_with_parts(12, 'foo', FORMAT_HTML, false, false);
-
 
54
        $options = new \question_display_options();
-
 
55
 
-
 
56
        // Prepare and start an interactive question attempt.
-
 
57
        $quba = new \question_usage_by_activity('qtype_shortanswer', \context_system::instance());
-
 
58
        $qa = new \question_attempt($question, $quba->get_id());
-
 
59
        $qa->start('interactive', 1);
-
 
60
 
-
 
61
        // No answer has been submitted, so we should not have access to files from the 'hint' area.
-
 
62
        $args = [$question->hints[0]->id, 'foo.jpg'];
-
 
63
        $checkresult = $question->check_file_access($qa, $options, 'question', 'hint', $args, false);
-
 
64
        $this->assertFalse($checkresult);
-
 
65
    }
47
}
66
}