ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCalendarScheduleFilterExercise Class Reference

Calendar schedule filter for exercises. More...

+ Inheritance diagram for ilCalendarScheduleFilterExercise:
+ Collaboration diagram for ilCalendarScheduleFilterExercise:

Public Member Functions

 __construct (int $a_user_id)
 
 getLogger ()
 
 filterCategories (array $a_cats)
 
 modifyEvent (ilCalendarEntry $a_event)
 
 addCustomEvents (ilDate $start, ilDate $end, array $a_categories)
 

Protected Member Functions

 isExerciseCategory ($a_cat_id)
 Check valid exercise calendar category. More...
 

Protected Attributes

int $user_id
 
ilLogger $logger
 

Detailed Description

Calendar schedule filter for exercises.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilCalendarScheduleFilterExercise.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarScheduleFilterExercise::__construct ( int  $a_user_id)

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

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

32  {
33  global $DIC;
34 
35  $this->user_id = $a_user_id;
36  $this->logger = $DIC->logger()->exc();
37  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomEvents()

ilCalendarScheduleFilterExercise::addCustomEvents ( ilDate  $start,
ilDate  $end,
array  $a_categories 
)

Implements ilCalendarScheduleFilter.

Definition at line 88 of file class.ilCalendarScheduleFilterExercise.php.

References $user_id, ilCalendarCategoryAssignments\_getAssignedAppointments(), ilDateTime\_within(), ilExAssignment\DEADLINE_RELATIVE, ilExcAssMemberState\getInstanceByIds(), ilExAssignment\getInstancesByExercise(), IL_CAL_UNIX, isExerciseCategory(), and null.

88  : array
89  {
90  $all_events = array();
91 
92  foreach ($a_categories as $cat_id) {
93  $cal_cat = $this->isExerciseCategory($cat_id);
94  if (!$cal_cat) {
95  continue;
96  }
97 
98  $exc_obj_id = $cal_cat->getObjId();
99 
100  $calc_dead = null;
101  foreach (ilExAssignment::getInstancesByExercise($exc_obj_id) as $ass) {
102  $idl = $ass->getPersonalDeadline($this->user_id);
103 
104  $has_individual_deadline = ($idl && $idl != $ass->getDeadline());
105  if ($has_individual_deadline) {
106  $idl = new ilDateTime($idl, IL_CAL_UNIX);
107  if (!ilDateTime::_within($idl, $start, $end)) {
108  $has_individual_deadline = false;
109  }
110  }
111  $has_relative_deadline = ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE);
112  if ($has_relative_deadline) {
113  $state = ilExcAssMemberState::getInstanceByIds($ass->getId(), $this->user_id);
114  $calculated_deadline = $state->getCalculatedDeadline();
115  if ($calculated_deadline) {
116  $calc_dead = new ilDateTime($calculated_deadline, IL_CAL_UNIX);
117  if (!ilDateTime::_within($calc_dead, $start, $end)) {
118  $has_relative_deadline = false;
119  }
120  } else {
121  $has_relative_deadline = false;
122  }
123  }
124 
125  if ($has_individual_deadline || $has_relative_deadline) {
126  $app_ids = ilCalendarCategoryAssignments::_getAssignedAppointments(array($cal_cat->getCategoryID()));
127  foreach ($app_ids as $app_id) {
128  $entry = new ilCalendarEntry($app_id);
129  if (!$entry->isAutoGenerated()) {
130  continue;
131  }
132  if ($entry->getContextId() == $ass->getId() . "0") {
133  if ($has_individual_deadline) {
134  $entry->setStart($idl);
135  $entry->setEnd($idl);
136  $all_events[] = $entry;
137  } elseif ($has_relative_deadline) {
138  $entry->setStart($calc_dead);
139  $entry->setEnd($calc_dead);
140  $all_events[] = $entry;
141  }
142  }
143  }
144  }
145  }
146  }
147  return $all_events;
148  }
const IL_CAL_UNIX
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
isExerciseCategory($a_cat_id)
Check valid exercise calendar category.
static getInstancesByExercise(int $a_exc_id)
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check whether an date is within a date duration given by start and end.
+ Here is the call graph for this function:

◆ filterCategories()

ilCalendarScheduleFilterExercise::filterCategories ( array  $a_cats)

Implements ilCalendarScheduleFilter.

Definition at line 47 of file class.ilCalendarScheduleFilterExercise.php.

47  : array
48  {
49  return $a_cats;
50  }

◆ getLogger()

ilCalendarScheduleFilterExercise::getLogger ( )

Definition at line 39 of file class.ilCalendarScheduleFilterExercise.php.

References $logger.

Referenced by isExerciseCategory().

+ Here is the caller graph for this function:

◆ isExerciseCategory()

ilCalendarScheduleFilterExercise::isExerciseCategory (   $a_cat_id)
protected

Check valid exercise calendar category.

Definition at line 153 of file class.ilCalendarScheduleFilterExercise.php.

References ilCalendarCategory\getInstanceByCategoryId(), getLogger(), null, and ilCalendarCategory\TYPE_OBJ.

Referenced by addCustomEvents(), and modifyEvent().

154  {
155  $category = ilCalendarCategory::getInstanceByCategoryId($a_cat_id);
156 
157  if ($category->getType() != ilCalendarCategory::TYPE_OBJ) {
158  $this->getLogger()->debug('Not modifying calendar for non object type');
159  return null;
160  }
161  if ($category->getObjType() != 'exc') {
162  $this->getLogger()->debug('Category object type is != folder => category event not modified');
163  return null;
164  }
165  return $category;
166  }
Stores calendar categories.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getInstanceByCategoryId(int $a_cat_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modifyEvent()

ilCalendarScheduleFilterExercise::modifyEvent ( ilCalendarEntry  $a_event)

Implements ilCalendarScheduleFilter.

Definition at line 55 of file class.ilCalendarScheduleFilterExercise.php.

References $ass_id, ilCalendarCategoryAssignments\_lookupCategory(), ilExAssignment\DEADLINE_RELATIVE, ilCalendarEntry\getContextId(), ilCalendarEntry\getEntryId(), ILIAS\Repository\int(), isExerciseCategory(), and null.

56  {
58  if ($cal_cat) {
59  $exc_obj_id = $cal_cat->getObjId();
60 
61  // see ilExAssignment::handleCalendarEntries()
62  $context_id = $a_event->getContextId();
63  $subtype = (int) substr((string) $context_id, -1);
64  $ass_id = (int) substr((string) $context_id, 0, -1);
65  // 1 is peer review deadline
66  if ($subtype != 1) {
67  $ass = new ilExAssignment($ass_id);
68  if ($ass->getExerciseId() == $exc_obj_id) {
69  $idl = $ass->getPersonalDeadline($this->user_id);
70  if ($idl &&
71  $idl != $ass->getDeadline()) {
72  // we have individal deadline (see addCustomEvents());
73  return null;
74  }
75  if ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
76  // we have relative deadline (see addCustomEvents());
77  return null;
78  }
79  }
80  }
81  }
82  return $a_event;
83  }
Exercise assignment.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isExerciseCategory($a_cat_id)
Check valid exercise calendar category.
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilCalendarScheduleFilterExercise::$logger
protected

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

Referenced by getLogger().

◆ $user_id

int ilCalendarScheduleFilterExercise::$user_id
protected

Definition at line 28 of file class.ilCalendarScheduleFilterExercise.php.

Referenced by addCustomEvents().


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