3 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../libs/composer/vendor/autoload.php");
32 $this->assertInstanceOf(Node::class, $pgs);
33 $this->assertEquals($pgs->getNodeId(), 123);
40 $dat = DateTimeImmutable::createFromFormat(
'Ymd',
'20221024');
42 $this->assertEquals($pgs->withAmountOfPoints(12)->getAmountOfPoints(), 12);
43 $this->assertEquals($pgs->withCurrentAmountOfPoints(8)->getCurrentAmountOfPoints(), 8);
46 $pgs = $pgs->withLastChange(6, $dat);
47 $this->assertEquals($pgs->getLastChangeBy(), 6);
48 $this->assertEquals($pgs->getLastChange(), $dat);
49 $this->assertEquals($pgs->withAssignmentDate($dat)->getAssignmentDate(), $dat);
50 $pgs = $pgs->withCompletion(6, $dat);
51 $this->assertEquals($pgs->getCompletionBy(), 6);
52 $this->assertEquals($pgs->getCompletionDate(), $dat);
53 $this->assertEquals($pgs->withDeadline($dat)->getDeadline(), $dat);
54 $this->assertEquals($pgs->withValidityOfQualification($dat)->getValidityOfQualification(), $dat);
55 $this->assertTrue($pgs->withIndividualModifications(
true)->hasIndividualModifications());
62 $this->assertTrue($pgs->isRelevant());
66 $this->assertFalse($pgs->isAccredited());
73 $yesterday = $today->sub(
new DateInterval(
'P1D'));
74 $tomorrow = $today->add(
new DateInterval(
'P1D'));
78 ->withValidityOfQualification($today);
80 $this->assertNull($pgs->hasValidQualification($today));
83 $this->assertTrue($pgs->hasValidQualification($yesterday));
84 $this->assertTrue($pgs->hasValidQualification($today));
85 $this->assertFalse($pgs->hasValidQualification($tomorrow));
91 $yesterday = $today->sub(
new DateInterval(
'P1D'));
96 ->withValidityOfQualification($today);
97 $this->assertFalse($pgs->isInvalidated());
100 ->withValidityOfQualification($yesterday)
102 $this->assertTrue($pgs->isInvalidated());
107 $this->expectException(\ilException::class);
109 $tomorrow = $today->add(
new DateInterval(
'P1D'));
112 ->withValidityOfQualification($tomorrow)
123 $pgs = $pgs->markAccredited($now, $usr);
124 $this->assertEquals($now, $pgs->getCompletionDate());
125 $this->assertEquals($usr, $pgs->getCompletionBy());
126 $this->assertEquals($usr, $pgs->getLastChangeBy());
141 $pgs = $pgs->unmarkAccredited($now, $usr);
142 $this->assertNull($pgs->getCompletionDate());
143 $this->assertNull($pgs->getCompletionBy());
144 $this->assertNull($pgs->getValidityOfQualification());
145 $this->assertEquals($usr, $pgs->getLastChangeBy());
160 $pgs = $pgs->markFailed($now, $usr);
161 $this->assertNull($pgs->getCompletionDate());
162 $this->assertNull($pgs->getCompletionBy());
163 $this->assertEquals($usr, $pgs->getLastChangeBy());
178 $pgs = $pgs->markNotFailed($now, $usr);
179 $this->assertNull($pgs->getCompletionDate());
180 $this->assertNull($pgs->getCompletionBy());
181 $this->assertEquals($usr, $pgs->getLastChangeBy());
196 $pgs = $pgs->succeed($now, $usr);
197 $this->assertEquals($now, $pgs->getCompletionDate());
198 $this->assertEquals($usr, $pgs->getCompletionBy());
199 $this->assertEquals($usr, $pgs->getLastChangeBy());
214 $pgs = $pgs->markRelevant($now, $usr);
215 $this->assertNull($pgs->getCompletionBy());
216 $this->assertEquals($usr, $pgs->getLastChangeBy());
222 $this->assertTrue($pgs->hasIndividualModifications());
232 $pgs = $pgs->markNotRelevant($now, $usr);
233 $this->assertNull($pgs->getCompletionBy());
234 $this->assertEquals($usr, $pgs->getLastChangeBy());
240 $this->assertTrue($pgs->hasIndividualModifications());
257 $this->expectException(\ilException::class);
267 if (in_array($status, [
274 $this->assertTrue($pgs->isTransitionAllowedTo($status));
276 $this->assertFalse($pgs->isTransitionAllowedTo($status));
288 if (in_array($status, [
295 $this->assertTrue($pgs->isTransitionAllowedTo($status));
297 $this->assertFalse($pgs->isTransitionAllowedTo($status));
309 if (in_array($status, [
314 $this->assertTrue($pgs->isTransitionAllowedTo($status));
316 $this->assertFalse($pgs->isTransitionAllowedTo($status));
328 if (in_array($status, [
334 $this->assertTrue($pgs->isTransitionAllowedTo($status));
336 $this->assertFalse($pgs->isTransitionAllowedTo($status));
347 || $status === $pgs->getStatus()
349 $this->assertTrue($pgs->isTransitionAllowedTo($status));
351 $this->assertFalse($pgs->isTransitionAllowedTo($status));
367 ->withAmountOfPoints(112);
369 ->withAmountOfPoints(111);
371 ->setSubnodes([$pgs111, $pgs112])
372 ->withAmountOfPoints(11);
374 ->withAmountOfPoints(12);
376 ->withAmountOfPoints(13);
378 ->setSubnodes([$pgs11, $pgs12, $pgs13])
379 ->withAmountOfPoints(1);
381 $this->assertEquals(111 + 112, $pgs11->getPossiblePointsOfRelevantChildren());
382 $this->assertEquals(0, $pgs12->getPossiblePointsOfRelevantChildren());
383 $this->assertEquals(11 + 12 + 13 * 0, $pgs1->getPossiblePointsOfRelevantChildren());
384 $this->assertEquals(111 + 112, $pgs11->getAchievedPointsOfChildren());
385 $this->assertEquals(0, $pgs1->getAchievedPointsOfChildren());
testPRGProgressPointsOfChildren()
testPRGProgressProperties()
testPRGProgressStatusActionsMarkNotRelevant()
testPRGProgressAllowedTransitionsForFailed($status)
status
testPRGProgressAllowedTransitionsForAccredited($status)
status
testPRGProgressAllowedTransitionsForCompleted($status)
status
testPRGProgressStatusActionsUnmarkAccredited()
testPRGProgressStatusActionsMarkRelevant()
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
testPRGProgressInitAndId()
testPRGProgressInvalidation()
testPRGProgressStatusActionsMarkNotFailed()
testPRGProgressHasValidQualification()
testPRGProgressAllowedTransitionsForIrrelevant($status)
status
testPRGProgressInvalidStatus()
const STATUS_NOT_RELEVANT
testPRGProgressAllowedTransitionsForInProgress(int $status)
status
testPRGProgressStatusChecker()
testPRGProgressStatusActionsMarkFailed()
testPRGProgressInvalidInvalidation()
testPRGProgressStatusActionsSucceed()
testPRGProgressStatusActionsMarkAccredited()