ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilStudyProgrammeUserProgressTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once(__DIR__."/mocks.php");
6
15 protected $backupGlobals = FALSE;
16
17 protected function setUp() {
18 PHPUnit_Framework_Error_Deprecated::$enabled = FALSE;
19
20 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
21
22 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
23 ilUnitUtil::performInitialisation();
24
26 $this->root->putInTree(ROOT_FOLDER_ID);
27 $this->root->object_factory = new ilObjectFactoryWrapperMock();
28
31
32 $this->leaf1 = new ilStudyProgrammeLeafMock();
33 $this->leaf2 = new ilStudyProgrammeLeafMock();
34
35 $this->root->addNode($this->node1);
36 $this->root->addNode($this->node2);
37 $this->node1->addLeaf($this->leaf1);
38 $this->node2->addLeaf($this->leaf2);
39
40 global $tree;
41 $this->tree = $tree;
42
43 global $ilUser;
44 $this->user = $ilUser;
45 }
46
47 protected function tearDown() {
48 if ($this->root) {
49 $this->root->delete();
50 }
51 }
52
53 protected function newUser() {
54 $user = new ilObjUser();
55 $user->create();
56 return $user;
57 }
58
59 protected function setAllNodesActive() {
60 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
61 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
62 $this->node2->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
63 }
64
65 protected function assignNewUserToRoot() {
66 $user = $this->newUser();
67 return array($this->root->assignUser($user->getId()), $user);
68 }
69
70 public function testInitialProgressActive() {
71 $this->setAllNodesActive();
72 $tmp = $this->assignNewUserToRoot();
73 $ass = $tmp[0];
74 $user = $tmp[1];
75
76 $root_progresses = $this->root->getProgressesOf($user->getId());
77 $this->assertCount(1, $root_progresses);
78 $root_progress = $root_progresses[0];
80 , $root_progress->getStatus());
81 $this->assertEquals( $this->root->getPoints()
82 , $root_progress->getAmountOfPoints());
83 $this->assertEquals(0, $root_progress->getCurrentAmountOfPoints());
84 $this->assertEquals($this->root->getId(), $root_progress->getStudyProgramme()->getId());
85 $this->assertEquals($ass->getId(), $root_progress->getAssignment()->getId());
86 $this->assertEquals($user->getId(), $root_progress->getUserId());
87 $this->assertNull($root_progress->getLastChangeBy());
88 $this->assertNull($root_progress->getCompletionBy());
89
90 $node1_progresses = $this->node1->getProgressesOf($user->getId());
91 $this->assertCount(1, $node1_progresses);
92 $node1_progress = $node1_progresses[0];
94 , $node1_progress->getStatus());
95 $this->assertEquals( $this->node1->getPoints()
96 , $node1_progress->getAmountOfPoints());
97 $this->assertEquals(0, $node1_progress->getCurrentAmountOfPoints());
98 $this->assertEquals($this->node1->getId(), $node1_progress->getStudyProgramme()->getId());
99 $this->assertEquals($ass->getId(), $node1_progress->getAssignment()->getId());
100 $this->assertEquals($user->getId(), $node1_progress->getUserId());
101 $this->assertNull($node1_progress->getLastChangeBy());
102 $this->assertNull($node1_progress->getCompletionBy());
103
104 $node2_progresses = $this->node2->getProgressesOf($user->getId());
105 $this->assertCount(1, $node2_progresses);
106 $node2_progress = $node2_progresses[0];
108 , $node2_progress->getStatus());
109 $this->assertEquals( $this->node2->getPoints()
110 , $node2_progress->getAmountOfPoints());
111 $this->assertEquals(0, $node2_progress->getCurrentAmountOfPoints());
112 $this->assertEquals($this->node2->getId(), $node2_progress->getStudyProgramme()->getId());
113 $this->assertEquals($ass->getId(), $node2_progress->getAssignment()->getId());
114 $this->assertEquals($user->getId(), $node2_progress->getUserId());
115 $this->assertNull($node2_progress->getLastChangeBy());
116 $this->assertNull($node2_progress->getCompletionBy());
117 }
118
119 public function testInitialProgressDraft() {
120 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
121 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
122 $this->node2->setStatus(ilStudyProgramme::STATUS_DRAFT)->update();
123
124 $tmp = $this->assignNewUserToRoot();
125 $user = $tmp[1];
126 $ass = $tmp[0];
127
128 $root_progresses = $this->root->getProgressesOf($user->getId());
129 $root_progress = $root_progresses[0];
131 , $root_progress->getStatus());
132
133 $node1_progresses = $this->node1->getProgressesOf($user->getId());
134 $node1_progress = $node1_progresses[0];
136 , $node1_progress->getStatus());
137
138 $node2_progresses = $this->node2->getProgressesOf($user->getId());
139 $node2_progress = $node2_progresses[0];
141 , $node2_progress->getStatus());
142 }
143
144 public function testInitialProgressOutdated() {
145 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
146 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
147 $this->node2->setStatus(ilStudyProgramme::STATUS_OUTDATED)->update();
148
149 $tmp = $this->assignNewUserToRoot();
150 $user = $tmp[1];
151 $ass = $tmp[0];
152
153 $root_progresses = $this->root->getProgressesOf($user->getId());
154 $root_progress = $root_progresses[0];
156 , $root_progress->getStatus());
157
158 $node1_progresses = $this->node1->getProgressesOf($user->getId());
159 $node1_progress = $node1_progresses[0];
161 , $node1_progress->getStatus());
162
163 $node2_progresses = $this->node2->getProgressesOf($user->getId());
164 $node2_progress = $node2_progresses[0];
166 , $node2_progress->getStatus());
167 }
168
169 public function testUserSelection() {
170 $this->setAllNodesActive();
171 $this->assignNewUserToRoot();
172 $tmp = $this->assignNewUserToRoot();
173 $ass = $tmp[0];
174 $user = $tmp[1];
175
176 $root_progresses = $this->root->getProgressesOf($user->getId());
177 $this->assertCount(1, $root_progresses);
178 }
179
180 public function testMarkAccredited() {
181 $this->setAllNodesActive();
182 $tmp = $this->assignNewUserToRoot();
183 $ass = $tmp[0];
184 $user = $tmp[1];
185
186 $user2 = $this->newUser();
187 $USER_ID = $user2->getId();
188
189 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
190 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
191
192 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
193 $this->assertEquals($root_progress->getAmountOfPoints(), ilStudyProgramme::DEFAULT_POINTS);
194 $this->assertEquals($node1_progress->getAmountOfPoints(), ilStudyProgramme::DEFAULT_POINTS);
195 $this->assertEquals($node2_progress->getAmountOfPoints(), ilStudyProgramme::DEFAULT_POINTS);
196
197 $ts_before_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
198 $node2_progress->markAccredited($USER_ID);
199 $ts_after_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
200
201 $this->assertTrue($node2_progress->isSuccessful());
202 $this->assertEquals($root_progress->getAmountOfPoints(), $root_progress->getCurrentAmountOfPoints());
203
204 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $root_progress->getStatus());
205 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
206 $this->assertEquals(ilStudyProgrammeProgress::STATUS_ACCREDITED, $node2_progress->getStatus());
207
208 $this->assertEquals($USER_ID, $node2_progress->getCompletionBy());
209 $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
210 }
211
212 public function testUnmarkAccredited() {
213 $this->setAllNodesActive();
214 $tmp = $this->assignNewUserToRoot();
215 $ass = $tmp[0];
216 $user = $tmp[1];
217
218 $user2 = $this->newUser();
219 $USER_ID = $user2->getId();
220
221 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
222 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
223 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
224
225 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
226 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
227 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node2_progress->getStatus());
228
229 $ts_before_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
230 $node2_progress->markAccredited($USER_ID);
231 $node2_progress->unmarkAccredited();
232 $ts_after_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
233
234 // The root node will still be completed, as we do not go back from completed to some other
235 // status.
236 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
237 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
238 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node2_progress->getStatus());
239 $this->assertEquals(NULL, $node2_progress->getCompletionBy());
240 $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
241 }
242
243
244 public function testMarkNotRelevant() {
245 $this->setAllNodesActive();
246 $tmp = $this->assignNewUserToRoot();
247 $ass = $tmp[0];
248 $user = $tmp[1];
249
250 $user2 = $this->newUser();
251 $USER_ID = $user2->getId();
252
253 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
254 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
255 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
256 $ts_before_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
257 $node2_progress->markNotRelevant($USER_ID);
258 $ts_after_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
259 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
260 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
261 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $node2_progress->getStatus());
262 $this->assertEquals($USER_ID, $node2_progress->getCompletionBy());
263 $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
264 $this->assertTrue($node2_progress->hasIndividualModifications());
265 }
266
267 // Neues Moduls: Wird dem Studierenden-Studierenden inkl. Kurse, Punkte als "Nicht relevant" hinzugefügt.
268 public function testNewNodesAreNotRelevant() {
269 $this->setAllNodesActive();
270 $tmp = $this->assignNewUserToRoot();
271 $ass = $tmp[0];
272 $user = $tmp[1];
273
275 $this->root->addNode($node3);
276
277 $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
278 $this->assertNotNull($node3_progress);
279 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $node3_progress->getStatus());
280 }
281
283 $this->setAllNodesActive();
284 $tmp = $this->assignNewUserToRoot();
285 $ass1 = $tmp[0];
286 $user1 = $tmp[1];
287
288
289 $NEW_AMOUNT_OF_POINTS_1 = 205;
290 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, ilStudyProgramme::DEFAULT_POINTS);
291
292 $node2_progress1 = array_shift($this->node2->getProgressesOf($user1->getId()));
293 $node2_progress1->setRequiredAmountOfPoints($NEW_AMOUNT_OF_POINTS_1, $this->user->getId());
294
295 $this->assertEquals($NEW_AMOUNT_OF_POINTS_1, $node2_progress1->getAmountOfPoints());
296 }
297
299 $this->setAllNodesActive();
300 $tmp = $this->assignNewUserToRoot();
301 $ass = $tmp[0];
302 $user = $tmp[1];
303
304 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
305 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
306 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
307
308 $this->assertEquals(2 * ilStudyProgramme::DEFAULT_POINTS, $root_progress->getMaximumPossibleAmountOfPoints());
309 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node1_progress->getMaximumPossibleAmountOfPoints());
310 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node2_progress->getMaximumPossibleAmountOfPoints());
311 }
312
314 $this->setAllNodesActive();
315 $tmp = $this->assignNewUserToRoot();
316 $ass = $tmp[0];
317 $user = $tmp[1];
318
319 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
320 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
321 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
322
323 $this->assertEquals(2 * ilStudyProgramme::DEFAULT_POINTS, $root_progress->getMaximumPossibleAmountOfPoints());
324 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node1_progress->getMaximumPossibleAmountOfPoints());
325 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node2_progress->getMaximumPossibleAmountOfPoints());
326 }
327
328 public function testCanBeCompleted1() {
329 $this->setAllNodesActive();
330 $tmp = $this->assignNewUserToRoot();
331 $ass = $tmp[0];
332 $user = $tmp[1];
333
334 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
335 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
336 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
337
338 $this->assertTrue($root_progress->canBeCompleted());
339 $this->assertTrue($node1_progress->canBeCompleted());
340 $this->assertTrue($node2_progress->canBeCompleted());
341 }
342
343 public function testCanBeCompleted2() {
344 $NEW_AMOUNT_OF_POINTS = 3003;
345 $this->assertGreaterThan(ilStudyProgramme::DEFAULT_POINTS, $NEW_AMOUNT_OF_POINTS);
346
347 $this->setAllNodesActive();
348 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
349 ->update();
350 $tmp = $this->assignNewUserToRoot();
351 $ass = $tmp[0];
352 $user = $tmp[1];
353
354 $this->assertLessThan($NEW_AMOUNT_OF_POINTS, $this->node1->getPoints() + $this->node2->getPoints());
355
356 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
357 $this->assertFalse($root_progress->canBeCompleted());
358 }
359
360 public function testCanBeCompleted3() {
361 $NEW_AMOUNT_OF_POINTS = 3003;
362 $this->assertGreaterThan(ilStudyProgramme::DEFAULT_POINTS, $NEW_AMOUNT_OF_POINTS);
363
364 $this->setAllNodesActive();
366 $this->root->addNode($node3);
367 $node3->setPoints($NEW_AMOUNT_OF_POINTS)
369 ->update();
370
371
372 $tmp = $this->assignNewUserToRoot();
373 $ass = $tmp[0];
374 $user = $tmp[1];
375
376 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
377 $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
378
379 $this->assertFalse($root_progress->canBeCompleted());
380 $this->assertFalse($node3_progress->canBeCompleted());
381 }
382
384 $this->setAllNodesActive();
385 $tmp = $this->assignNewUserToRoot();
386 $ass = $tmp[0];
387 $user = $tmp[1];
388
389 $user->delete();
390
391 $root_progresses = $this->root->getProgressesOf($user->getId());
392 $this->assertCount(0, $root_progresses);
393 $node1_progresses = $this->root->getProgressesOf($user->getId());
394 $this->assertCount(0, $node1_progresses);
395 $node2_progresses = $this->root->getProgressesOf($user->getId());
396 $this->assertCount(0, $node2_progresses);
397 }
398
399 // - Änderungen von Punkten bei bestehenden qua-Objekten werden nicht direkt übernommen
400 public function testNoImplicitPointUpdate() {
401 $this->setAllNodesActive();
402 $tmp = $this->assignNewUserToRoot();
403 $ass = $tmp[0];
404 $user = $tmp[1];
405
406 $NEW_AMOUNT_OF_POINTS = 201;
407 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS, ilStudyProgramme::DEFAULT_POINTS);
408
409 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
410 ->update();
411
412 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
413 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $root_progress->getAmountOfPoints());
414 }
415
416 // Änderungen von Punkten bei bestehenden qua-Objekten werden nicht direkt übernommen,
417 // sondern dann bei bewusster Aktualisierung.
418 public function testExplicitPointUpdate1() {
419 $this->setAllNodesActive();
420 $tmp = $this->assignNewUserToRoot();
421 $ass = $tmp[0];
422 $user = $tmp[1];
423
424 $NEW_AMOUNT_OF_POINTS = 202;
425 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS, ilStudyProgramme::DEFAULT_POINTS);
426
427 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
428 ->update();
429
430 $ass->updateFromProgram();
431 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
432 $this->assertEquals($NEW_AMOUNT_OF_POINTS, $root_progress->getAmountOfPoints());
433 }
434
435 // Änderungen von Punkten bei bestehenden qua-Objekten werden nicht direkt übernommen,
436 // sondern dann bei bewusster Aktualisierung.
437 // Similar to testExplicitPointUpdate1, but order of calls differs.
438 public function testExplicitPointUpdate2() {
439 $this->setAllNodesActive();
440 $tmp = $this->assignNewUserToRoot();
441 $ass = $tmp[0];
442 $user = $tmp[1];
443
444 $NEW_AMOUNT_OF_POINTS = 203;
445 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS, ilStudyProgramme::DEFAULT_POINTS);
446
447 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
448 ->update();
449
450 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
451 $ass->updateFromProgram();
452 $this->assertEquals($NEW_AMOUNT_OF_POINTS, $root_progress->getAmountOfPoints());
453 }
454
455 // Änderungen von Punkten bei bestehenden qua-Objekten werden nicht direkt übernommen,
456 // sondern dann bei bewusster Aktualisierung (sofern nicht ein darüberliegenden
457 // Knotenpunkt manuell angepasst worden ist)
458 public function testNoUpdateOnModifiedNodes() {
459 $this->setAllNodesActive();
460 $tmp = $this->assignNewUserToRoot();
461 $ass1 = $tmp[0];
462 $user1 = $tmp[1];
463
464 $tmp = $this->assignNewUserToRoot();
465 $ass2 = $tmp[0];
466 $user2 = $tmp[1];
467
468 $NEW_AMOUNT_OF_POINTS_1 = 205;
469 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, ilStudyProgramme::DEFAULT_POINTS);
470 $NEW_AMOUNT_OF_POINTS_2 = 206;
471 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_2, ilStudyProgramme::DEFAULT_POINTS);
472 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, $NEW_AMOUNT_OF_POINTS_2);
473
474 $node2_progress1 = array_shift($this->node2->getProgressesOf($user1->getId()));
475 $node2_progress2 = array_shift($this->node2->getProgressesOf($user2->getId()));
476
477 $node2_progress1->setRequiredAmountOfPoints($NEW_AMOUNT_OF_POINTS_1, $this->user->getId());
478
479 $this->node2->setPoints($NEW_AMOUNT_OF_POINTS_2)
480 ->update();
481 $this->root->updateAllAssignments();
482
483 $this->assertEquals($NEW_AMOUNT_OF_POINTS_1, $node2_progress1->getAmountOfPoints());
484 $this->assertEquals($NEW_AMOUNT_OF_POINTS_2, $node2_progress2->getAmountOfPoints());
485 }
486
494 $this->setAllNodesActive();
495 $this->node1->setStatus(ilStudyProgramme::STATUS_OUTDATED);
496 $tmp = $this->assignNewUserToRoot();
497 $ass1 = $tmp[0];
498 $user1 = $tmp[1];
499
500 $progress = $this->node1->getProgressForAssignment($ass1->getId());
502 , $progress->getStatus());
503 $progress->markAccredited($this->user->getId());
504 }
505
506 // Hinweis bei der bei der Studierenden-Instanz des Studienplanes, falls dieser vom
507 // Original-Studienplan abweicht.
508 public function testHasDeviationToProgram1() {
509 $this->setAllNodesActive();
510 $tmp = $this->assignNewUserToRoot();
511 $ass1 = $tmp[0];
512 $user1 = $tmp[1];
513
514 $progress = $this->node1->getProgressForAssignment($ass1->getId());
515 $this->assertFalse($progress->hasIndividualModifications());
516 }
517
518 public function testHasDeviationToProgram2() {
519 $this->setAllNodesActive();
520 $tmp = $this->assignNewUserToRoot();
521 $ass1 = $tmp[0];
522 $user1 = $tmp[1];
523
524 $progress = $this->node1->getProgressForAssignment($ass1->getId());
525 $progress->setRequiredAmountOfPoints(1000, $this->user->getId());
526 $this->assertTrue($progress->hasIndividualModifications());
527 }
528
529 public function testHasDeviationToProgram3() {
530 $this->setAllNodesActive();
531 $tmp = $this->assignNewUserToRoot();
532 $ass1 = $tmp[0];
533 $user1 = $tmp[1];
534
535 $progress = $this->node1->getProgressForAssignment($ass1->getId());
536 $progress->markNotRelevant($this->user->getId());
537 $this->assertTrue($progress->hasIndividualModifications());
538 }
539
540 public function testHasDeviationToProgram4() {
541 $this->setAllNodesActive();
542 $tmp = $this->assignNewUserToRoot();
543 $ass1 = $tmp[0];
544 $user1 = $tmp[1];
545
546 $progress = $this->node1->getProgressForAssignment($ass1->getId());
547 $progress->markAccredited($this->user->getId());
548 $this->assertFalse($progress->hasIndividualModifications());
549 }
550
552 $this->setAllNodesActive();
553 $tmp = $this->assignNewUserToRoot();
554 $ass = $tmp[0];
555 $user = $tmp[1];
556
557 $user2 = $this->newUser();
558 $USER_ID = $user2->getId();
559
560 $this->node1->setTitle("node1");
561 $this->node1->update();
562 $this->node2->setTitle("node2");
563 $this->node2->update();
564
565 $names = $this->root->getProgressForAssignment($ass->getId())
566 ->getNamesOfCompletedOrAccreditedChildren();
567 $this->assertEquals($names, array());
568
569 $this->node1->getProgressForAssignment($ass->getId())->markAccredited($USER_ID);
570 $names = $this->root->getProgressForAssignment($ass->getId())
571 ->getNamesOfCompletedOrAccreditedChildren();
572 $this->assertEquals($names, array("node1"));
573
574 $this->node2->getProgressForAssignment($ass->getId())->markAccredited($USER_ID);
575 $names = $this->root->getProgressForAssignment($ass->getId())
576 ->getNamesOfCompletedOrAccreditedChildren();
577 $this->assertEquals($names, array("node1", "node2"));
578 }
579
585 $depth1->putInTree(ROOT_FOLDER_ID);
586 $depth1->addNode($depth2);
587 $depth2->addNode($depth3);
588 $depth3->addNode($depth4);
589 $depth1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
590 $depth2->setStatus(ilStudyProgramme::STATUS_ACTIVE);
591 $depth3->setStatus(ilStudyProgramme::STATUS_ACTIVE);
592 $depth4->setStatus(ilStudyProgramme::STATUS_ACTIVE);
593
594 $user = $this->newUser();
595
596 $assignment = $depth1->assignUser($user->getId());
597 $progress4 = $depth4->getProgressForAssignment($assignment->getId());
598 $progress4->markAccredited(6);
599
600 $progress1 = $depth1->getProgressForAssignment($assignment->getId());
601 $progress2 = $depth2->getProgressForAssignment($assignment->getId());
602 $progress3 = $depth3->getProgressForAssignment($assignment->getId());
603
604 $this->assertTrue($progress1->isSuccessful());
605 $this->assertTrue($progress2->isSuccessful());
606 $this->assertTrue($progress3->isSuccessful());
607 $this->assertTrue($progress4->isSuccessful());
608
609 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress1->getCurrentAmountOfPoints());
610 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress2->getCurrentAmountOfPoints());
611 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress3->getCurrentAmountOfPoints());
612 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress4->getCurrentAmountOfPoints());
613 }
614}
const IL_CAL_DATETIME
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:66
Mock classes for tests.
Definition: mocks.php:21
TestCase for the progress of users at a programme.
testOutdatedNodesCantBeSetToRelevant()
QUA-Objekte, welche "Inaktiv" sind können bei Studierenden-Studienplänen nicht von "nicht relevant" a...
global $ilUser
Definition: imgupload.php:15