ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilStudyProgrammeLPTest.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 testInitialLPActive() {
71 $this->setAllNodesActive();
72 $tmp = $this->assignNewUserToRoot();
73 $ass = $tmp[0];
74 $user = $tmp[1];
75
76 require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
77 require_once("Services/Tracking/classes/class.ilLPStatus.php");
78 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
79 , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
80 );
81 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
82 , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
83 );
84 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
85 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
86 );
87 }
88
89 public function testInitialLPDraft() {
90 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
91 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
92 $this->node2->setStatus(ilStudyProgramme::STATUS_DRAFT)->update();
93
94 $tmp = $this->assignNewUserToRoot();
95 $user = $tmp[1];
96 $ass = $tmp[0];
97
98 require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
99 require_once("Services/Tracking/classes/class.ilLPStatus.php");
100 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
101 , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
102 );
103 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
104 , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
105 );
106 $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
107 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
108 );
109 }
110
111 public function testInitialProgressOutdated() {
112 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
113 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
114 $this->node2->setStatus(ilStudyProgramme::STATUS_OUTDATED)->update();
115
116 $tmp = $this->assignNewUserToRoot();
117 $user = $tmp[1];
118 $ass = $tmp[0];
119
120 require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
121 require_once("Services/Tracking/classes/class.ilLPStatus.php");
122 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
123 , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
124 );
125 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
126 , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
127 );
128 $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
129 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
130 );
131 }
132
133 public function testMarkAccredited() {
134 $this->setAllNodesActive();
135 $tmp = $this->assignNewUserToRoot();
136 $ass = $tmp[0];
137 $user = $tmp[1];
138
139 $user2 = $this->newUser();
140 $USER_ID = $user2->getId();
141
142 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
143 $node2_progress->markAccredited($USER_ID);
144
145 require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
146 require_once("Services/Tracking/classes/class.ilLPStatus.php");
147 $this->assertEquals( ilLPStatus::LP_STATUS_COMPLETED_NUM
148 , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
149 );
150 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
151 , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
152 );
153 $this->assertEquals( ilLPStatus::LP_STATUS_COMPLETED_NUM
154 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
155 );
156 }
157
158 public function testUnmarkAccredited() {
159 $this->setAllNodesActive();
160 $tmp = $this->assignNewUserToRoot();
161 $ass = $tmp[0];
162 $user = $tmp[1];
163
164 $user2 = $this->newUser();
165 $USER_ID = $user2->getId();
166
167 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
168 $node2_progress->markAccredited($USER_ID);
169
170 $this->assertEquals( ilLPStatus::LP_STATUS_COMPLETED_NUM
171 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
172 );
173
174 $node2_progress->unmarkAccredited();
175
176 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
177 , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
178 );
179 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
180 , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
181 );
182 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
183 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
184 );
185 }
186
187
188 public function testMarkNotRelevant() {
189 $this->setAllNodesActive();
190 $tmp = $this->assignNewUserToRoot();
191 $ass = $tmp[0];
192 $user = $tmp[1];
193
194 $user2 = $this->newUser();
195 $USER_ID = $user2->getId();
196
197 $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
198 $node2_progress->markNotRelevant($USER_ID);
199
200 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
201 , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
202 );
203 $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
204 , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
205 );
206 $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
207 , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
208 );
209 }
210
211 // Neues Moduls: Wird dem Studierenden-Studierenden inkl. Kurse, Punkte als "Nicht relevant" hinzugefügt.
212 public function testNewNodesAreNotRelevant() {
213 $this->setAllNodesActive();
214 $tmp = $this->assignNewUserToRoot();
215 $ass = $tmp[0];
216 $user = $tmp[1];
217
219 $this->root->addNode($node3);
220
221 $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
222 $this->assertNotNull($node3_progress);
223 $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
224 , ilLPStatusWrapper::_determineStatus($node3->getId(), $user->getId())
225 );
226 }
227}
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:66
TestCase for the learning progress of users at a programme.
Mock classes for tests.
Definition: mocks.php:21
global $ilUser
Definition: imgupload.php:15