ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCourseAppEventListener Class Reference

Course Pool listener. More...

+ Collaboration diagram for ilCourseAppEventListener:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getLogger ()
 

Static Public Member Functions

static initializeTimings ($a_obj_id, $a_usr_id, $a_role_id)
 initialize timings More...
 
static destroyTimings ($a_obj_id, $a_usr_id)
 Delete timings for user. More...
 
static handleEvent ($a_component, $a_event, $a_parameter)
 Handle an event in a listener. More...
 
static setBlockedForLP ($a_status)
 Toggle LP blocking property status. More...
 

Protected Member Functions

 handleUserAssignments ($a_event, $a_parameters)
 handle user assignments More...
 
 doAutoFill ($a_obj_id)
 Trigger autofill from waiting list. More...
 

Static Protected Attributes

static $timings_mode = null
 
static $course_mode = array()
 
static $blocked_for_lp
 

Private Attributes

 $logger = null
 

Detailed Description

Course Pool listener.

Listens to events of other components.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilCourseAppEventListener.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseAppEventListener::__construct ( )

Constructor.

Definition at line 24 of file class.ilCourseAppEventListener.php.

References ilLoggerFactory\getInstance().

25  {
26  $this->logger = ilLoggerFactory::getInstance()->getLogger('crs');
27  }
+ Here is the call graph for this function:

Member Function Documentation

◆ destroyTimings()

static ilCourseAppEventListener::destroyTimings (   $a_obj_id,
  $a_usr_id 
)
static

Delete timings for user.

Parameters
int$a_obj_id
int$a_usr_id
Returns
boolean

Definition at line 128 of file class.ilCourseAppEventListener.php.

References ilTimingsUser\getInstanceByContainerId().

129  {
130  include_once './Modules/Course/classes/Timings/class.ilTimingsUser.php';
131  $user_timings = ilTimingsUser::getInstanceByContainerId($a_obj_id);
132  $user_timings->init();
133  $user_timings->handleUnsubscribe($a_usr_id);
134  return true;
135  }
static getInstanceByContainerId($a_container_obj_id)
Get instance by container id.
+ Here is the call graph for this function:

◆ doAutoFill()

ilCourseAppEventListener::doAutoFill (   $a_obj_id)
protected

Trigger autofill from waiting list.

Parameters
int$a_obj_id

Definition at line 79 of file class.ilCourseAppEventListener.php.

References $factory, ilObject\_getAllReferences(), and getLogger().

80  {
81  $this->getLogger()->debug('Handling event deassign user -> waiting list auto fill');
82 
83  // #16694
84  include_once("./Modules/Course/classes/class.ilObjCourse.php");
85  $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
86 
87  include_once './Services/Object/classes/class.ilObjectFactory.php';
88  $factory = new ilObjectFactory();
89 
90  $course = $factory->getInstanceByRefId($ref_id, false);
91  if (!$course instanceof ilObjCourse) {
92  $this->getLogger()->warning('Cannot handle event deassign user since passed obj_id is not of type course: ' . $a_obj_id);
93  }
94 
95  $course->handleAutoFill();
96  }
Class ilObjectFactory.
$factory
Definition: metadata.php:43
static _getAllReferences($a_id)
get all reference ids of object
Class ilObjCourse.
+ Here is the call graph for this function:

◆ getLogger()

ilCourseAppEventListener::getLogger ( )
Returns
ilLogger

Definition at line 32 of file class.ilCourseAppEventListener.php.

References $logger.

Referenced by doAutoFill(), and handleUserAssignments().

+ Here is the caller graph for this function:

◆ handleEvent()

static ilCourseAppEventListener::handleEvent (   $a_component,
  $a_event,
  $a_parameter 
)
static

Handle an event in a listener.

Parameters
string$a_componentcomponent, e.g. "Modules/Forum" or "Services/User"
string$a_eventevent e.g. "createUser", "updateUser", "deleteUser", ...
array$a_parameterparameter array (assoc), array("name" => ..., "phone_office" => ...)

Definition at line 146 of file class.ilCourseAppEventListener.php.

References ilObjUserTracking\_enabledLearningProgress(), ilObject\_lookupType(), ilObjectLP\getInstance(), ilLPObjSettings\LP_MODE_COLLECTION, ilLPObjSettings\LP_MODE_MANUAL_BY_TUTOR, ilLPObjSettings\LP_MODE_OBJECTIVES, ilLPStatus\LP_STATUS_COMPLETED_NUM, and ilObjCourse\STATUS_DETERMINATION_LP.

147  {
148  if ($a_component == 'Services/AccessControl') {
149  $listener = new self();
150  $listener->handleUserAssignments($a_event, $a_parameter);
151  }
152 
153  switch ($a_component) {
154  case 'Modules/Course':
155  if ($a_event == 'addParticipant') {
156  self::initializeTimings($a_parameter['obj_id'], $a_parameter['usr_id'], $a_parameter['role_id']);
157  return true;
158  }
159  if ($a_event == 'deleteParticipant') {
160  self::destroyTimings($a_parameter['obj_id'], $a_parameter['usr_id']);
161  return true;
162  }
163  break;
164  }
165 
166  if ($a_component == "Services/Tracking" && $a_event == "updateStatus") {
167  // see ilObjCourseGUI::updateLPFromStatus()
168  if ((bool) self::$blocked_for_lp) {
169  return;
170  }
171 
172  // #13905
173  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
175  return;
176  }
177 
178  $obj_id = $a_parameter["obj_id"];
179  $user_id = $a_parameter["usr_id"];
180  $status = $a_parameter["status"];
181 
182  if ($obj_id && $user_id) {
183  if (ilObject::_lookupType($obj_id) != "crs") {
184  return;
185  }
186 
187  // determine couse setting only once
188  if (!isset(self::$course_mode[$obj_id])) {
189  include_once("./Modules/Course/classes/class.ilObjCourse.php");
190  $crs = new ilObjCourse($obj_id, false);
191  if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) {
192  include_once './Services/Object/classes/class.ilObjectLP.php';
193  $olp = ilObjectLP::getInstance($obj_id);
194  $mode = $olp->getCurrentMode();
195  } else {
196  $mode = false;
197  }
198  self::$course_mode[$obj_id] = $mode;
199  }
200 
201  $is_completed = ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM);
202 
203  // we are NOT using the members object because of performance issues
204  switch (self::$course_mode[$obj_id]) {
206  // #11600
207  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
208  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
209  break;
210 
213  // overwrites course passed status if it was set automatically (full sync)
214  // or toggle manually set passed status to completed (1-way-sync)
215  $do_update = $is_completed;
216  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
217  if (!$do_update) {
218  $part = new ilCourseParticipants($obj_id);
219  $passed = $part->getPassedInfo($user_id);
220  if (!is_array($passed) ||
221  $passed["user_id"] == -1) {
222  $do_update = true;
223  }
224  }
225  if ($do_update) {
226  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
227  }
228  break;
229  }
230  }
231  }
232  }
const LP_STATUS_COMPLETED_NUM
const STATUS_DETERMINATION_LP
static _enabledLearningProgress()
check wether learing progress is enabled or not
Class ilObjCourse.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ handleUserAssignments()

ilCourseAppEventListener::handleUserAssignments (   $a_event,
  $a_parameters 
)
protected

handle user assignments

Parameters
type$a_event
type$a_parameters

Definition at line 42 of file class.ilCourseAppEventListener.php.

References ilLoggerFactory\getInstance(), getLogger(), and ilParticipant\updateMemberRoles().

43  {
44  if ($a_parameters['type'] != 'crs') {
45  $this->getLogger()->debug('Ignoring event for type ' . $a_parameters['type']);
46  return true;
47  }
48 
49  if ($a_event == 'assignUser') {
50  $this->getLogger()->debug('Handling assign user event for type crs.');
51  $new_status = 1;
52  } elseif ($a_event == 'deassignUser') {
53  $this->getLogger()->debug('Handling assign user event for type crs.');
54  $new_status = 0;
55  }
56 
57  ilLoggerFactory::getInstance()->getLogger('crs')->debug(print_r($a_parameters, true));
58  ilLoggerFactory::getInstance()->getLogger('crs')->debug(print_r($new_status, true));
59 
60  include_once './Modules/Course/classes/class.ilCourseParticipant.php';
62  $a_parameters['obj_id'],
63  $a_parameters['usr_id'],
64  $a_parameters['role_id'],
65  $new_status
66  );
67 
68  if ($a_event == 'deassignUser') {
69  $self = new self();
70  $self->doAutoFill($a_parameters['obj_id']);
71  }
72  }
static updateMemberRoles($a_obj_id, $a_usr_id, $a_role_id, $a_status)
Update member roles ilDB $ilDB.
+ Here is the call graph for this function:

◆ initializeTimings()

static ilCourseAppEventListener::initializeTimings (   $a_obj_id,
  $a_usr_id,
  $a_role_id 
)
static

initialize timings

Definition at line 101 of file class.ilCourseAppEventListener.php.

References ilTimingsUser\getInstanceByContainerId(), IL_CAL_UNIX, ilCourseConstants\IL_CRS_VIEW_TIMING_RELATIVE, and ilObjCourse\lookupTimingMode().

102  {
103  static $timing_mode = array();
104 
105  if (!array_key_exists($a_obj_id, $timing_mode)) {
106  $timing_mode[$a_obj_id] = (
108  true :
109  false
110  );
111  }
112  if (!$timing_mode[$a_obj_id]) {
113  return true;
114  }
115 
116  $user_timings = ilTimingsUser::getInstanceByContainerId($a_obj_id);
117  $user_timings->init();
118  $user_timings->handleNewMembership($a_usr_id, new ilDateTime(time(), IL_CAL_UNIX));
119  return true;
120  }
static getInstanceByContainerId($a_container_obj_id)
Get instance by container id.
static lookupTimingMode($a_obj_id)
const IL_CAL_UNIX
Date and time handling
+ Here is the call graph for this function:

◆ setBlockedForLP()

static ilCourseAppEventListener::setBlockedForLP (   $a_status)
static

Toggle LP blocking property status.

Parameters
bool$a_status

Definition at line 239 of file class.ilCourseAppEventListener.php.

Referenced by ilObjCourseGUI\updateLPFromStatus().

240  {
241  self::$blocked_for_lp = (bool) $a_status;
242  }
+ Here is the caller graph for this function:

Field Documentation

◆ $blocked_for_lp

ilCourseAppEventListener::$blocked_for_lp
staticprotected

Definition at line 19 of file class.ilCourseAppEventListener.php.

◆ $course_mode

ilCourseAppEventListener::$course_mode = array()
staticprotected

Definition at line 18 of file class.ilCourseAppEventListener.php.

◆ $logger

ilCourseAppEventListener::$logger = null
private

Definition at line 14 of file class.ilCourseAppEventListener.php.

Referenced by getLogger().

◆ $timings_mode

ilCourseAppEventListener::$timings_mode = null
staticprotected

Definition at line 16 of file class.ilCourseAppEventListener.php.


The documentation for this class was generated from the following file: