ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
30
31 $lng = $DIC['lng'];
32
33 $lng->loadLanguageModule('crs');
34
35 return $lng->txt('crs_mail_context_tutor_title');
36 }
37
41 public function getDescription()
42 {
43 global $DIC;
44
45 $lng = $DIC['lng'];
46
47 $lng->loadLanguageModule('crs');
48
49 return $lng->txt('crs_mail_context_tutor_info');
50 }
51
56 public function getSpecificPlaceholders()
57 {
61 global $DIC;
62
63 $lng = $DIC['lng'];
64
65 $lng->loadLanguageModule('crs');
66 $lng->loadLanguageModule('trac');
67
68 // tracking settings
69 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
70 $tracking = new ilObjUserTracking();
71
72
73 $placeholders = array();
74
75
76 $placeholders['crs_title'] = array(
77 'placeholder' => 'COURSE_TITLE',
78 'label' => $lng->txt('crs_title')
79 );
80
81 $placeholders['crs_status'] = array(
82 'placeholder' => 'COURSE_STATUS',
83 'label' => $lng->txt('trac_status')
84 );
85
86 $placeholders['crs_mark'] = array(
87 'placeholder' => 'COURSE_MARK',
88 'label' => $lng->txt('trac_mark')
89 );
90
91 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
92 $placeholders['crs_time_spent'] = array(
93 'placeholder' => 'COURSE_TIME_SPENT',
94 'label' => $lng->txt('trac_spent_seconds')
95 );
96 }
97
98 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
99 $placeholders['crs_first_access'] = array(
100 'placeholder' => 'COURSE_FIRST_ACCESS',
101 'label' => $lng->txt('trac_first_access')
102 );
103
104 $placeholders['crs_last_access'] = array(
105 'placeholder' => 'COURSE_LAST_ACCESS',
106 'label' => $lng->txt('trac_last_access')
107 );
108 }
109
110
111 $placeholders['crs_link'] = array(
112 'placeholder' => 'COURSE_LINK',
113 'label' => $lng->txt('crs_mail_permanent_link')
114 );
115
116 return $placeholders;
117 }
118
122 public function resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient = null, $html_markup = false)
123 {
127 global $DIC;
128
129 $ilObjDataCache = $DIC['ilObjDataCache'];
130
131 if (!in_array($placeholder_id, array(
132 'crs_title',
133 'crs_link',
134 'crs_status',
135 'crs_mark',
136 'crs_time_spent',
137 'crs_first_access',
138 'crs_last_access'))) {
139 return '';
140 }
141
142 $obj_id = $ilObjDataCache->lookupObjId($context_parameters['ref_id']);
143
144 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
145 $tracking = new ilObjUserTracking();
146
147 $this->getLanguage()->loadLanguageModule('trac');
148 $this->getLanguage()->loadLanguageModule('crs');
149
150 switch ($placeholder_id) {
151 case 'crs_title':
152 return $ilObjDataCache->lookupTitle($obj_id);
153
154 case 'crs_link':
155 require_once './Services/Link/classes/class.ilLink.php';
156 return ilLink::_getLink($context_parameters['ref_id'], 'crs');
157
158 case 'crs_status':
159 if ($recipient === null) {
160 return '';
161 }
162
163 include_once './Services/Tracking/classes/class.ilLPStatus.php';
164 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
165 $status = ilLPStatus::_lookupStatus($obj_id, $recipient->getId());
166 if (!$status) {
168 }
170
171 case 'crs_mark':
172 if ($recipient === null) {
173 return '';
174 }
175
176 include_once './Services/Tracking/classes/class.ilLPMarks.php';
177 $mark = ilLPMarks::_lookupMark($recipient->getId(), $obj_id);
178 return strlen(trim($mark)) ? $mark : '-';
179
180 case 'crs_time_spent':
181 if ($recipient === null) {
182 return '';
183 }
184
185 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
186 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
187 $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
188 if (isset($progress['spent_seconds'])) {
189 return ilDatePresentation::secondsToString($progress['spent_seconds'], false, $this->getLanguage());
190 }
191 }
192 break;
193
194 case 'crs_first_access':
195 if ($recipient === null) {
196 return '';
197 }
198
199 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
200 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
201 $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
202 if (isset($progress['access_time_min'])) {
203 return ilDatePresentation::formatDate(new ilDateTime($progress['access_time_min'], IL_CAL_UNIX));
204 }
205 }
206 break;
207
208 case 'crs_last_access':
209 if ($recipient === null) {
210 return '';
211 }
212
213 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
214 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
215 $progress = ilLearningProgress::_getProgress($recipient->getId(), $obj_id);
216 if (isset($progress['access_time'])) {
217 return ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_UNIX));
218 }
219 }
220 break;
221 }
222
223 return '';
224 }
225}
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, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
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 $DIC
Definition: saml.php:7
$lng