ILIAS  release_8 Revision v8.24
ilTestEvaluationPassDataTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26{
28
29 protected function setUp(): void
30 {
31 parent::setUp();
32
33 $this->testObj = new ilTestEvaluationPassData();
34 }
35
37 {
38 $this->assertInstanceOf(ilTestEvaluationPassData::class, $this->testObj);
39 }
40
41 public function test__sleep(): void
42 {
43 $expected = [
44 "answeredQuestions",
45 "pass",
46 "nrOfAnsweredQuestions",
47 "reachedpoints",
48 "maxpoints",
49 "questioncount",
50 "workingtime",
51 "examId"
52 ];
53 $this->assertEquals($expected, $this->testObj->__sleep());
54 }
55
56 public function testNrOfAnsweredQuestions(): void
57 {
58 $this->testObj->setNrOfAnsweredQuestions(20);
59 $this->assertEquals(20, $this->testObj->getNrOfAnsweredQuestions());
60 }
61
62 public function testReachedPoints(): void
63 {
64 $this->testObj->setReachedPoints(20);
65 $this->assertEquals(20, $this->testObj->getReachedPoints());
66 }
67
68 public function testMaxPoints(): void
69 {
70 $this->testObj->setMaxPoints(20);
71 $this->assertEquals(20, $this->testObj->getMaxPoints());
72 }
73
74 public function testQuestionCount(): void
75 {
76 $this->testObj->setQuestionCount(20);
77 $this->assertEquals(20, $this->testObj->getQuestionCount());
78 }
79
80 public function testWorkingTime(): void
81 {
82 $this->testObj->setWorkingTime(20);
83 $this->assertEquals(20, $this->testObj->getWorkingTime());
84 }
85
86 public function testPass(): void
87 {
88 $this->testObj->setPass(20);
89 $this->assertEquals(20, $this->testObj->getPass());
90 }
91
92 public function testAnsweredQuestions(): void
93 {
94 $expected = [
95 ["id" => 20, "points" => 2.5, "reached" => 1.5, "isAnswered" => true, "sequence" => null, "manual" => 0],
96 ["id" => 12, "points" => 12.5, "reached" => 11, "isAnswered" => true, "sequence" => null, "manual" => 1],
97 ["id" => 165, "points" => -5.5, "reached" => 0, "isAnswered" => false, "sequence" => null, "manual" => 0],
98 ["id" => 4, "points" => 55.5, "reached" => 200, "isAnswered" => false, "sequence" => null, "manual" => 1],
99 ];
100
101 foreach ($expected as $value) {
102 $this->testObj->addAnsweredQuestion(
103 $value["id"],
104 $value["points"],
105 $value["reached"],
106 $value["isAnswered"],
107 $value["sequence"],
108 $value["manual"],
109 );
110 }
111
112 $this->assertEquals($expected, $this->testObj->getAnsweredQuestions());
113
114 $this->assertEquals($expected[1], $this->testObj->getAnsweredQuestion(1));
115 }
116
118 {
119 $expected = [
120 ["id" => 20, "points" => 2.5, "reached" => 1.5, "isAnswered" => true, "sequence" => null, "manual" => 0],
121 ["id" => 12, "points" => 12.5, "reached" => 11, "isAnswered" => true, "sequence" => null, "manual" => 1],
122 ["id" => 165, "points" => -5.5, "reached" => 0, "isAnswered" => false, "sequence" => null, "manual" => 0],
123 ["id" => 4, "points" => 55.5, "reached" => 200, "isAnswered" => false, "sequence" => null, "manual" => 1],
124 ];
125
126 foreach ($expected as $value) {
127 $this->testObj->addAnsweredQuestion(
128 $value["id"],
129 $value["points"],
130 $value["reached"],
131 $value["isAnswered"],
132 $value["sequence"],
133 $value["manual"],
134 );
135 }
136
137 $this->assertEquals($expected[1], $this->testObj->getAnsweredQuestionByQuestionId(12));
138 }
139
140 public function testGetAnsweredQuestionCount(): void
141 {
142 $expected = [
143 ["id" => 20, "points" => 2.5, "reached" => 1.5, "isAnswered" => true, "sequence" => null, "manual" => 0],
144 ["id" => 12, "points" => 12.5, "reached" => 11, "isAnswered" => true, "sequence" => null, "manual" => 1],
145 ["id" => 165, "points" => -5.5, "reached" => 0, "isAnswered" => false, "sequence" => null, "manual" => 0],
146 ["id" => 4, "points" => 55.5, "reached" => 200, "isAnswered" => false, "sequence" => null, "manual" => 1],
147 ];
148
149 foreach ($expected as $value) {
150 $this->testObj->addAnsweredQuestion(
151 $value["id"],
152 $value["points"],
153 $value["reached"],
154 $value["isAnswered"],
155 $value["sequence"],
156 $value["manual"],
157 );
158 }
159
160 $this->assertEquals(4, $this->testObj->getAnsweredQuestionCount());
161 }
162
163 public function testRequestedHintsCount(): void
164 {
165 $this->testObj->setRequestedHintsCount(5);
166
167 $this->assertEquals(5, $this->testObj->getRequestedHintsCount());
168 }
169
170 public function testDeductedHintPoints(): void
171 {
172 $this->testObj->setDeductedHintPoints(5);
173
174 $this->assertEquals(5, $this->testObj->getDeductedHintPoints());
175 }
176
177 public function testObligationsAnswered(): void
178 {
179 $this->testObj->setObligationsAnswered(true);
180
181 $this->assertTrue($this->testObj->areObligationsAnswered());
182 }
183
184 public function testExamId(): void
185 {
186 $this->testObj->setExamId("5");
187
188 $this->assertEquals("5", $this->testObj->getExamId());
189 }
190}
Class ilTestBaseClass.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...