ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
mocks.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 
12 require_once("Services/Tracking/classes/class.ilLPStatus.php");
13 
17 require_once("Modules/StudyProgramme/classes/interfaces/interface.ilStudyProgrammeLeaf.php");
18 require_once("Services/Object/classes/class.ilObject2.php");
19 
21 {
22  public function __construct($a_id = 0, $a_call_by_reference = true)
23  {
24  parent::__construct($a_id, $a_call_by_reference);
25  if ($a_id == 0) {
26  parent::create();
27  }
28  }
29 
30  // from ilObject2
31  public function initType()
32  {
33  $this->type = "crsr";
34  }
35 
36  // from ilStudyProgrammeLeaf
37  /*public function getParentId() {
38  global $DIC;
39  $tree = $DIC['tree'];
40  if (!$tree->isInTree($this->getRefId())) {
41  return null;
42  }
43 
44  $nd = $tree->getParentNodeData($this->getRefId());
45  return $nd["obj_id"];
46  }*/
47 
48  // Mark this leaf as completed for a user.
49  public function markCompletedFor($a_user_id)
50  {
51  global $DIC;
52  $ilAppEventHandler = $DIC['ilAppEventHandler'];
53 
54  $ilAppEventHandler->raise("Services/Tracking", "updateStatus", array(
55  "obj_id" => $this->getId(),
56  "usr_id" => $a_user_id,
58  "percentage" => 100
59  ));
60  }
61 }
62 
66 require_once("Modules/StudyProgramme/classes/class.ilObjectFactoryWrapper.php");
67 
69 {
70  public function getInstanceByRefId($a_ref_id, $stop_on_error = true)
71  {
72  if (ilObject::_lookupType($a_ref_id, true) == "mock") {
73  return new ilStudyProgrammeLeafMock($a_ref_id);
74  }
75  return ilObjectFactoryWrapper::singleton()->getInstanceByRefId($a_ref_id, $stop_on_error);
76  }
77 }
78 
83 {
84  public $events;
85 
86  public function __construct()
87  {
88  $this->events = array();
89  }
90 
91  public function raise($a_component, $a_event, $a_parameters)
92  {
93  $this->events[] = array( "component" => $a_component
94  , "event" => $a_event
95  , "parameters" => $a_parameters
96  );
97  }
98 }
const LP_STATUS_COMPLETED_NUM
The interface a class has to fullfill if it should be used as leaf in a program.
Mock classes for tests.
Definition: mocks.php:20
getInstanceByRefId($a_ref_id, $stop_on_error=true)
Definition: mocks.php:70
markCompletedFor($a_user_id)
Definition: mocks.php:49
__construct($a_id=0, $a_call_by_reference=true)
Definition: mocks.php:22
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilObjectFactoryWrapper.
Mock for ilAppEventHandler.
Definition: mocks.php:82
Class ilObject2 This is an intermediate progress of ilObject class.
global $DIC
getId()
Get the ILIAS object id of the leaf.
Mock for object factory.
Definition: mocks.php:68