ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilStudyProgrammeUserProgressTest Class Reference

TestCase for the progress of users at a programme. More...

+ Inheritance diagram for ilStudyProgrammeUserProgressTest:
+ Collaboration diagram for ilStudyProgrammeUserProgressTest:

Public Member Functions

 testInitialProgressActive ()
 
 testInitialProgressDraft ()
 
 testInitialProgressOutdated ()
 
 testUserSelection ()
 
 testMarkAccredited ()
 
 testUnmarkAccredited ()
 
 testMarkFailed ()
 
 testMarkNotFailed ()
 
 testMarkNotRelevant ()
 
 testNewNodesAreNotRelevant ()
 
 testIndividualRequiredPoints ()
 
 testMaximimPossibleAmountOfPoints1 ()
 
 testMaximimPossibleAmountOfPoints2 ()
 
 testCanBeCompleted1 ()
 
 testCanBeCompleted2 ()
 
 testCanBeCompleted3 ()
 
 testUserDeletionDeletesAssignments ()
 
 testNoImplicitPointUpdate ()
 
 testExplicitPointUpdate1 ()
 
 testExplicitPointUpdate2 ()
 
 testNoUpdateOnModifiedNodes ()
 
 testOutdatedNodesCantBeSetToRelevant ()
 QUA-Objekte, welche "Inaktiv" sind können bei Studierenden-Studienplänen nicht von "nicht relevant" auf irgendeinen anderen Status gesetzt werden. More...
 
 testHasDeviationToProgram1 ()
 
 testHasDeviationToProgram2 ()
 
 testHasDeviationToProgram3 ()
 
 testHasDeviationToProgram4 ()
 
 testGetNamesOfCompletedOrAccreditedChildren ()
 
 testCompletionOnDeeplyNestedProgresses ()
 
 testPossibleActions ()
 
 testGetInstance ()
 
 testGetInstanceCalls ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 newUser ()
 
 setAllNodesActive ()
 
 assignNewUserToRoot ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

TestCase for the progress of users at a programme.

@group needsInstalledILIAS

Author
Michael Herren mh@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de
Version
1.0.0

Definition at line 15 of file ilStudyProgrammeUserProgressTest.php.

Member Function Documentation

◆ assignNewUserToRoot()

◆ newUser()

ilStudyProgrammeUserProgressTest::newUser ( )
protected

Definition at line 59 of file ilStudyProgrammeUserProgressTest.php.

60 {
61 $user = new ilObjUser();
62 $user->create();
63 return $user;
64 }

Referenced by assignNewUserToRoot(), testCompletionOnDeeplyNestedProgresses(), testGetNamesOfCompletedOrAccreditedChildren(), testMarkAccredited(), testMarkFailed(), testMarkNotFailed(), testMarkNotRelevant(), and testUnmarkAccredited().

+ Here is the caller graph for this function:

◆ setAllNodesActive()

◆ setUp()

ilStudyProgrammeUserProgressTest::setUp ( )
protected

Definition at line 19 of file ilStudyProgrammeUserProgressTest.php.

20 {
21 PHPUnit_Framework_Error_Deprecated::$enabled = false;
22
23 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
24
25 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
26 ilUnitUtil::performInitialisation();
27
29 $this->root->putInTree(ROOT_FOLDER_ID);
30 $this->root->object_factory = new ilObjectFactoryWrapperMock();
31
34
35 $this->leaf1 = new ilStudyProgrammeLeafMock();
36 $this->leaf2 = new ilStudyProgrammeLeafMock();
37
38 $this->root->addNode($this->node1);
39 $this->root->addNode($this->node2);
40 $this->node1->addLeaf($this->leaf1);
41 $this->node2->addLeaf($this->leaf2);
42
43 global $DIC;
44 $tree = $DIC['tree'];
45 $this->tree = $tree;
46
47 global $DIC;
48 $ilUser = $DIC['ilUser'];
49 $this->user = $ilUser;
50 }
user()
Definition: user.php:4
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:69
Mock classes for tests.
Definition: mocks.php:21
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18

References $DIC, $ilUser, ilObjStudyProgramme\createInstance(), and user().

+ Here is the call graph for this function:

◆ tearDown()

ilStudyProgrammeUserProgressTest::tearDown ( )
protected

Definition at line 52 of file ilStudyProgrammeUserProgressTest.php.

53 {
54 if ($this->root) {
55 $this->root->delete();
56 }
57 }

◆ testCanBeCompleted1()

ilStudyProgrammeUserProgressTest::testCanBeCompleted1 ( )

Definition at line 379 of file ilStudyProgrammeUserProgressTest.php.

380 {
381 $this->setAllNodesActive();
382 $tmp = $this->assignNewUserToRoot();
383 $ass = $tmp[0];
384 $user = $tmp[1];
385
386 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
387 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
388 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
389
390 $this->assertTrue($root_progress->canBeCompleted());
391 $this->assertTrue($node1_progress->canBeCompleted());
392 $this->assertTrue($node2_progress->canBeCompleted());
393 }

References assignNewUserToRoot(), and setAllNodesActive().

+ Here is the call graph for this function:

◆ testCanBeCompleted2()

ilStudyProgrammeUserProgressTest::testCanBeCompleted2 ( )

Definition at line 395 of file ilStudyProgrammeUserProgressTest.php.

396 {
397 $NEW_AMOUNT_OF_POINTS = 3003;
398 $this->assertGreaterThan(ilStudyProgramme::DEFAULT_POINTS, $NEW_AMOUNT_OF_POINTS);
399
400 $this->setAllNodesActive();
401 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
402 ->update();
403 $tmp = $this->assignNewUserToRoot();
404 $ass = $tmp[0];
405 $user = $tmp[1];
406
407 $this->assertLessThan($NEW_AMOUNT_OF_POINTS, $this->node1->getPoints() + $this->node2->getPoints());
408
409 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
410 $this->assertFalse($root_progress->canBeCompleted());
411 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, and setAllNodesActive().

+ Here is the call graph for this function:

◆ testCanBeCompleted3()

ilStudyProgrammeUserProgressTest::testCanBeCompleted3 ( )

Definition at line 413 of file ilStudyProgrammeUserProgressTest.php.

414 {
415 $NEW_AMOUNT_OF_POINTS = 3003;
416 $this->assertGreaterThan(ilStudyProgramme::DEFAULT_POINTS, $NEW_AMOUNT_OF_POINTS);
417
418 $this->setAllNodesActive();
420 $this->root->addNode($node3);
421 $node3->setPoints($NEW_AMOUNT_OF_POINTS)
423 ->update();
424
425
426 $tmp = $this->assignNewUserToRoot();
427 $ass = $tmp[0];
428 $user = $tmp[1];
429
430 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
431 $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
432
433 $this->assertFalse($root_progress->canBeCompleted());
434 $this->assertFalse($node3_progress->canBeCompleted());
435 }

References assignNewUserToRoot(), ilObjStudyProgramme\createInstance(), ilStudyProgramme\DEFAULT_POINTS, setAllNodesActive(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testCompletionOnDeeplyNestedProgresses()

ilStudyProgrammeUserProgressTest::testCompletionOnDeeplyNestedProgresses ( )

Definition at line 644 of file ilStudyProgrammeUserProgressTest.php.

645 {
650 $depth1->putInTree(ROOT_FOLDER_ID);
651 $depth1->addNode($depth2);
652 $depth2->addNode($depth3);
653 $depth3->addNode($depth4);
654 $depth1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
655 $depth2->setStatus(ilStudyProgramme::STATUS_ACTIVE);
656 $depth3->setStatus(ilStudyProgramme::STATUS_ACTIVE);
657 $depth4->setStatus(ilStudyProgramme::STATUS_ACTIVE);
658
659 $user = $this->newUser();
660
661 $assignment = $depth1->assignUser($user->getId());
662 $progress4 = $depth4->getProgressForAssignment($assignment->getId());
663 $progress4->markAccredited(6);
664
665 $progress1 = $depth1->getProgressForAssignment($assignment->getId());
666 $progress2 = $depth2->getProgressForAssignment($assignment->getId());
667 $progress3 = $depth3->getProgressForAssignment($assignment->getId());
668
669 $this->assertTrue($progress1->isSuccessful());
670 $this->assertTrue($progress2->isSuccessful());
671 $this->assertTrue($progress3->isSuccessful());
672 $this->assertTrue($progress4->isSuccessful());
673
674 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress1->getCurrentAmountOfPoints());
675 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress2->getCurrentAmountOfPoints());
676 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress3->getCurrentAmountOfPoints());
677 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $progress4->getCurrentAmountOfPoints());
678 }

References ilObjStudyProgramme\createInstance(), ilStudyProgramme\DEFAULT_POINTS, newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testExplicitPointUpdate1()

ilStudyProgrammeUserProgressTest::testExplicitPointUpdate1 ( )

