ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCourseAppEventListener Class Reference

Course Pool listener. More...

+ Collaboration diagram for ilCourseAppEventListener:

Public Member Functions

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

Static Public Member Functions

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 $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 22 of file class.ilCourseAppEventListener.php.

References ilLoggerFactory\getInstance().

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

Member Function Documentation

◆ doAutoFill()

ilCourseAppEventListener::doAutoFill (   $a_obj_id)
protected

Trigger autofill from waiting list.

Parameters
int$a_obj_id

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

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

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

◆ getLogger()

ilCourseAppEventListener::getLogger ( )
Returns
ilLogger

Definition at line 31 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 110 of file class.ilCourseAppEventListener.php.

References ilObjUserTracking\_enabledLearningProgress(), ilObject\_lookupType(), ilCourseParticipants\_updatePassed(), 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.

111  {
112  if($a_component == 'Services/AccessControl')
113  {
114  $listener = new self();
115  $listener->handleUserAssignments($a_event, $a_parameter);
116  }
117 
118  if($a_component == "Services/Tracking" && $a_event == "updateStatus")
119  {
120  // see ilObjCourseGUI::updateLPFromStatus()
121  if((bool)self::$blocked_for_lp)
122  {
123  return;
124  }
125 
126  // #13905
127  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
129  {
130  return;
131  }
132 
133  $obj_id = $a_parameter["obj_id"];
134  $user_id = $a_parameter["usr_id"];
135  $status = $a_parameter["status"];
136 
137  if($obj_id && $user_id)
138  {
139  if (ilObject::_lookupType($obj_id) != "crs")
140  {
141  return;
142  }
143 
144  // determine couse setting only once
145  if(!isset(self::$course_mode[$obj_id]))
146  {
147  include_once("./Modules/Course/classes/class.ilObjCourse.php");
148  $crs = new ilObjCourse($obj_id, false);
149  if($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP)
150  {
151  include_once './Services/Object/classes/class.ilObjectLP.php';
152  $olp = ilObjectLP::getInstance($obj_id);
153  $mode = $olp->getCurrentMode();
154  }
155  else
156  {
157  $mode = false;
158  }
159  self::$course_mode[$obj_id] = $mode;
160  }
161 
162  $is_completed = ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM);
163 
164  // we are NOT using the members object because of performance issues
165  switch(self::$course_mode[$obj_id])
166  {
168  // #11600
169  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
170  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
171  break;
172 
175  // overwrites course passed status if it was set automatically (full sync)
176  // or toggle manually set passed status to completed (1-way-sync)
177  $do_update = $is_completed;
178  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
179  if(!$do_update)
180  {
181  $part = new ilCourseParticipants($obj_id);
182  $passed = $part->getPassedInfo($user_id);
183  if(!is_array($passed) ||
184  $passed["user_id"] == -1)
185  {
186  $do_update = true;
187  }
188  }
189  if($do_update)
190  {
191  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
192  }
193  break;
194  }
195  }
196  }
197  }
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 _updatePassed($a_obj_id, $a_usr_id, $a_passed, $a_manual=false, $a_no_origin=false)
Update passed status (static)
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 41 of file class.ilCourseAppEventListener.php.

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

42  {
43  if($a_parameters['type'] != 'crs')
44  {
45  $this->getLogger()->debug('Ignoring event for type '. $a_parameters['type']);
46  return TRUE;
47  }
48 
49  if($a_event == 'assignUser')
50  {
51  $this->getLogger()->debug('Handling assign user event for type crs.');
52  $new_status = 1;
53  }
54  elseif($a_event == 'deassignUser')
55  {
56  $this->getLogger()->debug('Handling assign user event for type crs.');
57  $new_status = 0;
58  }
59 
60  ilLoggerFactory::getInstance()->getLogger('crs')->debug(print_r($a_parameters,TRUE));
61  ilLoggerFactory::getInstance()->getLogger('crs')->debug(print_r($new_status,TRUE));
62 
63  include_once './Modules/Course/classes/class.ilCourseParticipant.php';
65  $a_parameters['obj_id'],
66  $a_parameters['usr_id'],
67  $a_parameters['role_id'],
68  $new_status
69  );
70 
71  if($a_event == 'deassignUser')
72  {
73  $self = new self();
74  $self->doAutoFill($a_parameters['obj_id']);
75  }
76  }
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:

◆ setBlockedForLP()

static ilCourseAppEventListener::setBlockedForLP (   $a_status)
static

Toggle LP blocking property status.

Parameters
bool$a_status

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

Referenced by ilObjCourseGUI\updateLPFromStatus().

205  {
206  self::$blocked_for_lp = (bool)$a_status;
207  }
+ Here is the caller graph for this function:

Field Documentation

◆ $blocked_for_lp

ilCourseAppEventListener::$blocked_for_lp
staticprotected

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

◆ $course_mode

ilCourseAppEventListener::$course_mode = array()
staticprotected

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

◆ $logger

ilCourseAppEventListener::$logger = null
private

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

Referenced by getLogger().


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