ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCourseAppEventListener Class Reference

Course Pool listener. 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 Member Functions

static awardCertificate (int $a_obj_id, int $a_usr_id)
 

Static Protected Attributes

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

Private Attributes

ilLogger $logger
 

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 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: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ awardCertificate()

static ilCourseAppEventListener::awardCertificate ( int  $a_obj_id,
int  $a_usr_id 
)
staticprotected

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

References $DIC, Vendor\Package\$e, ilLogLevel\DEBUG, ilLogger\logStack(), and ilLogger\warning().

125  : void
126  {
127  global $DIC;
128 
129  $logger = $DIC->logger('crs');
130  if (!$DIC->certificate()->userCertificates()->isActiveCertificateTemplateAvailableFor($a_obj_id)) {
131  return;
132  }
133  try {
134  $DIC->certificate()->userCertificates()->certificateCriteriaMet(
135  $a_usr_id,
136  $a_obj_id
137  );
138  } catch (Exception $e) {
139  $logger->warning($e->getMessage());
141  }
142  }
logStack(?int $level=null, string $message='', array $context=[])
warning(string $message, array $context=[])
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ 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:65
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 144 of file class.ilCourseAppEventListener.php.

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

144  : void
145  {
146  if ($a_component == 'components/ILIAS/AccessControl') {
147  $listener = new self();
148  $listener->handleUserAssignments($a_event, $a_parameter);
149  }
150 
151  switch ($a_component) {
152  case 'components/ILIAS/Course':
153  if ($a_event == 'addParticipant') {
154  self::initializeTimings($a_parameter['obj_id'], $a_parameter['usr_id'], $a_parameter['role_id']);
155  return;
156  }
157  if ($a_event == 'deleteParticipant') {
158  self::destroyTimings($a_parameter['obj_id'], $a_parameter['usr_id']);
159  return;
160  }
161  if ($a_event === 'participantHasPassedCourse' && !ilObjUserTracking::_enabledLearningProgress()) {
162  self::awardCertificate($a_parameter['obj_id'], $a_parameter['usr_id']);
163  }
164  break;
165  }
166 
167  if ($a_component == "components/ILIAS/Tracking" && $a_event == "updateStatus") {
168  // see ilObjCourseGUI::updateLPFromStatus()
169  if (self::$blocked_for_lp) {
170  return;
171  }
172 
173  // #13905
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  $crs = new ilObjCourse($obj_id, false);
190  if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) {
191  $olp = ilObjectLP::getInstance($obj_id);
192  $mode = $olp->getCurrentMode();
193  } else {
194  $mode = false;
195  }
196  self::$course_mode[$obj_id] = $mode;
197  }
198 
199  $is_completed = ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM);
200 
201  // we are NOT using the members object because of performance issues
202  switch (self::$course_mode[$obj_id]) {
204  // #11600
205  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
206  break;
207 
210  // overwrites course passed status if it was set automatically (full sync)
211  // or toggle manually set passed status to completed (1-way-sync)
212  $do_update = $is_completed;
213  if (!$do_update) {
214  $part = new ilCourseParticipants($obj_id);
215  $passed = $part->getPassedInfo($user_id);
216  if (
217  !is_array($passed) ||
218  ((int) ($passed["user_id"] ?? 0)) === -1) {
219  $do_update = true;
220  }
221  }
222  if ($do_update) {
223  ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
224  }
225  break;
226  }
227  }
228  }
229  }
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 234 of file class.ilCourseAppEventListener.php.

Referenced by ilObjCourseGUI\updateLPFromStatus().

234  : void
235  {
236  self::$blocked_for_lp = $a_status;
237  }
+ 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: