ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestResultHeaderLabelBuilder.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
12{
13 const LO_TEST_TYPE_INITIAL = 'loTestInitial';
14 const LO_TEST_TYPE_QUALIFYING = 'loTestQualifying';
18 protected $lng;
19
23 protected $objCache;
24
29
33 protected $testObjId;
34
38 protected $testRefId;
39
43 protected $userId;
44
48 protected $crsTitle;
49
53 protected $testType;
54
58 protected $objectives;
59
65 {
66 $this->lng = $lng;
67 $this->objCache = $objCache;
68
69 $this->objectiveOrientedContainerId = null;
70 $this->testObjId = null;
71 $this->testRefId = null;
72 $this->userId = null;
73
74 $this->testType = null;
75 $this->crsTitle = null;
76
77 $this->objectives = array();
78 }
79
84 {
86 }
87
92 {
93 $this->objectiveOrientedContainerId = $objectiveOrientedContainerId;
94 }
95
99 public function getTestObjId()
100 {
101 return $this->testObjId;
102 }
103
107 public function setTestObjId($testObjId)
108 {
109 $this->testObjId = $testObjId;
110 }
111
115 public function getTestRefId()
116 {
117 return $this->testRefId;
118 }
119
123 public function setTestRefId($testRefId)
124 {
125 $this->testRefId = $testRefId;
126 }
127
131 public function getUserId()
132 {
133 return $this->userId;
134 }
135
139 public function setUserId($userId)
140 {
141 $this->userId = $userId;
142 }
143
145 {
146 $this->initTestType();
147 $this->initObjectives();
148 $this->initCourseTitle();
149 }
150
151 private function initTestType()
152 {
153 require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
155
156 if ($loSettings->getInitialTest() == $this->getTestRefId()) {
157 $this->testType = self::LO_TEST_TYPE_INITIAL;
158 } elseif ($loSettings->getQualifiedTest() == $this->getTestRefId()) {
159 $this->testType = self::LO_TEST_TYPE_QUALIFYING;
160 }
161 }
162
163 private function initObjectives()
164 {
165 require_once 'Modules/Course/classes/Objectives/class.ilLOTestRun.php';
166 $loRuns = ilLOTestRun::getRun($this->getObjectiveOrientedContainerId(), $this->getUserId(), $this->getTestObjId());
167
168 $this->objectives = array();
169
170 foreach ($loRuns as $loRun) {
171 /* @var ilLOTestRun $loRun */
172
173 $this->objectives[$loRun->getObjectiveId()] = $this->getObjectiveTitle($loRun);
174 }
175 }
176
177 private function initCourseTitle()
178 {
179 $this->crsTitle = $this->objCache->lookupTitle($this->getObjectiveOrientedContainerId());
180 }
181
186 {
187 if (!$this->getObjectiveOrientedContainerId()) {
188 return $this->lng->txt('tst_results_overview');
189 }
190
191 if ($this->isInitialTestForAllObjectives()) {
192 return sprintf(
193 $this->lng->txt('tst_pass_overview_header_lo_initial_all_objectives'),
194 $this->crsTitle
195 );
196 } elseif ($this->isInitialTestPerObjective()) {
197 return sprintf(
198 $this->lng->txt('tst_pass_overview_header_lo_initial_per_objective'),
199 $this->getObjectivesString(),
200 $this->crsTitle
201 );
202 } elseif ($this->isQualifyingTestForAllObjectives()) {
203 return sprintf(
204 $this->lng->txt('tst_pass_overview_header_lo_qualifying_all_objectives'),
205 $this->crsTitle
206 );
207 } elseif ($this->isQualifyingTestPerObjective()) {
208 return sprintf(
209 $this->lng->txt('tst_pass_overview_header_lo_qualifying_per_objective'),
210 $this->getObjectivesString(),
211 $this->crsTitle
212 );
213 }
214
215 return '';
216 }
217
221 public function getPassDetailsHeaderLabel($attemptNumber)
222 {
223 if (!$this->getObjectiveOrientedContainerId()) {
224 return sprintf(
225 $this->lng->txt('tst_pass_details_overview_table_title'),
226 $attemptNumber
227 );
228 }
229
230 if ($this->isInitialTest()) {
231 return sprintf(
232 $this->lng->txt('tst_pass_details_header_lo_initial'),
233 $this->getObjectivesString(),
234 $this->getAttemptLabel($attemptNumber)
235 );
236 } elseif ($this->isQualifyingTest()) {
237 return sprintf(
238 $this->lng->txt('tst_pass_details_header_lo_qualifying'),
239 $this->getObjectivesString(),
240 $this->getAttemptLabel($attemptNumber)
241 );
242 }
243
244 return '';
245 }
246
247 private function isInitialTest()
248 {
249 return $this->testType == self::LO_TEST_TYPE_INITIAL;
250 }
251
252 private function isQualifyingTest()
253 {
254 return $this->testType == self::LO_TEST_TYPE_QUALIFYING;
255 }
256
258 {
259 if ($this->testType != self::LO_TEST_TYPE_INITIAL) {
260 return false;
261 }
262
263 if (count($this->objectives) <= 1) {
264 return false;
265 }
266
267 return true;
268 }
269
270 private function isInitialTestPerObjective()
271 {
272 if ($this->testType != self::LO_TEST_TYPE_INITIAL) {
273 return false;
274 }
275
276 if (count($this->objectives) > 1) {
277 return false;
278 }
279
280 return true;
281 }
282
284 {
285 if ($this->testType != self::LO_TEST_TYPE_QUALIFYING) {
286 return false;
287 }
288
289 if (count($this->objectives) <= 1) {
290 return false;
291 }
292
293 return true;
294 }
295
297 {
298 if ($this->testType != self::LO_TEST_TYPE_QUALIFYING) {
299 return false;
300 }
301
302 if (count($this->objectives) > 1) {
303 return false;
304 }
305
306 return true;
307 }
308
309 private function getObjectiveTitle(ilLOTestRun $loRun)
310 {
311 require_once 'Modules/Course/classes/class.ilCourseObjective.php';
313 }
314
315 private function getObjectivesString()
316 {
317 return implode(', ', $this->objectives);
318 }
319
320 private function getAttemptLabel($attemptNumber)
321 {
322 return sprintf($this->lng->txt('tst_res_lo_try_n'), $attemptNumber);
323 }
324
325 public function getListOfAnswersHeaderLabel($attemptNumber)
326 {
327 $langVar = 'tst_eval_results_by_pass';
328
329 if ($this->getObjectiveOrientedContainerId()) {
330 $langVar = 'tst_eval_results_by_pass_lo';
331 }
332
333 return sprintf($this->lng->txt($langVar), $attemptNumber);
334 }
335
337 {
338 return $this->lng->txt('tst_eval_results_lo');
339 }
340
341 public function getVirtualPassDetailsHeaderLabel($objectiveTitle)
342 {
343 if ($this->isInitialTest()) {
344 return sprintf(
345 $this->lng->txt('tst_virtual_pass_header_lo_initial'),
346 $objectiveTitle
347 );
348 } elseif ($this->isQualifyingTest()) {
349 return sprintf(
350 $this->lng->txt('tst_virtual_pass_header_lo_qualifying'),
351 $objectiveTitle
352 );
353 }
354
355 return '';
356 }
357}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
static getInstanceByObjId($a_obj_id)
get singleton instance
Stores current objective, questions and max points.
static getRun($a_container_id, $a_user_id, $a_test_id)
language handling
class ilObjectDataCache
__construct(ilLanguage $lng, ilObjectDataCache $objCache)
setObjectiveOrientedContainerId($objectiveOrientedContainerId)