ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4include_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 {
87 $placeholders['crs_time_spent'] = array(
88 'placeholder' => 'COURSE_TIME_SPENT',
89 'label' => $lng->txt('trac_spent_seconds')
90 );
91 }
92
93 if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
94 {
95 $placeholders['crs_first_access'] = array(
96 'placeholder' => 'COURSE_FIRST_ACCESS',
97 'label' => $lng->txt('trac_first_access')
98 );
99
100 $placeholders['crs_last_access'] = array(
101 'placeholder' => 'COURSE_LAST_ACCESS',
102 'label' => $lng->txt('trac_last_access')
103 );
104 }
105
106
107 $placeholders['crs_link'] = array(
108 'placeholder' => 'COURSE_LINK',
109 'label' => $lng->txt('crs_mail_permanent_link')
110 );
111
112 return $placeholders;
113 }
114
118 public function resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient = null, $html_markup = false)
119 {
123 global $ilObjDataCache;
124
125 if(!in_array($placeholder_id, array(
126 'crs_title',
127 'crs_link',
128 'crs_status',
129 'crs_mark',
130 'crs_time_spent',
131 'crs_first_access',
132 'crs_last_access'))) {
133 return '';
134 }
135
136 $obj_id = $ilObjDataCache->lookupObjId($context_parameters['ref_id']);
137
138 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
139 $tracking = new ilObjUserTracking();
140
141 $this->getLanguage()->loadLanguageModule('trac');
142 $this->getLanguage()->loadLanguageModule('crs');
143
144 switch($placeholder_id)
145 {
146 case 'crs_title':
147 return $ilObjDataCache->lookupTitle($obj_id);
148
149 case 'crs_link':
150 require_once './Services/Link/classes/class.ilLink.php';
151 return ilLink::_getLink($context_parameters['ref_id'], 'crs');
152
153 case 'crs_status':
154 if($recipient === null)
155 {
156 return '';
157 }
158
159 include_once './Services/Tracking/classes/class.ilLPStatus.php';
160 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
161 $status = ilLPStatus::_lookupStatus($obj_id, $recipient->getId());
162 if(!$status)
163 {
165 }
166 return ilLearningProgressBaseGUI::_getStatusText($status, $this->getLanguage());
167
168 case 'crs_mark':
169 if($recipient === null)
170 {
171 return '';
172 }
173
174 include_once './Services/Tracking/classes/class.ilLPMarks.php';
175 $mark = ilLPMarks::_lookupMark($recipient->getId(), $obj_id);
176 return strlen(trim($mark)) ? $mark : '-';
177
178 case 'crs_time_spent':
179 if($recipient === null)
180 {
181 return '';
182 }
183
184 if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS))
185 {
186 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
187 $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
188 if(isset($progress['spent_seconds']))
189 {
190 return ilDatePresentation::secondsToString($progress['spent_seconds'], false, $this->getLanguage());
191 }
192 }
193 break;
194
195 case 'crs_first_access':
196 if($recipient === null)
197 {
198 return '';
199 }
200
201 if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
202 {
203 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
204 $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
205 if(isset($progress['access_time_min']))
206 {
207 return ilDatePresentation::formatDate(new ilDateTime($progress['access_time_min'], IL_CAL_UNIX));
208 }
209 }
210 break;
211
212 case 'crs_last_access':
213 if($recipient === null)
214 {
215 return '';
216 }
217
218 if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
219 {
220 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
221 $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
222 if(isset($progress['access_time']))
223 {
224 return ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_UNIX));
225 }
226 }
227 break;
228 }
229
230 return '';
231 }
232}
233?>
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static _lookupMark($a_usr_id, $a_obj_id)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
const LP_STATUS_NOT_ATTEMPTED_NUM
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _getProgress($a_user_id, $a_obj_id)
Class ilMailTemplateContext.
getSpecificPlaceholders()
Return an array of placeholders.
resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient=null, $html_markup=false)
global $lng
Definition: privfeed.php:17