Definition at line 474 of file ilStudyProgrammeUserProgressTest.php.

475 {
476 $this->setAllNodesActive();
477 $tmp = $this->assignNewUserToRoot();
478 $ass = $tmp[0];
479 $user = $tmp[1];
480
481 $NEW_AMOUNT_OF_POINTS = 202;
482 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS, ilStudyProgramme::DEFAULT_POINTS);
483
484 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
485 ->update();
486
487 $ass->updateFromProgram();
488 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
489 $this->assertEquals($NEW_AMOUNT_OF_POINTS, $root_progress->getAmountOfPoints());
490 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, and setAllNodesActive().

+ Here is the call graph for this function:

◆ testExplicitPointUpdate2()

ilStudyProgrammeUserProgressTest::testExplicitPointUpdate2 ( )

Definition at line 495 of file ilStudyProgrammeUserProgressTest.php.

496 {
497 $this->setAllNodesActive();
498 $tmp = $this->assignNewUserToRoot();
499 $ass = $tmp[0];
500 $user = $tmp[1];
501
502 $NEW_AMOUNT_OF_POINTS = 203;
503 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS, ilStudyProgramme::DEFAULT_POINTS);
504
505 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
506 ->update();
507
508 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
509 $ass->updateFromProgram();
510 $this->assertEquals($NEW_AMOUNT_OF_POINTS, $root_progress->getAmountOfPoints());
511 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, and setAllNodesActive().

+ Here is the call graph for this function:

◆ testGetInstance()

ilStudyProgrammeUserProgressTest::testGetInstance ( )

Definition at line 742 of file ilStudyProgrammeUserProgressTest.php.

743 {
744 $this->setAllNodesActive();
745 $tmp = $this->assignNewUserToRoot();
746 $ass = $tmp[0];
747 $user = $tmp[1];
748
749 $sp_user_progress_db = new ilStudyProgrammeUserProgressDB();
750 $inst = $sp_user_progress_db->getInstance(
751 $ass->getId(),
752 $this->root->getId(),
753 $user->getId()
754 );
755 $this->assertInstanceOf(ilStudyProgrammeUserProgress::class, $inst);
756 $this->assertEquals(
757 $this->root->getProgressesOf($user->getId()),
758 $sp_user_progress_db->getInstancesForUser($this->root->getId(), $user->getId())
759 );
760
761 $up = $this->root->getProgressesOf($user->getId())[0];
762 $this->assertEquals(
763 $up,
764 $sp_user_progress_db->getInstanceById($up->getId())
765 );
766 }
Storage implementation for ilStudyProgrammeUserProgress.

References assignNewUserToRoot(), and setAllNodesActive().

+ Here is the call graph for this function:

◆ testGetInstanceCalls()

ilStudyProgrammeUserProgressTest::testGetInstanceCalls ( )

Definition at line 768 of file ilStudyProgrammeUserProgressTest.php.

769 {
770 $sp_user_progress_db = new ilStudyProgrammeUserProgressDB();
771 try {
772 $sp_user_progress_db->getInstanceById(-1);
773 $this->assertFalse("This should not happen");
774 } catch (ilException $e) {
775 $this->assertTrue(true);
776 }
777
778
779 try {
780 $sp_user_progress_db->getInstancesForAssignment(-1);
781 $this->assertFalse("This should not happen");
783 $this->assertTrue(true);
784 }
785 }
Base class for ILIAS Exception handling.
Exception is thrown when a progress for some programme node and assignment is missing.

◆ testGetNamesOfCompletedOrAccreditedChildren()

ilStudyProgrammeUserProgressTest::testGetNamesOfCompletedOrAccreditedChildren ( )

Definition at line 614 of file ilStudyProgrammeUserProgressTest.php.

615 {
616 $this->setAllNodesActive();
617 $tmp = $this->assignNewUserToRoot();
618 $ass = $tmp[0];
619 $user = $tmp[1];
620
621 $user2 = $this->newUser();
622 $USER_ID = $user2->getId();
623
624 $this->node1->setTitle("node1");
625 $this->node1->update();
626 $this->node2->setTitle("node2");
627 $this->node2->update();
628
629 $names = $this->root->getProgressForAssignment($ass->getId())
630 ->getNamesOfCompletedOrAccreditedChildren();
631 $this->assertEquals($names, array());
632
633 $this->node1->getProgressForAssignment($ass->getId())->markAccredited($USER_ID);
634 $names = $this->root->getProgressForAssignment($ass->getId())
635 ->getNamesOfCompletedOrAccreditedChildren();
636 $this->assertEquals($names, array("node1"));
637
638 $this->node2->getProgressForAssignment($ass->getId())->markAccredited($USER_ID);
639 $names = $this->root->getProgressForAssignment($ass->getId())
640 ->getNamesOfCompletedOrAccreditedChildren();
641 $this->assertEquals($names, array("node1", "node2"));
642 }

References $names, assignNewUserToRoot(), newUser(), and setAllNodesActive().

+ Here is the call graph for this function:

◆ testHasDeviationToProgram1()

ilStudyProgrammeUserProgressTest::testHasDeviationToProgram1 ( )

Definition at line 567 of file ilStudyProgrammeUserProgressTest.php.

568 {
569 $this->setAllNodesActive();
570 $tmp = $this->assignNewUserToRoot();
571 $ass1 = $tmp[0];
572 $user1 = $tmp[1];
573
574 $progress = $this->node1->getProgressForAssignment($ass1->getId());
575 $this->assertFalse($progress->hasIndividualModifications());
576 }

References assignNewUserToRoot(), and setAllNodesActive().

+ Here is the call graph for this function:

◆ testHasDeviationToProgram2()

ilStudyProgrammeUserProgressTest::testHasDeviationToProgram2 ( )

Definition at line 578 of file ilStudyProgrammeUserProgressTest.php.

579 {
580 $this->setAllNodesActive();
581 $tmp = $this->assignNewUserToRoot();
582 $ass1 = $tmp[0];
583 $user1 = $tmp[1];
584
585 $progress = $this->node1->getProgressForAssignment($ass1->getId());
586 $progress->setRequiredAmountOfPoints(1000, $this->user->getId());
587 $this->assertTrue($progress->hasIndividualModifications());
588 }

References assignNewUserToRoot(), setAllNodesActive(), and user().

+ Here is the call graph for this function:

◆ testHasDeviationToProgram3()

ilStudyProgrammeUserProgressTest::testHasDeviationToProgram3 ( )

Definition at line 590 of file ilStudyProgrammeUserProgressTest.php.

591 {
592 $this->setAllNodesActive();
593 $tmp = $this->assignNewUserToRoot();
594 $ass1 = $tmp[0];
595 $user1 = $tmp[1];
596
597 $progress = $this->node1->getProgressForAssignment($ass1->getId());
598 $progress->markNotRelevant($this->user->getId());
599 $this->assertTrue($progress->hasIndividualModifications());
600 }

References assignNewUserToRoot(), setAllNodesActive(), and user().

+ Here is the call graph for this function:

◆ testHasDeviationToProgram4()

ilStudyProgrammeUserProgressTest::testHasDeviationToProgram4 ( )

Definition at line 602 of file ilStudyProgrammeUserProgressTest.php.

603 {
604 $this->setAllNodesActive();
605 $tmp = $this->assignNewUserToRoot();
606 $ass1 = $tmp[0];
607 $user1 = $tmp[1];
608
609 $progress = $this->node1->getProgressForAssignment($ass1->getId());
610 $progress->markAccredited($this->user->getId());
611 $this->assertFalse($progress->hasIndividualModifications());
612 }

References assignNewUserToRoot(), setAllNodesActive(), and user().

+ Here is the call graph for this function:

◆ testIndividualRequiredPoints()

ilStudyProgrammeUserProgressTest::testIndividualRequiredPoints ( )

Definition at line 330 of file ilStudyProgrammeUserProgressTest.php.

331 {
332 $this->setAllNodesActive();
333 $tmp = $this->assignNewUserToRoot();
334 $ass1 = $tmp[0];
335 $user1 = $tmp[1];
336
337
338 $NEW_AMOUNT_OF_POINTS_1 = 205;
339 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, ilStudyProgramme::DEFAULT_POINTS);
340
341 $node2_progress1 = array_shift($this->node2->getProgressesOf($user1->getId()));
342 $node2_progress1->setRequiredAmountOfPoints($NEW_AMOUNT_OF_POINTS_1, $this->user->getId());
343
344 $this->assertEquals($NEW_AMOUNT_OF_POINTS_1, $node2_progress1->getAmountOfPoints());
345 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, setAllNodesActive(), and user().

+ Here is the call graph for this function:

◆ testInitialProgressActive()

ilStudyProgrammeUserProgressTest::testInitialProgressActive ( )

Definition at line 79 of file ilStudyProgrammeUserProgressTest.php.

80 {
81 $this->setAllNodesActive();
82 $tmp = $this->assignNewUserToRoot();
83 $ass = $tmp[0];
84 $user = $tmp[1];
85
86 $root_progresses = $this->root->getProgressesOf($user->getId());
87 $this->assertCount(1, $root_progresses);
88 $root_progress = $root_progresses[0];
89 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
90 $this->assertEquals($this->root->getPoints(), $root_progress->getAmountOfPoints());
91 $this->assertEquals(0, $root_progress->getCurrentAmountOfPoints());
92 $this->assertEquals($this->root->getId(), $root_progress->getStudyProgramme()->getId());
93 $this->assertEquals($ass->getId(), $root_progress->getAssignment()->getId());
94 $this->assertEquals($user->getId(), $root_progress->getUserId());
95 $this->assertNull($root_progress->getLastChangeBy());
96 $this->assertNull($root_progress->getCompletionBy());
97
98 $node1_progresses = $this->node1->getProgressesOf($user->getId());
99 $this->assertCount(1, $node1_progresses);
100 $node1_progress = $node1_progresses[0];
101 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
102 $this->assertEquals($this->node1->getPoints(), $node1_progress->getAmountOfPoints());
103 $this->assertEquals(0, $node1_progress->getCurrentAmountOfPoints());
104 $this->assertEquals($this->node1->getId(), $node1_progress->getStudyProgramme()->getId());
105 $this->assertEquals($ass->getId(), $node1_progress->getAssignment()->getId());
106 $this->assertEquals($user->getId(), $node1_progress->getUserId());
107 $this->assertNull($node1_progress->getLastChangeBy());
108 $this->assertNull($node1_progress->getCompletionBy());
109
110 $node2_progresses = $this->node2->getProgressesOf($user->getId());
111 $this->assertCount(1, $node2_progresses);
112 $node2_progress = $node2_progresses[0];
113 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node2_progress->getStatus());
114 $this->assertEquals($this->node2->getPoints(), $node2_progress->getAmountOfPoints());
115 $this->assertEquals(0, $node2_progress->getCurrentAmountOfPoints());
116 $this->assertEquals($this->node2->getId(), $node2_progress->getStudyProgramme()->getId());
117 $this->assertEquals($ass->getId(), $node2_progress->getAssignment()->getId());
118 $this->assertEquals($user->getId(), $node2_progress->getUserId());
119 $this->assertNull($node2_progress->getLastChangeBy());
120 $this->assertNull($node2_progress->getCompletionBy());
121 }

References assignNewUserToRoot(), setAllNodesActive(), and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testInitialProgressDraft()

ilStudyProgrammeUserProgressTest::testInitialProgressDraft ( )

Definition at line 123 of file ilStudyProgrammeUserProgressTest.php.

124 {
125 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
126 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
127 $this->node2->setStatus(ilStudyProgramme::STATUS_DRAFT)->update();
128
129 $tmp = $this->assignNewUserToRoot();
130 $user = $tmp[1];
131 $ass = $tmp[0];
132
133 $root_progresses = $this->root->getProgressesOf($user->getId());
134 $root_progress = $root_progresses[0];
135 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
136
137 $node1_progresses = $this->node1->getProgressesOf($user->getId());
138 $node1_progress = $node1_progresses[0];
139 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
140
141 $node2_progresses = $this->node2->getProgressesOf($user->getId());
142 $node2_progress = $node2_progresses[0];
143 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $node2_progress->getStatus());
144 }

References assignNewUserToRoot(), ilStudyProgramme\STATUS_ACTIVE, ilStudyProgramme\STATUS_DRAFT, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

+ Here is the call graph for this function:

◆ testInitialProgressOutdated()

ilStudyProgrammeUserProgressTest::testInitialProgressOutdated ( )

Definition at line 146 of file ilStudyProgrammeUserProgressTest.php.

147 {
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];
158 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
159
160 $node1_progresses = $this->node1->getProgressesOf($user->getId());
161 $node1_progress = $node1_progresses[0];
162 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
163
164 $node2_progresses = $this->node2->getProgressesOf($user->getId());
165 $node2_progress = $node2_progresses[0];
166 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $node2_progress->getStatus());
167 }

References assignNewUserToRoot(), ilStudyProgramme\STATUS_ACTIVE, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and ilStudyProgramme\STATUS_OUTDATED.

+ Here is the call graph for this function:

◆ testMarkAccredited()

