1 <?php declare(strict_types=1);
3 require_once(__DIR__ .
"/../../../libs/composer/vendor/autoload.php");
4 require_once(__DIR__ .
"/prg_mocks.php");
11 $prg =
new PrgMock($prg_id, $this);
12 $settings =
new SettingsMock(
20 ->withAssessmentSettings($set_ass)
21 ->withDeadlineSettings($set_dl)
22 ->withValidityOfQualificationSettings($set_vq);
23 $this->settings_repo->update($settings);
28 ->withAmountOfPoints(2)
29 ->withAssignmentId(-42)
30 ->withNodeId($prg_id);
31 $this->progress_repo->update($progress);
37 $this->progress_repo =
new ProgressRepoMock();
38 $this->assignment_repo =
new AssignmentRepoMock();
39 $this->settings_repo =
new SettingsRepoMock();
51 1 => [
'parent' => null,
'children' => [11,12,13],
'prg' => $this->
buildProgramme(1)],
52 11 => [
'parent' => 1,
'children' => [111,112],
'prg' => $this->
buildProgramme(11)],
53 111 => [
'parent' => 11,
'children' => [],
'prg' => $this->
buildProgramme(111)],
54 112 => [
'parent' => 11,
'children' => [],
'prg' => $this->
buildProgramme(112)],
55 12 => [
'parent' => 1,
'children' => [],
'prg' => $this->
buildProgramme(12)],
56 13 => [
'parent' => 1,
'children' => [],
'prg' => $this->
buildProgramme(13)]
61 $this->assignment_repo->update($assignment);
67 return $this->mock_tree[1][
'prg'];
73 $this->settings_repo->update($this->settings_repo->get($node_id)->withAssessmentSettings($set));
74 $this->progress_repo->update($this->progress_repo->get($node_id)->withAmountOfPoints($points));
76 $this->assertEquals($points, $this->mock_tree[$node_id][
'prg']->getPoints());
81 $set = $this->settings_repo->get($node_id)->setLPMode($mode);
82 $this->settings_repo->update($set);
88 $progress = $this->progress_repo->get(111);
89 $parent = $this->
getRootPrg()->getParentProgress($progress);
90 $this->assertEquals(111, $progress->getNodeId());
91 $this->assertEquals(11, $parent->getNodeId());
93 $this->progress_repo->update(
96 $progress = $this->progress_repo->get(112);
97 $parent = $this->
getRootPrg()->getParentProgress($progress);
98 $this->assertEquals(11, $parent->getNodeId());
101 $progress = $this->progress_repo->get(11);
104 $this->progress_repo->get(111),
105 $this->progress_repo->get(112)
107 $this->
getRootPrg()->getChildrenProgress($progress)
114 $progress = $this->progress_repo->get(11);
130 ->testUpdateParentProgress($this->progress_repo->get(112));
131 $this->assertEquals($this->progress_repo->get(1), $progress);
134 ->testUpdateParentProgress($this->progress_repo->get(13));
135 $this->assertEquals($this->progress_repo->get(1), $progress);
157 $this->
getRootPrg()->getPossiblePointsOfRelevantChildren(
158 $this->progress_repo->get(11)
164 $this->
getRootPrg()->getPossiblePointsOfRelevantChildren(
165 $this->progress_repo->get(1)
169 $this->
getRootPrg()->markNotRelevant(12, 6, $this->messages);
170 $this->
getRootPrg()->markNotRelevant(112, 6, $this->messages);
174 $this->
getRootPrg()->getPossiblePointsOfRelevantChildren(
175 $this->progress_repo->get(11)
181 $this->
getRootPrg()->getPossiblePointsOfRelevantChildren(
182 $this->progress_repo->get(1)
205 $this->assertEquals(0, $prg->getAchievedPointsOfChildren($this->progress_repo->get(12)));
206 $this->assertEquals(0, $prg->getAchievedPointsOfChildren($this->progress_repo->get(11)));
207 $this->assertEquals(0, $prg->getAchievedPointsOfChildren($this->progress_repo->get(1)));
209 $prg->markAccredited(12, 6, $this->messages);
210 $prg->markAccredited(13, 6, $this->messages);
211 $this->assertEquals(22, $prg->getAchievedPointsOfChildren($this->progress_repo->get(1)));
212 $this->assertEquals(22, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
214 $prg->markAccredited(111, 6, $this->messages);
215 $this->assertEquals(5, $prg->getAchievedPointsOfChildren($this->progress_repo->get(11)));
235 $this->
getRootPrg()->markAccredited(111, 6, $this->messages);
236 $this->
getRootPrg()->markAccredited(112, 6, $this->messages);
238 $this->assertEquals(5, $this->progress_repo->get(111)->getCurrentAmountOfPoints());
239 $this->assertEquals(7, $this->progress_repo->get(112)->getCurrentAmountOfPoints());
240 $this->assertEquals(12, $this->progress_repo->get(11)->getCurrentAmountOfPoints());
241 $this->assertEquals(12, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
245 $this->
getRootPrg()->getPossiblePointsOfRelevantChildren(
246 $this->progress_repo->get(1)
251 $this->
getRootPrg()->getAchievedPointsOfChildren(
252 $this->progress_repo->get(1)
274 1 => $this->mock_tree[1],
275 11 => $this->mock_tree[13],
276 12 => $this->mock_tree[12]
279 $this->
getRootPrg()->markAccredited(11, 6, $this->messages);
281 $this->assertEquals(5, $this->progress_repo->get(11)->getCurrentAmountOfPoints());
285 $this->
getRootPrg()->markAccredited(12, 6, $this->messages);
289 $this->assertEquals(5, $this->progress_repo->get(11)->getCurrentAmountOfPoints());
290 $this->assertEquals(5, $this->progress_repo->get(12)->getCurrentAmountOfPoints());
291 $this->assertEquals(10, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
304 $this->progress_repo->update(
308 $this->
getRootPrg()->markAccredited(111, 6, $this->messages);
309 $this->
getRootPrg()->markAccredited(112, 6, $this->messages);
314 $this->assertEquals(0, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
319 $this->progress_repo->update(
323 $this->
getRootPrg()->markAccredited(111, 6, $this->messages);
324 $this->
getRootPrg()->markAccredited(112, 6, $this->messages);
325 $this->assertEquals(0, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
327 $this->
getRootPrg()->markRelevant(11, 6, $this->messages);
329 $this->assertEquals(2, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
331 $this->
getRootPrg()->markNotRelevant(11, 6, $this->messages);
334 $this->assertEquals(2, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
352 $this->mock_tree[112][
'prg']->markAccredited(112, 6, $this->messages);
353 $this->mock_tree[12][
'prg']->markAccredited(13, 6, $this->messages);
354 $triggering_obj_id = 9001;
355 $this->mock_tree[111][
'prg']->succeed(111, $triggering_obj_id);
358 $this->assertEquals(2, $this->progress_repo->get(111)->getCurrentAmountOfPoints());
361 $this->assertEquals(5, $this->progress_repo->get(11)->getCurrentAmountOfPoints());
364 $this->assertEquals(6, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
378 $this->
getRootPrg()->markAccredited(11, 6, $this->messages);
379 $this->
getRootPrg()->markAccredited(13, 6, $this->messages);
381 $this->assertEquals(4, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
384 $this->
getRootPrg()->markNotRelevant(12, 6, $this->messages);
386 $this->assertEquals(4, $this->progress_repo->get(1)->getCurrentAmountOfPoints());
393 $past = DateTimeImmutable::createFromFormat(
'Ymd',
'20010101');
394 $progress = $this->progress_repo->get(13)->withDeadline($past);
396 $progress = $this->
getRootPrg()->testApplyProgressDeadline($progress);
400 $progress->getStatus()
406 $progress = $this->progress_repo->get(13);
408 $progress = $this->
getRootPrg()->testApplyProgressDeadline(
409 $progress->withDeadline($future)
414 $progress->getStatus()
420 $progress = $this->progress_repo->get(13)
422 $this->progress_repo->update($progress);
424 $past = DateTimeImmutable::createFromFormat(
'Ymd',
'20010101');
425 $progress = $this->
getRootPrg()->testApplyProgressDeadline(
426 $progress->withDeadline($past)
431 $progress->getStatus()
437 $past = DateTimeImmutable::createFromFormat(
'Ymd',
'20010101');
438 $this->
getRootPrg()->changeProgressDeadline(12, 6, $this->messages, $past);
442 $this->progress_repo->get(12)->getStatus()
448 $this->progress_repo->update(
449 $this->progress_repo->get(12)
453 $past = DateTimeImmutable::createFromFormat(
'Ymd',
'20010101');
454 $this->
getRootPrg()->changeProgressDeadline(12, 6, $this->messages, $past);
456 $progress = $this->progress_repo->get(12);
458 $this->assertNull($progress->getDeadline());
463 $past = DateTimeImmutable::createFromFormat(
'Ymd',
'20010101');
464 $this->progress_repo->update(
465 $this->progress_repo->get(11)
467 ->withDeadline($past)
470 $this->
getRootPrg()->unmarkAccredited(11, 6, $this->messages);
474 $this->progress_repo->get(11)->getStatus()
481 $this->progress_repo->update(
482 $this->progress_repo->get(1)
486 $this->
getRootPrg()->changeProgressValidityDate(1, 6, $this->messages, $future);
489 $this->progress_repo->get(1)->getValidityOfQualification()
496 $this->progress_repo->update(
497 $this->progress_repo->get(1)
500 $this->
getRootPrg()->changeProgressValidityDate(1, 6, $this->messages, $future);
501 $this->assertNull($this->progress_repo->get(1)->getValidityOfQualification());
506 $this->assertFalse($this->progress_repo->get(11)->hasIndividualModifications());
508 $this->
getRootPrg()->markNotRelevant(11, 6, $this->messages);
509 $this->assertTrue($this->progress_repo->get(11)->hasIndividualModifications());
513 $this->
getRootPrg()->changeProgressDeadline(12, 6, $this->messages, $future);
514 $this->assertTrue($this->progress_repo->get(12)->hasIndividualModifications());
516 $this->
getRootPrg()->changeProgressValidityDate(13, 6, $this->messages, $future);
517 $this->assertFalse($this->progress_repo->get(13)->hasIndividualModifications());
524 $prg->tree = $this->mock_tree;
526 $prg->changeProgressDeadline(12, 6, $this->messages, $future);
527 $this->assertTrue($this->progress_repo->get(12)->hasIndividualModifications());
528 $prg->updatePlanFromRepository(12, 6);
529 $this->assertFalse($this->progress_repo->get(12)->hasIndividualModifications());
534 $future = (
new DateTime())->
add(
new DateInterval(
'P1D'));
535 $future2 = (
new DateTime())->
add(
new DateInterval(
'P4D'));
542 foreach ([1,11,111] as $id) {
543 $settings = $this->mock_tree[$id][
'prg']->getSettings()
544 ->withDeadlineSettings($set_dl)
545 ->withValidityOfQualificationSettings($set_vq)
546 ->withAssessmentSettings($set_as);
548 $this->mock_tree[$id][
'prg']->updateSettings($settings);
549 $progress = $this->progress_repo->get($id)
550 ->withAmountOfPoints(69)
551 ->withDeadline(DateTimeImmutable::createFromMutable($future2))
552 ->withValidityOfQualification(DateTimeImmutable::createFromMutable($future));
553 $progress = $progress->markAccredited(
558 $this->progress_repo->update($progress);
559 $progress = $this->progress_repo->get($id);
560 $this->assertEquals($future2, $progress->getDeadline());
561 $this->assertEquals($future, $progress->getValidityOfQualification());
562 $this->assertEquals(69, $progress->getAmountOfPoints());
565 $prg->tree = &$this->mock_tree;
568 $this->
getRootPrg()->updatePlanFromRepository(11, 6);
570 foreach ([1,11,111] as $prg_id) {
571 $progress = $this->progress_repo->get($prg_id);
572 $this->assertEquals($points, $progress->getAmountOfPoints());
573 $this->assertEquals($future, $progress->getDeadline());
testInternalRunIntegrity()
setModeForNode(int $node_id, int $mode)
testDontFailByDeadlineIfSucceeded()
testDontChangeValidityForIncomplete()
testSuccessionCompletingParents()
setPointsForNode(int $node_id, int $points)
testMarkIrrelevantDoesNotCompleteParent()
testMarkAccreditedShouldNotChangeIrrelevantParent()
── 1 ├── 11 (irrelevant) │ ├── 111 │ └── 112 ├── 12 └── 13
testUpdateFromSettingsResetsIndividual()
testDontFailByFutureDeadline()
testMarkAccreditedOnLPNode()
── 1 (10) ├── 11 (5, LP) └── 12 (5)
testDontChangeDeadlineForCompleted()
testInternalTreeIntegrity()
Represents one assignment of the user to a program tree.
testMarkAccreditedShouldCompleteParentBySufficientPoints()
PRG: MODE_POINTS ── 1 (5) ├── 11 (12) │ ├── 111 (5) │ └── 112 (7) ├── 12 (2) └── 1...
const STATUS_NOT_RELEVANT
testParentAcquisition()
── 1 ├── 11 │ ├── 111 │ └── 112 ├── 12 └── 13
Class ilStudyProgrammeProgress.
testAchievedPoints()
── 1 (1) ├── 11 (8) │ ├── 111 (5) │ └── 112 (10) ├── 12 (12) └── 13 (10) ...
testChildrenPossiblePointsAddition()
── 1 (1) ├── 11 (8) │ ├── 111 (5) │ └── 112 (10) <– turns irrelevant ├── 12 (12) <–...
testUpdatePlanFromSettings()
buildProgramme(int $prg_id)
testMarkRelevantShouldRecalculateStatusAndPoints()
testTranstitionToProgressWithPastDeadline()
Holds information about multi-actions, mainly in context of member-assignemnts and status changes...