ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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 12 of file class.ilCalendarScheduleFilterExercise.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarScheduleFilterExercise::__construct ( int  $a_user_id)

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

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

18  {
19  global $DIC;
20 
21  $this->user_id = $a_user_id;
22  $this->logger = $DIC->logger()->exc();
23  }
global $DIC
Definition: feed.php:28
+ 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 74 of file class.ilCalendarScheduleFilterExercise.php.

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

74  : array
75  {
76  $all_events = array();
77 
78  foreach ($a_categories as $cat_id) {
79  $cal_cat = $this->isExerciseCategory($cat_id);
80  if (!$cal_cat) {
81  continue;
82  }
83 
84  $exc_obj_id = $cal_cat->getObjId();
85 
86  $calc_dead = null;
87  foreach (ilExAssignment::getInstancesByExercise($exc_obj_id) as $ass) {
88  $idl = $ass->getPersonalDeadline($this->user_id);
89 
90  $has_individual_deadline = ($idl && $idl != $ass->getDeadline());
91  if ($has_individual_deadline) {
92  $idl = new ilDateTime($idl, IL_CAL_UNIX);
93  if (!ilDateTime::_within($idl, $start, $end)) {
94  $has_individual_deadline = false;
95  }
96  }
97  $has_relative_deadline = ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE);
98  if ($has_relative_deadline) {
100  $calculated_deadline = $state->getCalculatedDeadline();
101  if ($calculated_deadline) {
102  $calc_dead = new ilDateTime($calculated_deadline, IL_CAL_UNIX);
103  if (!ilDateTime::_within($calc_dead, $start, $end)) {
104  $has_relative_deadline = false;
105  }
106  } else {
107  $has_relative_deadline = false;
108  }
109  }
110 
111  if ($has_individual_deadline || $has_relative_deadline) {
112  $app_ids = ilCalendarCategoryAssignments::_getAssignedAppointments(array($cal_cat->getCategoryID()));
113  foreach ($app_ids as $app_id) {
114  $entry = new ilCalendarEntry($app_id);
115  if (!$entry->isAutoGenerated()) {
116  continue;
117  }
118  if ($entry->getContextId() == $ass->getId() . "0") {
119  if ($has_individual_deadline) {
120  $entry->setStart($idl);
121  $entry->setEnd($idl);
122  $all_events[] = $entry;
123  } elseif ($has_relative_deadline) {
124  $entry->setStart($calc_dead);
125  $entry->setEnd($calc_dead);
126  $all_events[] = $entry;
127  }
128  }
129  }
130  }
131  }
132  }
133  return $all_events;
134  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
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 33 of file class.ilCalendarScheduleFilterExercise.php.

33  : array
34  {
35  return $a_cats;
36  }

◆ getLogger()

ilCalendarScheduleFilterExercise::getLogger ( )

Definition at line 25 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 139 of file class.ilCalendarScheduleFilterExercise.php.

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

Referenced by addCustomEvents(), and modifyEvent().

140  {
141  $category = ilCalendarCategory::getInstanceByCategoryId($a_cat_id);
142 
143  if ($category->getType() != ilCalendarCategory::TYPE_OBJ) {
144  $this->getLogger()->debug('Not modifying calendar for non object type');
145  return null;
146  }
147  if ($category->getObjType() != 'exc') {
148  $this->getLogger()->debug('Category object type is != folder => category event not modified');
149  return null;
150  }
151  return $category;
152  }
Stores calendar categories.
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 41 of file class.ilCalendarScheduleFilterExercise.php.

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

42  {
44  if ($cal_cat) {
45  $exc_obj_id = $cal_cat->getObjId();
46 
47  // see ilExAssignment::handleCalendarEntries()
48  $context_id = $a_event->getContextId();
49  $subtype = (int) substr((string) $context_id, -1);
50  $ass_id = (int) substr((string) $context_id, 0, -1);
51  // 1 is peer review deadline
52  if ($subtype != 1) {
53  $ass = new ilExAssignment($ass_id);
54  if ($ass->getExerciseId() == $exc_obj_id) {
55  $idl = $ass->getPersonalDeadline($this->user_id);
56  if ($idl &&
57  $idl != $ass->getDeadline()) {
58  // we have individal deadline (see addCustomEvents());
59  return null;
60  }
61  if ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
62  // we have relative deadline (see addCustomEvents());
63  return null;
64  }
65  }
66  }
67  }
68  return $a_event;
69  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Exercise assignment.
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 15 of file class.ilCalendarScheduleFilterExercise.php.

Referenced by getLogger().

◆ $user_id

int ilCalendarScheduleFilterExercise::$user_id
protected

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

Referenced by addCustomEvents().


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