ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCourseMailTemplateTutorContext.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Mail/classes/class.ilMailTemplateContext.php';
5 
13 {
14  const ID = 'crs_context_tutor_manual';
15 
19  public function getId()
20  {
21  return self::ID;
22  }
23 
27  public function getTitle()
28  {
29  global $lng;
30 
31  $lng->loadLanguageModule('crs');
32 
33  return $lng->txt('crs_mail_context_tutor_title');
34  }
35 
39  public function getDescription()
40  {
41  global $lng;
42 
43  $lng->loadLanguageModule('crs');
44 
45  return $lng->txt('crs_mail_context_tutor_info');
46  }
47 
52  public function getSpecificPlaceholders()
53  {
57  global $lng;
58 
59  $lng->loadLanguageModule('crs');
60  $lng->loadLanguageModule('trac');
61 
62  // tracking settings
63  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
64  $tracking = new ilObjUserTracking();
65 
66 
67  $placeholders = array();
68 
69 
70  $placeholders['crs_title'] = array(
71  'placeholder' => 'COURSE_TITLE',
72  'label' => $lng->txt('crs_title')
73  );
74 
75  $placeholders['crs_status'] = array(
76  'placeholder' => 'COURSE_STATUS',
77  'label' => $lng->txt('trac_status')
78  );
79 
80  $placeholders['crs_mark'] = array(
81  'placeholder' => 'COURSE_MARK',
82  'label' => $lng->txt('trac_mark')
83  );
84 
85  if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
86  $placeholders['crs_time_spent'] = array(
87  'placeholder' => 'COURSE_TIME_SPENT',
88  'label' => $lng->txt('trac_spent_seconds')
89  );
90  }
91 
92  if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
93  $placeholders['crs_first_access'] = array(
94  'placeholder' => 'COURSE_FIRST_ACCESS',
95  'label' => $lng->txt('trac_first_access')
96  );
97 
98  $placeholders['crs_last_access'] = array(
99  'placeholder' => 'COURSE_LAST_ACCESS',
100  'label' => $lng->txt('trac_last_access')
101  );
102  }
103 
104 
105  $placeholders['crs_link'] = array(
106  'placeholder' => 'COURSE_LINK',
107  'label' => $lng->txt('crs_mail_permanent_link')
108  );
109 
110  return $placeholders;
111  }
112 
116  public function resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient = null, $html_markup = false)
117  {
121  global $ilObjDataCache;
122 
123  if (!in_array($placeholder_id, array(
124  'crs_title',
125  'crs_link',
126  'crs_status',
127  'crs_mark',
128  'crs_time_spent',
129  'crs_first_access',
130  'crs_last_access'))) {
131  return '';
132  }
133 
134  $obj_id = $ilObjDataCache->lookupObjId($context_parameters['ref_id']);
135 
136  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
137  $tracking = new ilObjUserTracking();
138 
139  $this->getLanguage()->loadLanguageModule('trac');
140  $this->getLanguage()->loadLanguageModule('crs');
141 
142  switch ($placeholder_id) {
143  case 'crs_title':
144  return $ilObjDataCache->lookupTitle($obj_id);
145 
146  case 'crs_link':
147  require_once './Services/Link/classes/class.ilLink.php';
148  return ilLink::_getLink($context_parameters['ref_id'], 'crs');
149 
150  case 'crs_status':
151  if ($recipient === null) {
152  return '';
153  }
154 
155  include_once './Services/Tracking/classes/class.ilLPStatus.php';
156  include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
157  $status = ilLPStatus::_lookupStatus($obj_id, $recipient->getId());
158  if (!$status) {
160  }
161  return ilLearningProgressBaseGUI::_getStatusText($status, $this->getLanguage());
162 
163  case 'crs_mark':
164  if ($recipient === null) {
165  return '';
166  }
167 
168  include_once './Services/Tracking/classes/class.ilLPMarks.php';
169  $mark = ilLPMarks::_lookupMark($recipient->getId(), $obj_id);
170  return strlen(trim($mark)) ? $mark : '-';
171 
172  case 'crs_time_spent':
173  if ($recipient === null) {
174  return '';
175  }
176 
177  if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
178  include_once './Services/Tracking/classes/class.ilLearningProgress.php';
179  $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
180  if (isset($progress['spent_seconds'])) {
181  return ilDatePresentation::secondsToString($progress['spent_seconds'], false, $this->getLanguage());
182  }
183  }
184  break;
185 
186  case 'crs_first_access':
187  if ($recipient === null) {
188  return '';
189  }
190 
191  if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
192  include_once './Services/Tracking/classes/class.ilLearningProgress.php';
193  $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
194  if (isset($progress['access_time_min'])) {
195  return ilDatePresentation::formatDate(new ilDateTime($progress['access_time_min'], IL_CAL_UNIX));
196  }
197  }
198  break;
199 
200  case 'crs_last_access':
201  if ($recipient === null) {
202  return '';
203  }
204 
205  if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
206  include_once './Services/Tracking/classes/class.ilLearningProgress.php';
207  $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
208  if (isset($progress['access_time'])) {
209  return ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_UNIX));
210  }
211  }
212  break;
213  }
214 
215  return '';
216  }
217 }
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient=null, $html_markup=false)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
getSpecificPlaceholders()
Return an array of placeholders.
const IL_CAL_UNIX
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
Date and time handling
Class ilMailTemplateContext.
Create styles array
The data for the language used.
const LP_STATUS_NOT_ATTEMPTED_NUM
global $lng
Definition: privfeed.php:17
static _lookupMark($a_usr_id, $a_obj_id)
static _getProgress($a_user_id, $a_obj_id)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.