ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCalendarScheduleFilterExercise Class Reference

Calendar schedule filter for exercises. More...

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

Public Member Functions

 __construct ($a_user_id)
 
 getLogger ()
 
 filterCategories (array $a_cats)
 
 modifyEvent (ilCalendarEntry $a_event)
 
 addCustomEvents (ilDate $start, ilDate $end, array $a_categories)
 
 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

 $user_id
 
 $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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarScheduleFilterExercise::__construct (   $a_user_id)

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

24 {
25 global $DIC;
26
27 $this->user_id = $a_user_id;
28 $this->logger = $DIC->logger()->exc();
29 }
global $DIC
Definition: saml.php:7

References $DIC.

Member Function Documentation

◆ addCustomEvents()

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

Implements ilCalendarScheduleFilter.

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

78 {
79 $all_events = array();
80
81 foreach ($a_categories as $cat_id) {
82 $cal_cat = $this->isExerciseCategory($cat_id);
83 if (!$cal_cat) {
84 continue;
85 }
86
87 $exc_obj_id = $cal_cat->getObjId();
88
89 include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
90 include_once './Modules/Exercise/classes/class.ilExAssignment.php';
91 foreach (ilExAssignment::getInstancesByExercise($exc_obj_id) as $ass) {
92 $idl = $ass->getPersonalDeadline($this->user_id);
93
94 $has_individual_deadline = ($idl && $idl != $ass->getDeadline());
95 if ($has_individual_deadline) {
96 $idl = new ilDateTime($idl, IL_CAL_UNIX);
97 if (!ilDateTime::_within($idl, $start, $end)) {
98 $has_individual_deadline = false;
99 }
100 }
101 $has_relative_deadline = ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE);
102 if ($has_relative_deadline) {
103 $state = ilExcAssMemberState::getInstanceByIds($ass->getId(), $this->user_id);
104 $calculated_deadline = $state->getCalculatedDeadline();
105 if ($calculated_deadline) {
106 $calc_dead = new ilDateTime($calculated_deadline, IL_CAL_UNIX);
107 if (!ilDateTime::_within($calc_dead, $start, $end)) {
108 $has_relative_deadline = false;
109 }
110 } else {
111 $has_relative_deadline = false;
112 }
113 }
114
115 if ($has_individual_deadline || $has_relative_deadline) {
116 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
117 $app_ids = ilCalendarCategoryAssignments::_getAssignedAppointments(array($cal_cat->getCategoryID()));
118 foreach ($app_ids as $app_id) {
119 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
120 $entry = new ilCalendarEntry($app_id);
121 if (!$entry->isAutoGenerated()) {
122 continue;
123 }
124 if ($entry->getContextId() == $ass->getId() . "0") {
125 if ($has_individual_deadline) {
126 $entry->setStart($idl);
127 $entry->setEnd($idl);
128 $all_events[] = $entry;
129 } elseif ($has_relative_deadline) {
130 $entry->setStart($calc_dead);
131 $entry->setEnd($calc_dead);
132 $all_events[] = $entry;
133 }
134 }
135 }
136 }
137 }
138 }
139
140 return $all_events;
141 }
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
const IL_CAL_UNIX
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
Model for a calendar entry.
isExerciseCategory($a_cat_id)
Check valid exercise calendar category.
@classDescription Date and time handling
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check whether an date is within a date duration given by start and end.
static getInstancesByExercise($a_exc_id)
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)
$start
Definition: bench.php:8

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

+ Here is the call graph for this function:

◆ filterCategories()

ilCalendarScheduleFilterExercise::filterCategories ( array  $a_cats)

Implements ilCalendarScheduleFilter.

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

40 {
41 return $a_cats;
42 }

◆ getLogger()

ilCalendarScheduleFilterExercise::getLogger ( )
Returns
\ilLogger

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

Parameters
int$a_cat_id
Returns
ilCalendarCategory

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

150 {
151 include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
152 $category = ilCalendarCategory::getInstanceByCategoryId($a_cat_id);
153
154 if ($category->getType() != ilCalendarCategory::TYPE_OBJ) {
155 $this->getLogger()->debug('Not modifying calendar for non object type');
156 return false;
157 }
158 if ($category->getObjType() != 'exc') {
159 $this->getLogger()->debug('Category object type is != folder => category event not modified');
160 return false;
161 }
162
163 return $category;
164 }
static getInstanceByCategoryId($a_cat_id)
Get instance by category id.

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

Referenced by addCustomEvents(), and modifyEvent().

+ 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 44 of file class.ilCalendarScheduleFilterExercise.php.

45 {
46 include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
48 if ($cal_cat) {
49 $exc_obj_id = $cal_cat->getObjId();
50
51 // see ilExAssignment::handleCalendarEntries()
52 $context_id = $a_event->getContextId();
53 $subtype = (int) substr($context_id, -1);
54 $ass_id = (int) substr($context_id, 0, -1);
55 // 1 is peer review deadline
56 if ($subtype != 1) {
57 include_once './Modules/Exercise/classes/class.ilExAssignment.php';
58 $ass = new ilExAssignment($ass_id);
59 if ($ass->getExerciseId() == $exc_obj_id) {
60 $idl = $ass->getPersonalDeadline($this->user_id);
61 if ($idl &&
62 $idl != $ass->getDeadline()) {
63 // we have individal deadline (see addCustomEvents());
64 return false;
65 }
66 if ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
67 // we have relative deadline (see addCustomEvents());
68 return false;
69 }
70 }
71 }
72 }
73
74 return $a_event;
75 }
static _lookupCategory($a_cal_id)
Lookup category id.
getContextId()
get context id
Exercise assignment.

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

+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilCalendarScheduleFilterExercise::$logger
protected

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

Referenced by getLogger().

◆ $user_id

ilCalendarScheduleFilterExercise::$user_id
protected

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


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