ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

23 {
24 $this->logger = ilLoggerFactory::getInstance()->getLogger('crs');
25 }

References ilLoggerFactory\getInstance().

+ 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 77 of file class.ilCourseAppEventListener.php.

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

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

+ Here is the call graph for this function:

◆ getLogger()

ilCourseAppEventListener::getLogger ( )
Returns
ilLogger

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

104 {
105 if ($a_component == 'Services/AccessControl') {
106 $listener = new self();
107 $listener->handleUserAssignments($a_event, $a_parameter);
108 }
109
110 if ($a_component == "Services/Tracking" && $a_event == "updateStatus") {
111 // see ilObjCourseGUI::updateLPFromStatus()
112 if ((bool) self::$blocked_for_lp) {
113 return;
114 }
115
116 // #13905
117 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
119 return;
120 }
121
122 $obj_id = $a_parameter["obj_id"];
123 $user_id = $a_parameter["usr_id"];
124 $status = $a_parameter["status"];
125
126 if ($obj_id && $user_id) {
127 if (ilObject::_lookupType($obj_id) != "crs") {
128 return;
129 }
130
131 // determine couse setting only once
132 if (!isset(self::$course_mode[$obj_id])) {
133 include_once("./Modules/Course/classes/class.ilObjCourse.php");
134 $crs = new ilObjCourse($obj_id, false);
135 if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) {
136 include_once './Services/Object/classes/class.ilObjectLP.php';
137 $olp = ilObjectLP::getInstance($obj_id);
138 $mode = $olp->getCurrentMode();
139 } else {
140 $mode = false;
141 }
142 self::$course_mode[$obj_id] = $mode;
143 }
144
145 $is_completed = ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM);
146
147 // we are NOT using the members object because of performance issues
148 switch (self::$course_mode[$obj_id]) {
150 // #11600
151 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
152 ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
153 break;
154
157 // overwrites course passed status if it was set automatically (full sync)
158 // or toggle manually set passed status to completed (1-way-sync)
159 $do_update = $is_completed;
160 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
161 if (!$do_update) {
162 $part = new ilCourseParticipants($obj_id);
163 $passed = $part->getPassedInfo($user_id);
164 if (!is_array($passed) ||
165 $passed["user_id"] == -1) {
166 $do_update = true;
167 }
168 }
169 if ($do_update) {
170 ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
171 }
172 break;
173 }
174 }
175 }
176 }
const LP_STATUS_COMPLETED_NUM
const STATUS_DETERMINATION_LP
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getInstance($a_obj_id)
static _lookupType($a_id, $a_reference=false)
lookup object type

References $blocked_for_lp, 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.

+ 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 40 of file class.ilCourseAppEventListener.php.

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

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

+ 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 183 of file class.ilCourseAppEventListener.php.

184 {
185 self::$blocked_for_lp = (bool) $a_status;
186 }

Referenced by ilObjCourseGUI\updateLPFromStatus().

+ 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.

Referenced by handleEvent().

◆ $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: