Línea 36... |
Línea 36... |
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
37 |
*
|
37 |
*
|
38 |
* @covers \question_type
|
38 |
* @covers \question_type
|
39 |
* @covers \qtype_calculated
|
39 |
* @covers \qtype_calculated
|
40 |
*/
|
40 |
*/
|
41 |
class question_type_test extends \advanced_testcase {
|
41 |
final class question_type_test extends \advanced_testcase {
|
42 |
protected $tolerance = 0.00000001;
|
42 |
protected $tolerance = 0.00000001;
|
43 |
protected $qtype;
|
43 |
protected $qtype;
|
Línea 44... |
Línea 44... |
44 |
|
44 |
|
- |
|
45 |
protected function setUp(): void {
|
45 |
protected function setUp(): void {
|
46 |
parent::setUp();
|
46 |
$this->qtype = new qtype_calculated();
|
47 |
$this->qtype = new qtype_calculated();
|
Línea 47... |
Línea 48... |
47 |
}
|
48 |
}
|
48 |
|
49 |
|
- |
|
50 |
protected function tearDown(): void {
|
49 |
protected function tearDown(): void {
|
51 |
$this->qtype = null;
|
Línea 50... |
Línea 52... |
50 |
$this->qtype = null;
|
52 |
parent::tearDown();
|
51 |
}
|
53 |
}
|
52 |
|
54 |
|
Línea 101... |
Línea 103... |
101 |
$this->assertEquals(1, $questiondata->length);
|
103 |
$this->assertEquals(1, $questiondata->length);
|
102 |
$this->assertEquals(\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, $questiondata->status);
|
104 |
$this->assertEquals(\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, $questiondata->status);
|
103 |
$this->assertEquals($question->createdby, $questiondata->createdby);
|
105 |
$this->assertEquals($question->createdby, $questiondata->createdby);
|
104 |
$this->assertEquals($question->createdby, $questiondata->modifiedby);
|
106 |
$this->assertEquals($question->createdby, $questiondata->modifiedby);
|
105 |
$this->assertEquals('', $questiondata->idnumber);
|
107 |
$this->assertEquals('', $questiondata->idnumber);
|
106 |
$this->assertEquals($syscontext->id, $questiondata->contextid);
|
108 |
$this->assertEquals($category->contextid, $questiondata->contextid);
|
107 |
$this->assertEquals([], $questiondata->hints);
|
109 |
$this->assertCount(1, $questiondata->hints);
|
- |
|
110 |
$hint = array_pop($questiondata->hints);
|
- |
|
111 |
$this->assertEquals('Add', $hint->hint);
|
- |
|
112 |
$this->assertEquals(FORMAT_HTML, $hint->hintformat);
|
Línea 108... |
Línea 113... |
108 |
|
113 |
|
109 |
// Options.
|
114 |
// Options.
|
110 |
$this->assertEquals($questiondata->id, $questiondata->options->question);
|
115 |
$this->assertEquals($questiondata->id, $questiondata->options->question);
|
- |
|
116 |
$this->assertCount(1, $questiondata->options->units);
|
- |
|
117 |
$unit = array_pop($questiondata->options->units);
|
- |
|
118 |
$this->assertEquals($unit->unit, 'x');
|
111 |
$this->assertEquals([], $questiondata->options->units);
|
119 |
$this->assertEquals($unit->multiplier, '1.0');
|
112 |
$this->assertEquals(qtype_numerical::UNITNONE, $questiondata->options->showunits);
|
120 |
$this->assertEquals(qtype_numerical::UNITOPTIONAL, $questiondata->options->showunits);
|
113 |
$this->assertEquals(0, $questiondata->options->unitgradingtype); // Unit role is none, so this is 0.
|
121 |
$this->assertEquals(0, $questiondata->options->unitgradingtype); // Unit role is none, so this is 0.
|
114 |
$this->assertEquals($fromform->unitpenalty, $questiondata->options->unitpenalty);
|
122 |
$this->assertEquals($fromform->unitpenalty, $questiondata->options->unitpenalty);
|
Línea 115... |
Línea 123... |
115 |
$this->assertEquals($fromform->unitsleft, $questiondata->options->unitsleft);
|
123 |
$this->assertEquals($fromform->unitsleft, $questiondata->options->unitsleft);
|