1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace qtype_essay;
|
|
|
18 |
|
|
|
19 |
use qtype_essay;
|
|
|
20 |
|
|
|
21 |
defined('MOODLE_INTERNAL') || die();
|
|
|
22 |
|
|
|
23 |
global $CFG;
|
|
|
24 |
require_once($CFG->dirroot . '/question/type/essay/questiontype.php');
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Unit tests for the essay question type class.
|
|
|
29 |
*
|
|
|
30 |
* @package qtype_essay
|
|
|
31 |
* @copyright 2010 The Open University
|
|
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
33 |
*/
|
1441 |
ariadna |
34 |
final class question_type_test extends \advanced_testcase {
|
1 |
efrain |
35 |
protected $qtype;
|
|
|
36 |
|
|
|
37 |
protected function setUp(): void {
|
1441 |
ariadna |
38 |
parent::setUp();
|
1 |
efrain |
39 |
$this->qtype = new qtype_essay();
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
protected function tearDown(): void {
|
|
|
43 |
$this->qtype = null;
|
1441 |
ariadna |
44 |
parent::tearDown();
|
1 |
efrain |
45 |
}
|
|
|
46 |
|
|
|
47 |
protected function get_test_question_data() {
|
|
|
48 |
$q = new \stdClass();
|
|
|
49 |
$q->id = 1;
|
|
|
50 |
|
|
|
51 |
return $q;
|
|
|
52 |
}
|
|
|
53 |
|
11 |
efrain |
54 |
public function test_name(): void {
|
1 |
efrain |
55 |
$this->assertEquals($this->qtype->name(), 'essay');
|
|
|
56 |
}
|
|
|
57 |
|
11 |
efrain |
58 |
public function test_can_analyse_responses(): void {
|
1 |
efrain |
59 |
$this->assertFalse($this->qtype->can_analyse_responses());
|
|
|
60 |
}
|
|
|
61 |
|
11 |
efrain |
62 |
public function test_get_random_guess_score(): void {
|
1 |
efrain |
63 |
$q = $this->get_test_question_data();
|
|
|
64 |
$this->assertEquals(0, $this->qtype->get_random_guess_score($q));
|
|
|
65 |
}
|
|
|
66 |
|
11 |
efrain |
67 |
public function test_get_possible_responses(): void {
|
1 |
efrain |
68 |
$q = $this->get_test_question_data();
|
|
|
69 |
$this->assertEquals(array(), $this->qtype->get_possible_responses($q));
|
|
|
70 |
|
|
|
71 |
}
|
|
|
72 |
}
|