ilStudyProgrammeUserProgressTest::testMarkAccredited ( )

Definition at line 181 of file ilStudyProgrammeUserProgressTest.php.

182 {
183 $this->setAllNodesActive();
184 $tmp = $this->assignNewUserToRoot();
185 $ass = $tmp[0];
186 $user = $tmp[1];
187
188 $user2 = $this->newUser();
189 $USER_ID = $user2->getId();
190
191 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
192 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
193
194 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
195 $this->assertEquals($root_progress->getAmountOfPoints(), ilStudyProgramme::DEFAULT_POINTS);
196 $this->assertEquals($node1_progress->getAmountOfPoints(), ilStudyProgramme::DEFAULT_POINTS);
197 $this->assertEquals($node2_progress->getAmountOfPoints(), ilStudyProgramme::DEFAULT_POINTS);
198
199 $ts_before_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
200 $node2_progress->markAccredited($USER_ID);
201 $ts_after_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
202
203 $this->assertTrue($node2_progress->isSuccessful());
204 $this->assertEquals($root_progress->getAmountOfPoints(), $root_progress->getCurrentAmountOfPoints());
205
206 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $root_progress->getStatus());
207 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
208 $this->assertEquals(ilStudyProgrammeProgress::STATUS_ACCREDITED, $node2_progress->getStatus());
209
210 $this->assertEquals($USER_ID, $node2_progress->getCompletionBy());
211 $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
212 }
const IL_CAL_DATETIME

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, IL_CAL_DATETIME, newUser(), setAllNodesActive(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testMarkFailed()

ilStudyProgrammeUserProgressTest::testMarkFailed ( )

Definition at line 246 of file ilStudyProgrammeUserProgressTest.php.

247 {
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 $node2_progress->markFailed($USER_ID);
260
261 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
262 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
263 $this->assertEquals(ilStudyProgrammeProgress::STATUS_FAILED, $node2_progress->getStatus());
264 }

References assignNewUserToRoot(), newUser(), setAllNodesActive(), ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testMarkNotFailed()

ilStudyProgrammeUserProgressTest::testMarkNotFailed ( )

Definition at line 266 of file ilStudyProgrammeUserProgressTest.php.

267 {
268 $this->setAllNodesActive();
269 $tmp = $this->assignNewUserToRoot();
270 $ass = $tmp[0];
271 $user = $tmp[1];
272
273 $user2 = $this->newUser();
274 $USER_ID = $user2->getId();
275
276 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
277 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
278 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
279 $node2_progress->markFailed($USER_ID);
280
281 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
282 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
283 $this->assertEquals(ilStudyProgrammeProgress::STATUS_FAILED, $node2_progress->getStatus());
284
285 $node2_progress->markNotFailed($USER_ID);
286
287 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node2_progress->getStatus());
288 }

References assignNewUserToRoot(), newUser(), setAllNodesActive(), ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testMarkNotRelevant()

ilStudyProgrammeUserProgressTest::testMarkNotRelevant ( )

Definition at line 290 of file ilStudyProgrammeUserProgressTest.php.

291 {
292 $this->setAllNodesActive();
293 $tmp = $this->assignNewUserToRoot();
294 $ass = $tmp[0];
295 $user = $tmp[1];
296
297 $user2 = $this->newUser();
298 $USER_ID = $user2->getId();
299
300 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
301 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
302 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
303 $ts_before_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
304 $node2_progress->markNotRelevant($USER_ID);
305 $ts_after_change = $node2_progress->getLastChange()->get(IL_CAL_DATETIME);
306 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $root_progress->getStatus());
307 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $node1_progress->getStatus());
308 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $node2_progress->getStatus());
309 $this->assertEquals($USER_ID, $node2_progress->getCompletionBy());
310 $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
311 $this->assertTrue($node2_progress->hasIndividualModifications());
312 }

References assignNewUserToRoot(), IL_CAL_DATETIME, newUser(), setAllNodesActive(), ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

+ Here is the call graph for this function:

◆ testMaximimPossibleAmountOfPoints1()

ilStudyProgrammeUserProgressTest::testMaximimPossibleAmountOfPoints1 ( )

Definition at line 347 of file ilStudyProgrammeUserProgressTest.php.

348 {
349 $this->setAllNodesActive();
350 $tmp = $this->assignNewUserToRoot();
351 $ass = $tmp[0];
352 $user = $tmp[1];
353
354 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
355 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
356 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
357
358 $this->assertEquals(2 * ilStudyProgramme::DEFAULT_POINTS, $root_progress->getMaximumPossibleAmountOfPoints());
359 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node1_progress->getMaximumPossibleAmountOfPoints());
360 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node2_progress->getMaximumPossibleAmountOfPoints());
361 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, and setAllNodesActive().

+ Here is the call graph for this function:

◆ testMaximimPossibleAmountOfPoints2()

ilStudyProgrammeUserProgressTest::testMaximimPossibleAmountOfPoints2 ( )

Definition at line 363 of file ilStudyProgrammeUserProgressTest.php.

364 {
365 $this->setAllNodesActive();
366 $tmp = $this->assignNewUserToRoot();
367 $ass = $tmp[0];
368 $user = $tmp[1];
369
370 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
371 $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
372 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
373
374 $this->assertEquals(2 * ilStudyProgramme::DEFAULT_POINTS, $root_progress->getMaximumPossibleAmountOfPoints());
375 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node1_progress->getMaximumPossibleAmountOfPoints());
376 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $node2_progress->getMaximumPossibleAmountOfPoints());
377 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, and setAllNodesActive().

+ Here is the call graph for this function:

◆ testNewNodesAreNotRelevant()

ilStudyProgrammeUserProgressTest::testNewNodesAreNotRelevant ( )

Definition at line 315 of file ilStudyProgrammeUserProgressTest.php.

316 {
317 $this->setAllNodesActive();
318 $tmp = $this->assignNewUserToRoot();
319 $ass = $tmp[0];
320 $user = $tmp[1];
321
323 $this->root->addNode($node3);
324
325 $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
326 $this->assertNotNull($node3_progress);
327 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $node3_progress->getStatus());
328 }

References assignNewUserToRoot(), ilObjStudyProgramme\createInstance(), setAllNodesActive(), and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

+ Here is the call graph for this function:

◆ testNoImplicitPointUpdate()

ilStudyProgrammeUserProgressTest::testNoImplicitPointUpdate ( )

Definition at line 455 of file ilStudyProgrammeUserProgressTest.php.

456 {
457 $this->setAllNodesActive();
458 $tmp = $this->assignNewUserToRoot();
459 $ass = $tmp[0];
460 $user = $tmp[1];
461
462 $NEW_AMOUNT_OF_POINTS = 201;
463 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS, ilStudyProgramme::DEFAULT_POINTS);
464
465 $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
466 ->update();
467
468 $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
469 $this->assertEquals(ilStudyProgramme::DEFAULT_POINTS, $root_progress->getAmountOfPoints());
470 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, and setAllNodesActive().

+ Here is the call graph for this function:

◆ testNoUpdateOnModifiedNodes()

ilStudyProgrammeUserProgressTest::testNoUpdateOnModifiedNodes ( )

Definition at line 516 of file ilStudyProgrammeUserProgressTest.php.

517 {
518 $this->setAllNodesActive();
519 $tmp = $this->assignNewUserToRoot();
520 $ass1 = $tmp[0];
521 $user1 = $tmp[1];
522
523 $tmp = $this->assignNewUserToRoot();
524 $ass2 = $tmp[0];
525 $user2 = $tmp[1];
526
527 $NEW_AMOUNT_OF_POINTS_1 = 205;
528 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, ilStudyProgramme::DEFAULT_POINTS);
529 $NEW_AMOUNT_OF_POINTS_2 = 206;
530 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_2, ilStudyProgramme::DEFAULT_POINTS);
531 $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, $NEW_AMOUNT_OF_POINTS_2);
532
533 $node2_progress1 = array_shift($this->node2->getProgressesOf($user1->getId()));
534 $node2_progress2 = array_shift($this->node2->getProgressesOf($user2->getId()));
535
536 $node2_progress1->setRequiredAmountOfPoints($NEW_AMOUNT_OF_POINTS_1, $this->user->getId());
537
538 $this->node2->setPoints($NEW_AMOUNT_OF_POINTS_2)
539 ->update();
540 $this->root->updateAllAssignments();
541
542 $this->assertEquals($NEW_AMOUNT_OF_POINTS_1, $node2_progress1->getAmountOfPoints());
543 $this->assertEquals($NEW_AMOUNT_OF_POINTS_2, $node2_progress2->getAmountOfPoints());
544 }

References assignNewUserToRoot(), ilStudyProgramme\DEFAULT_POINTS, setAllNodesActive(), and user().

+ Here is the call graph for this function:

◆ testOutdatedNodesCantBeSetToRelevant()

