ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCourseAppEventListener Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCourseAppEventListener:

Public Member Functions

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

Static Public Member Functions

static initializeTimings (int $a_obj_id, int $a_usr_id, int $a_role_id)
 
static destroyTimings (int $a_obj_id, int $a_usr_id)
 Delete timings for user. More...
 
static handleEvent (string $a_component, string $a_event, array $a_parameter)
 
static setBlockedForLP (bool $a_status)
 Toggle LP blocking property status. More...
 

Protected Member Functions

 handleUserAssignments (string $a_event, array $a_parameters)
 
 doAutoFill (int $a_obj_id)
 Trigger autofill from waiting list. More...
 

Static Protected Attributes

static array $course_mode = array()
 
static bool $blocked_for_lp = false
 

Private Attributes

ilLogger $logger
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 27 of file class.ilCourseAppEventListener.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseAppEventListener::__construct ( )

Constructor PhpUndefinedMethodInspection.

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

References $DIC, and ILIAS\Repository\logger().

39  {
40  global $DIC;
41  $this->logger = $DIC->logger()->crs();
42  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ destroyTimings()

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

Delete timings for user.

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

References ilTimingsUser\getInstanceByContainerId().

117  : bool
118  {
119  $user_timings = ilTimingsUser::getInstanceByContainerId($a_obj_id);
120  $user_timings->init();
121  $user_timings->handleUnsubscribe($a_usr_id);
122  return true;
123  }
static getInstanceByContainerId(int $a_container_obj_id)
+ Here is the call graph for this function:

◆ doAutoFill()

ilCourseAppEventListener::doAutoFill ( int  $a_obj_id)
protected

Trigger autofill from waiting list.

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

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

83  : void
84  {
85  $this->getLogger()->debug('Handling event deassign user -> waiting list auto fill');
86 
87  // #16694
88  $refs = ilObject::_getAllReferences($a_obj_id);
89  $ref_id = array_pop($refs);
90 
92  if (!$course instanceof ilObjCourse) {
93  $this->getLogger()->warning('Cannot handle event deassign user since passed obj_id is not of type course: ' . $a_obj_id);
94  }
95  $course->handleAutoFill();
96  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getLogger()

ilCourseAppEventListener::getLogger ( )

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

References $logger.

Referenced by doAutoFill(), and handleUserAssignments().

44  : ilLogger
45  {
46  return $this->logger;
47  }
+ Here is the caller graph for this function:

◆ handleEvent()

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

Definition at line 125 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.

125  : void
126  {
127  if ($a_component == 'Services/AccessControl') {
128  $listener = new self();
129  $listener->handleUserAssignments($a_event, $a_parameter);
130  }
131 
132  switch ($a_component) {
133  case 'Modules/Course':
134  if ($a_event == 'addParticipant') {
135  self::initializeTimings($a_parameter['obj_id'], $a_parameter['usr_id'], $a_parameter['role_id']);
136  return;
137  }
138  if ($a_event == 'deleteParticipant') {
139  self::destroyTimings($a_parameter['obj_id'], $a_parameter['usr_id']);
140  return;
141  }
142  break;
143  }
144 
145  if ($a_component == "Services/Tracking" && $a_event == "updateStatus") {
146  // see ilObjCourseGUI::updateLPFromStatus()
147  if (self::$blocked_for_lp) {
148  return;
149  }
150 
151  // #13905
153  return;
154  }
155 
156  $obj_id = $a_parameter["obj_id"];
157  $user_id = $a_parameter["usr_id"];
158  $status = $a_parameter["status"];
159 
160  if ($obj_id && $user_id) {
161  if (ilObject::_lookupType($obj_id) != "crs") {
162  return;
163  }
164 
165  // determine couse setting only once
166  if (!isset(self::$course_mode[$obj_id])) {
167  $crs = new ilObjCourse($obj_id, false);
168  if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) {
169  $olp = ilObjectLP::getInstance($obj_id);
170  $mode = $olp->getCurrentMode();
171  } else {
172  $mode = false;
173  }
174  self::$course_mode[$obj_id] = $mode;
175  }
176 
177  $is_completed = ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM);
178 
179  // we are NOT using the members object because of performance issues
180  switch (self::$course_mode[$obj_id]) {
182  // #11600
183  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
184  break;
185 
188  // overwrites course passed status if it was set automatically (full sync)
189  // or toggle manually set passed status to completed (1-way-sync)
190  $do_update = $is_completed;
191  if (!$do_update) {
192  $part = new ilCourseParticipants($obj_id);
193  $passed = $part->getPassedInfo($user_id);
194  if (
195  !is_array($passed) ||
196  ((int) ($passed["user_id"] ?? 0)) === -1) {
197  $do_update = true;
198  }
199  }
200  if ($do_update) {
201  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
202  }
203  break;
204  }
205  }
206  }
207  }
const LP_STATUS_COMPLETED_NUM
const STATUS_DETERMINATION_LP
static _lookupType(int $id, bool $reference=false)
static getInstance(int $obj_id)
static _updatePassed(int $a_obj_id, int $a_usr_id, bool $a_passed, bool $a_manual=false, bool $a_no_origin=false)
+ Here is the call graph for this function:

◆ handleUserAssignments()

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

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

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

49  : void
50  {
51  if ($a_parameters['type'] != 'crs') {
52  $this->getLogger()->debug('Ignoring event for type ' . $a_parameters['type']);
53  return;
54  }
55  $new_status = 0;
56  if ($a_event == 'assignUser') {
57  $this->getLogger()->debug('Handling assign user event for type crs.');
58  $new_status = 1;
59  } elseif ($a_event == 'deassignUser') {
60  $this->getLogger()->debug('Handling assign user event for type crs.');
61  $new_status = 0;
62  }
63 
64  ilLoggerFactory::getInstance()->getLogger('crs')->debug(print_r($a_parameters, true));
65  ilLoggerFactory::getInstance()->getLogger('crs')->debug(print_r($new_status, true));
66 
68  $a_parameters['obj_id'],
69  $a_parameters['usr_id'],
70  $a_parameters['role_id'],
71  $new_status
72  );
73 
74  if ($a_event == 'deassignUser') {
75  $self = new self();
76  $self->doAutoFill($a_parameters['obj_id']);
77  }
78  }
static updateMemberRoles(int $a_obj_id, int $a_usr_id, int $a_role_id, int $a_status)
+ Here is the call graph for this function:

◆ initializeTimings()

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

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

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

98  : bool
99  {
100  static $timing_mode = array();
101 
102  if (!array_key_exists($a_obj_id, $timing_mode)) {
104  }
105  if (!$timing_mode[$a_obj_id]) {
106  return true;
107  }
108  $user_timings = ilTimingsUser::getInstanceByContainerId($a_obj_id);
109  $user_timings->init();
110  $user_timings->handleNewMembership($a_usr_id, new ilDateTime(time(), IL_CAL_UNIX));
111  return true;
112  }
static lookupTimingMode(int $a_obj_id)
static getInstanceByContainerId(int $a_container_obj_id)
const IL_CAL_UNIX
+ Here is the call graph for this function:

◆ setBlockedForLP()

static ilCourseAppEventListener::setBlockedForLP ( bool  $a_status)
static

Toggle LP blocking property status.

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

Referenced by ilObjCourseGUI\updateLPFromStatus().

212  : void
213  {
214  self::$blocked_for_lp = $a_status;
215  }
+ Here is the caller graph for this function:

Field Documentation

◆ $blocked_for_lp

bool ilCourseAppEventListener::$blocked_for_lp = false
staticprotected

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

◆ $course_mode

array ilCourseAppEventListener::$course_mode = array()
staticprotected

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

◆ $logger

ilLogger ilCourseAppEventListener::$logger
private

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

Referenced by getLogger().


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