5require_once(__DIR__ . 
"/mocks.php");
 
   21        PHPUnit_Framework_Error_Deprecated::$enabled = 
false;
 
   23        require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
 
   25        include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
 
   26        ilUnitUtil::performInitialisation();
 
   29        $this->root->putInTree(ROOT_FOLDER_ID);
 
   38        $this->root->addNode($this->node1);
 
   39        $this->root->addNode($this->node2);
 
   40        $this->node1->addLeaf($this->leaf1);
 
   41        $this->node2->addLeaf($this->leaf2);
 
   55            $this->root->delete();
 
   76        return array($this->root->assignUser($user->getId()), $user);
 
   86        $root_progresses = $this->root->getProgressesOf($user->getId());
 
   87        $this->assertCount(1, $root_progresses);
 
   88        $root_progress = $root_progresses[0];
 
   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());
 
   98        $node1_progresses = $this->node1->getProgressesOf($user->getId());
 
   99        $this->assertCount(1, $node1_progresses);
 
  100        $node1_progress = $node1_progresses[0];
 
  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());
 
  110        $node2_progresses = $this->node2->getProgressesOf($user->getId());
 
  111        $this->assertCount(1, $node2_progresses);
 
  112        $node2_progress = $node2_progresses[0];
 
  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());
 
  133        $root_progresses = $this->root->getProgressesOf($user->getId());
 
  134        $root_progress = $root_progresses[0];
 
  137        $node1_progresses = $this->node1->getProgressesOf($user->getId());
 
  138        $node1_progress = $node1_progresses[0];
 
  141        $node2_progresses = $this->node2->getProgressesOf($user->getId());
 
  142        $node2_progress = $node2_progresses[0];
 
  156        $root_progresses = $this->root->getProgressesOf($user->getId());
 
  157        $root_progress = $root_progresses[0];
 
  160        $node1_progresses = $this->node1->getProgressesOf($user->getId());
 
  161        $node1_progress = $node1_progresses[0];
 
  164        $node2_progresses = $this->node2->getProgressesOf($user->getId());
 
  165        $node2_progress = $node2_progresses[0];
 
  177        $root_progresses = $this->root->getProgressesOf($user->getId());
 
  178        $this->assertCount(1, $root_progresses);
 
  189        $USER_ID = $user2->getId();
 
  191        $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
 
  192        $node1_progress = array_shift($this->node1->getProgressesOf($user->getId()));
 
  194        $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
 
  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);
 
  203        $this->assertTrue($node2_progress->isSuccessful());
 
  204        $this->assertEquals($root_progress->getAmountOfPoints(), $root_progress->getCurrentAmountOfPoints());
 
  210        $this->assertEquals($USER_ID, $node2_progress->getCompletionBy());
 
  211        $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
 
  222        $USER_ID = $user2->getId();
 
  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()));
 
  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);
 
  242        $this->assertEquals(
null, $node2_progress->getCompletionBy());
 
  243        $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
 
  254        $USER_ID = $user2->getId();
 
  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);
 
  274        $USER_ID = $user2->getId();
 
  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);
 
  285        $node2_progress->markNotFailed($USER_ID);
 
  298        $USER_ID = $user2->getId();
 
  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);
 
  309        $this->assertEquals($USER_ID, $node2_progress->getCompletionBy());
 
  310        $this->assertLessThanOrEqual($ts_before_change, $ts_after_change);
 
  311        $this->assertTrue($node2_progress->hasIndividualModifications());
 
  323        $this->root->addNode($node3);
 
  325        $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
 
  326        $this->assertNotNull($node3_progress);
 
  338        $NEW_AMOUNT_OF_POINTS_1 = 205;
 
  341        $node2_progress1 = array_shift($this->node2->getProgressesOf($user1->getId()));
 
  342        $node2_progress1->setRequiredAmountOfPoints($NEW_AMOUNT_OF_POINTS_1, $this->
user->getId());
 
  344        $this->assertEquals($NEW_AMOUNT_OF_POINTS_1, $node2_progress1->getAmountOfPoints());
 
  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()));
 
  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()));
 
  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()));
 
  390        $this->assertTrue($root_progress->canBeCompleted());
 
  391        $this->assertTrue($node1_progress->canBeCompleted());
 
  392        $this->assertTrue($node2_progress->canBeCompleted());
 
  397        $NEW_AMOUNT_OF_POINTS = 3003;
 
  401        $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
 
  407        $this->assertLessThan($NEW_AMOUNT_OF_POINTS, $this->node1->getPoints() + $this->node2->getPoints());
 
  409        $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
 
  410        $this->assertFalse($root_progress->canBeCompleted());
 
  415        $NEW_AMOUNT_OF_POINTS = 3003;
 
  420        $this->root->addNode($node3);
 
  421        $node3->setPoints($NEW_AMOUNT_OF_POINTS)
 
  430        $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
 
  431        $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
 
  433        $this->assertFalse($root_progress->canBeCompleted());
 
  434        $this->assertFalse($node3_progress->canBeCompleted());
 
  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);
 
  462        $NEW_AMOUNT_OF_POINTS = 201;
 
  465        $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
 
  468        $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
 
  481        $NEW_AMOUNT_OF_POINTS = 202;
 
  484        $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
 
  487        $ass->updateFromProgram();
 
  488        $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
 
  489        $this->assertEquals($NEW_AMOUNT_OF_POINTS, $root_progress->getAmountOfPoints());
 
  502        $NEW_AMOUNT_OF_POINTS = 203;
 
  505        $this->root->setPoints($NEW_AMOUNT_OF_POINTS)
 
  508        $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
 
  509        $ass->updateFromProgram();
 
  510        $this->assertEquals($NEW_AMOUNT_OF_POINTS, $root_progress->getAmountOfPoints());
 
  527        $NEW_AMOUNT_OF_POINTS_1 = 205;
 
  529        $NEW_AMOUNT_OF_POINTS_2 = 206;
 
  531        $this->assertNotEquals($NEW_AMOUNT_OF_POINTS_1, $NEW_AMOUNT_OF_POINTS_2);
 
  533        $node2_progress1 = array_shift($this->node2->getProgressesOf($user1->getId()));
 
  534        $node2_progress2 = array_shift($this->node2->getProgressesOf($user2->getId()));
 
  536        $node2_progress1->setRequiredAmountOfPoints($NEW_AMOUNT_OF_POINTS_1, $this->
user->getId());
 
  538        $this->node2->setPoints($NEW_AMOUNT_OF_POINTS_2)
 
  540        $this->root->updateAllAssignments();
 
  542        $this->assertEquals($NEW_AMOUNT_OF_POINTS_1, $node2_progress1->getAmountOfPoints());
 
  543        $this->assertEquals($NEW_AMOUNT_OF_POINTS_2, $node2_progress2->getAmountOfPoints());
 
  560        $progress = $this->node1->getProgressForAssignment($ass1->getId());
 
  562        $progress->markAccredited($this->
user->getId());
 
  574        $progress = $this->node1->getProgressForAssignment($ass1->getId());
 
  575        $this->assertFalse($progress->hasIndividualModifications());
 
  585        $progress = $this->node1->getProgressForAssignment($ass1->getId());
 
  586        $progress->setRequiredAmountOfPoints(1000, $this->
user->getId());
 
  587        $this->assertTrue($progress->hasIndividualModifications());
 
  597        $progress = $this->node1->getProgressForAssignment($ass1->getId());
 
  598        $progress->markNotRelevant($this->
user->getId());
 
  599        $this->assertTrue($progress->hasIndividualModifications());
 
  609        $progress = $this->node1->getProgressForAssignment($ass1->getId());
 
  610        $progress->markAccredited($this->
user->getId());
 
  611        $this->assertFalse($progress->hasIndividualModifications());
 
  622        $USER_ID = $user2->getId();
 
  624        $this->node1->setTitle(
"node1");
 
  625        $this->node1->update();
 
  626        $this->node2->setTitle(
"node2");
 
  627        $this->node2->update();
 
  629        $names = $this->root->getProgressForAssignment($ass->getId())
 
  630                    ->getNamesOfCompletedOrAccreditedChildren();
 
  631        $this->assertEquals(
$names, array());
 
  633        $this->node1->getProgressForAssignment($ass->getId())->markAccredited($USER_ID);
 
  634        $names = $this->root->getProgressForAssignment($ass->getId())
 
  635                    ->getNamesOfCompletedOrAccreditedChildren();
 
  636        $this->assertEquals(
$names, array(
"node1"));
 
  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"));
 
  650        $depth1->putInTree(ROOT_FOLDER_ID);
 
  651        $depth1->addNode($depth2);
 
  652        $depth2->addNode($depth3);
 
  653        $depth3->addNode($depth4);
 
  661        $assignment = $depth1->assignUser($user->getId());
 
  662        $progress4 = $depth4->getProgressForAssignment($assignment->getId());
 
  663        $progress4->markAccredited(6);
 
  665        $progress1 = $depth1->getProgressForAssignment($assignment->getId());
 
  666        $progress2 = $depth2->getProgressForAssignment($assignment->getId());
 
  667        $progress3 = $depth3->getProgressForAssignment($assignment->getId());
 
  669        $this->assertTrue($progress1->isSuccessful());
 
  670        $this->assertTrue($progress2->isSuccessful());
 
  671        $this->assertTrue($progress3->isSuccessful());
 
  672        $this->assertTrue($progress4->isSuccessful());
 
  750        $inst = $sp_user_progress_db->getInstance(
 
  752            $this->root->getId(),
 
  755        $this->assertInstanceOf(ilStudyProgrammeUserProgress::class, $inst);
 
  757            $this->root->getProgressesOf($user->getId()),
 
  758            $sp_user_progress_db->getInstancesForUser($this->root->getId(), $user->getId())
 
  761        $up = $this->root->getProgressesOf($user->getId())[0];
 
  764            $sp_user_progress_db->getInstanceById($up->getId())
 
  772            $sp_user_progress_db->getInstanceById(-1);
 
  773            $this->assertFalse(
"This should not happen");
 
  775            $this->assertTrue(
true);
 
  780            $sp_user_progress_db->getInstancesForAssignment(-1);
 
  781            $this->assertFalse(
"This should not happen");
 
  783            $this->assertTrue(
true);
 
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Exception is thrown when a progress for some programme node and assignment is missing.
const STATUS_NOT_RELEVANT
Storage implementation for ilStudyProgrammeUserProgress.
TestCase for the progress of users at a programme.
testHasDeviationToProgram1()
testHasDeviationToProgram3()
testOutdatedNodesCantBeSetToRelevant()
QUA-Objekte, welche "Inaktiv" sind können bei Studierenden-Studienplänen nicht von "nicht relevant" a...
testGetNamesOfCompletedOrAccreditedChildren()
testHasDeviationToProgram2()
testNoImplicitPointUpdate()
testNewNodesAreNotRelevant()
testHasDeviationToProgram4()
testExplicitPointUpdate2()
testIndividualRequiredPoints()
testInitialProgressDraft()
testInitialProgressActive()
testExplicitPointUpdate1()
testMaximimPossibleAmountOfPoints1()
testNoUpdateOnModifiedNodes()
testCompletionOnDeeplyNestedProgresses()
testInitialProgressOutdated()
testUserDeletionDeletesAssignments()
testMaximimPossibleAmountOfPoints2()
const ACTION_SHOW_INDIVIDUAL_PLAN
const ACTION_MARK_ACCREDITED
static getPossibleActions($a_node_id, $a_root_prg_id, $a_status)
Get a list with possible actions on a progress record.
const ACTION_UNMARK_ACCREDITED