ilStudyProgrammeUserProgressTest::testOutdatedNodesCantBeSetToRelevant ( )

QUA-Objekte, welche "Inaktiv" sind können bei Studierenden-Studienplänen nicht von "nicht relevant" auf irgendeinen anderen Status gesetzt werden.

@expectedException ilException

Definition at line 552 of file ilStudyProgrammeUserProgressTest.php.

553 {
554 $this->setAllNodesActive();
555 $this->node1->setStatus(ilStudyProgramme::STATUS_OUTDATED);
556 $tmp = $this->assignNewUserToRoot();
557 $ass1 = $tmp[0];
558 $user1 = $tmp[1];
559
560 $progress = $this->node1->getProgressForAssignment($ass1->getId());
561 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $progress->getStatus());
562 $progress->markAccredited($this->user->getId());
563 }

References assignNewUserToRoot(), setAllNodesActive(), ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, ilStudyProgramme\STATUS_OUTDATED, and user().

+ Here is the call graph for this function:

◆ testPossibleActions()

ilStudyProgrammeUserProgressTest::testPossibleActions ( )

Definition at line 681 of file ilStudyProgrammeUserProgressTest.php.

682 {
683 //node is root-node, status is "not relevant"
684 $expected = array(
687 );
688 $this->assertEquals(
689 $expected,
691 1,
692 1,
694 )
695 );
696
697 //node is root-node, status is "in progress"
698 $expected = array(
702 );
703 $this->assertEquals(
704 $expected,
706 1,
707 1,
709 )
710 );
711
712 //node is root-node, status is "accredited"
713 $expected = array(
717 );
718 $this->assertEquals(
719 $expected,
721 1,
722 1,
724 )
725 );
726
727 //node is _not_ root-node, status is "accredited"
728 $expected = array(
730 );
731 $this->assertEquals(
732 $expected,
734 0,
735 1,
737 )
738 );
739 }
static getPossibleActions($a_node_id, $a_root_prg_id, $a_status)
Get a list with possible actions on a progress record.

References ilStudyProgrammeUserProgress\ACTION_MARK_ACCREDITED, ilStudyProgrammeUserProgress\ACTION_REMOVE_USER, ilStudyProgrammeUserProgress\ACTION_SHOW_INDIVIDUAL_PLAN, ilStudyProgrammeUserProgress\ACTION_UNMARK_ACCREDITED, ilStudyProgrammeUserProgress\getPossibleActions(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

+ Here is the call graph for this function:

◆ testUnmarkAccredited()

ilStudyProgrammeUserProgressTest::testUnmarkAccredited ( )

Definition at line 214 of file ilStudyProgrammeUserProgressTest.php.

215 {
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 }

References assignNewUserToRoot(), IL_CAL_DATETIME, newUser(), setAllNodesActive(), and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testUserDeletionDeletesAssignments()

ilStudyProgrammeUserProgressTest::testUserDeletionDeletesAssignments ( )

Definition at line 437 of file ilStudyProgrammeUserProgressTest.php.

438 {
439 $this->setAllNodesActive();
440 $tmp = $this->assignNewUserToRoot();
441 $ass = $tmp[0];
442 $user = $tmp[1];
443
444 $user->delete();
445
446 $root_progresses = $this->root->getProgressesOf($user->getId());
447 $this->assertCount(0, $root_progresses);
448 $node1_progresses = $this->root->getProgressesOf($user->getId());
449 $this->assertCount(0, $node1_progresses);
450 $node2_progresses = $this->root->getProgressesOf($user->getId());
451 $this->assertCount(0, $node2_progresses);
452 }

References assignNewUserToRoot(), and setAllNodesActive().

+ Here is the call graph for this function:

◆ testUserSelection()

ilStudyProgrammeUserProgressTest::testUserSelection ( )

Definition at line 169 of file ilStudyProgrammeUserProgressTest.php.

170 {
171 $this->setAllNodesActive();
172 $this->assignNewUserToRoot();
173 $tmp = $this->assignNewUserToRoot();
174 $ass = $tmp[0];
175 $user = $tmp[1];
176
177 $root_progresses = $this->root->getProgressesOf($user->getId());
178 $this->assertCount(1, $root_progresses);
179 }

References assignNewUserToRoot(), and setAllNodesActive().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeUserProgressTest::$backupGlobals = false
protected

Definition at line 17 of file ilStudyProgrammeUserProgressTest.php.


The documentation for this class was generated from the following file: