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