ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExerciseMailNotification.php
Go to the documentation of this file.
1<?php
2
23{
24 public const TYPE_FEEDBACK_FILE_ADDED = 20;
25 public const TYPE_SUBMISSION_UPLOAD = 30;
26 public const TYPE_FEEDBACK_TEXT_ADDED = 40;
27 public const TYPE_GRADING_DONE = 70;
28 protected \ILIAS\Exercise\InternalDomainService $domain;
29 public const TYPE_MESSAGE_FROM_PF_GIVER = 50;
31 public const TYPE_DEADLINE_REQUESTED = 70;
32 public const TYPE_IDL_DEADLINE_SET = 80;
33 protected string $additional_text = "";
34 protected int $peer_id = 0;
35 protected \ILIAS\Exercise\PermanentLink\PermanentLinkManager $permanent_link;
36
37 protected ilObjUser $user;
38 protected int $ass_id;
39
40 public function __construct()
41 {
42 global $DIC;
43
44 $this->user = $DIC->user();
45 $this->domain = $DIC->exercise()->internal()->domain();
46 $this->permanent_link = $DIC->exercise()->internal()->gui()->permanentLink();
48 }
49
50 public function setAssignmentId(int $a_val): void
51 {
52 $this->ass_id = $a_val;
53 }
54
55 public function getAssignmentId(): int
56 {
57 return $this->ass_id;
58 }
59
60 protected function addOpenSubmission(): void
61 {
62 $ass = new ilExAssignment($this->getAssignmentId());
64 $type = $types->getById($ass->getType());
65 if ($type->supportsWebDirAccess()) {
66 $submission = new ilExSubmission($ass, $this->user->getId());
67 if ($submission->hasSubmittedPrintVersion()) {
68 $this->appendBody("\n\n");
69 $this->appendBody(sprintf(
70 $this->getLanguageText('exc_submission_open_notification_link'),
71 $this->permanent_link->getOpenSubmissionsLink($this->ref_id, $this->getAssignmentId(), $this->user->getId())
72 ));
73 }
74 }
75 }
76
77 public function setPeerId(int $a_val): void
78 {
79 $this->peer_id = $a_val;
80 }
81
82 public function getPeerId(): int
83 {
84 return $this->peer_id;
85 }
86
87 public function setAdditionalText(string $a_val): void
88 {
89 $this->additional_text = $a_val;
90 }
91
92 public function getAdditionalText(): string
93 {
95 }
96
97 public function send(): bool
98 {
99 $ilUser = $this->user;
100 $perma = $this->permanent_link;
101 // parent::send();
102
103 switch ($this->getType()) {
105
106 foreach ($this->getRecipients() as $rcp) {
107 $this->initLanguage($rcp);
108 $this->initMail();
109 $this->setSubject(
110 sprintf(
111 $this->getLanguageText('exc_msg_new_feedback_file_uploaded'),
112 $this->getObjectTitle(true)
113 )
114 );
115 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
116 $this->appendBody("\n\n");
117 $this->appendBody(
118 $this->getLanguageText('exc_msg_new_feedback_file_uploaded2')
119 );
120 $this->appendBody("\n");
121 $this->appendBody(
122 $this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)
123 );
124 $this->appendBody("\n");
125 $this->appendBody(
126 $this->getLanguageText('exc_assignment') . ": " .
128 );
129 $this->appendBody("\n\n");
130 $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
131 $this->appendBody("\n");
132 $this->appendBody($this->permanent_link->getPermanentLink($this->ref_id, $this->getAssignmentId()));
133 $this->getMail()->appendInstallationSignature(true);
134
135 $this->sendMail(array($rcp));
136 }
137 break;
138
140
141 foreach ($this->getRecipients() as $rcp) {
142 $this->initLanguage($rcp);
143 $this->initMail();
144 $this->setSubject(
145 sprintf(
146 $this->getLanguageText('exc_submission_notification_subject'),
147 $this->getObjectTitle(true)
148 )
149 );
150 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
151 $this->appendBody("\n\n");
152 $this->appendBody(
153 sprintf($this->getLanguageText('exc_submission_notification_body'), $this->getObjectTitle(true))
154 );
155 $this->appendBody("\n");
156 $this->appendBody(
157 $this->getLanguageText('exc_assignment') . ": " .
159 );
160 $this->appendBody("\n");
161 $this->appendBody(
162 $this->getLanguageText('user') . ": " .
163 $ilUser->getFullname()
164 );
165 $this->appendBody("\n\n");
166 $this->appendBody(sprintf(
167 $this->getLanguageText('exc_submission_notification_link'),
168 $this->permanent_link->getPermanentLink($this->ref_id, $this->getAssignmentId())
169 ));
170
172 $this->appendBody("\n\n");
173
174 //new files uploaded
175 //$assignment = new ilExAssignment($this->getAssignmentId());
176 //$submission = new ilExSubmission($assignment, $ilUser->getId());
177
178 // since mails are sent immediately after upload the files should always be new
179 //if($submission->lookupNewFiles($submission->getTutor()))
180 //{
181 $this->appendBody(sprintf(
182 $this->getLanguageText('exc_submission_downloads_notification_link'),
183 $this->permanent_link->getDownloadSubmissionLink($this->ref_id, $this->getAssignmentId(), $ilUser->getId())
184 ));
185 //}
186 //else
187 //{
188 // $this->appendBody(sprintf($this->getLanguageText('exc_submission_downloads_notification_link'),
189 // $this->getLanguageText("exc_submission_no_new_files")));
190 //}
191 }
192 $this->addOpenSubmission();
193
194 $this->appendBody("\n\n");
195 $this->appendBody(sprintf(
196 $this->getLanguageText('exc_submission_and_grades_notification_link'),
197 $this->permanent_link->getGradesLink($this->ref_id, $this->getAssignmentId())
198 ));
199
200 $this->getMail()->appendInstallationSignature(true);
201
202 $this->sendMail(array($rcp));
203 }
204 break;
205
207
208 foreach ($this->getRecipients() as $rcp) {
209 $this->initLanguage($rcp);
210 $this->initMail();
211 $this->setSubject(
212 sprintf(
213 $this->getLanguageText('exc_msg_new_feedback_text_uploaded'),
214 $this->getObjectTitle(true)
215 )
216 );
217 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
218 $this->appendBody("\n\n");
219 $this->appendBody(
220 $this->getLanguageText('exc_msg_new_feedback_text_uploaded2')
221 );
222 $this->appendBody("\n");
223 $this->appendBody(
224 $this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)
225 );
226 $this->appendBody("\n");
227 $this->appendBody(
228 $this->getLanguageText('exc_assignment') . ": " .
230 );
231 $this->appendBody("\n\n");
232 $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
233 $this->appendBody("\n");
234 $this->appendBody($this->permanent_link->getPermanentLink($this->ref_id, $this->getAssignmentId()));
235 $this->getMail()->appendInstallationSignature(true);
236
237 $this->sendMail(array($rcp));
238 }
239 break;
240
242
243 foreach ($this->getRecipients() as $rcp) {
244 $this->initLanguage($rcp);
245 $this->initMail();
246 $this->setSubject(
247 sprintf(
248 $this->getLanguageText('exc_msg_grading_done'),
249 $this->getObjectTitle(true)
250 )
251 );
252 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
253 $this->appendBody("\n\n");
254 $this->appendBody(
255 sprintf(
256 $this->getLanguageText('exc_msg_grading_done_body'),
257 $this->getObjectTitle(false)
258 )
259 );
260 $this->appendBody("\n");
261 $this->appendBody(
262 $this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)
263 );
264 $this->appendBody("\n");
265 $this->appendBody(
266 $this->getLanguageText('exc_assignment') . ": " .
268 );
269 $this->appendBody("\n\n");
270 $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
271 $this->appendBody("\n");
272 $this->appendBody($this->permanent_link->getPermanentLink($this->ref_id, $this->getAssignmentId()));
273 $this->getMail()->appendInstallationSignature(true);
274
275 $this->sendMail(array($rcp));
276 }
277 break;
278
280
281 foreach ($this->getRecipients() as $rcp) {
282 $this->initLanguage($rcp);
284 $rcp,
285 sprintf(
286 $this->getLanguageText('exc_msg_new_message_from_pf_giver'),
287 $this->getObjectTitle(true)
288 ),
289 $this->getLanguageText('exc_msg_new_message_from_pf_giver2') .
290 "\n\n" . $this->getAdditionalText(),
291 $perma->getReceivedFeedbackLink($this->ref_id, $this->getAssignmentId())
292 );
293 }
294 break;
295
297
298 foreach ($this->getRecipients() as $rcp) {
299 $this->initLanguage($rcp);
301 $rcp,
302 sprintf(
303 $this->getLanguageText('exc_msg_new_message_from_pf_recipient'),
304 $this->getObjectTitle(true)
305 ),
306 $this->getLanguageText('exc_msg_new_message_from_pf_recipient2') .
307 "\n\n" . $this->getAdditionalText(),
308 $perma->getGivenFeedbackLink($this->ref_id, $this->getAssignmentId(), $this->getPeerId())
309 );
310 }
311 break;
312
314 foreach ($this->getRecipients() as $rcp) {
315 $this->initLanguage($rcp);
317 $rcp,
318 sprintf(
319 $this->getLanguageText('exc_msg_deadline_request_subject'),
320 $this->getObjectTitle(true)
321 ),
322 $this->getLanguageText('exc_msg_deadline_request_body') .
323 "\n\n" . $this->getLanguageText('user') . ": " .
324 $ilUser->getFullname(),
325 $perma->getGradesLink($this->ref_id, $this->getAssignmentId())
326 );
327 }
328 break;
329
331 foreach ($this->getRecipients() as $rcp) {
332 $this->initLanguage($rcp);
334 $rcp,
335 sprintf(
336 $this->getLanguageText('exc_msg_idl_set_subject'),
337 $this->getObjectTitle(true)
338 ),
339 $this->getLanguageText('exc_msg_idl_set_body'),
340 $perma->getPermanentLink($this->ref_id, $this->getAssignmentId())
341 );
342 }
343 break;
344 }
345 return true;
346 }
347
348 protected function sendExerciseNotification(
349 int $rcp,
350 string $subject,
351 string $text,
352 string $link = ""
353 ): void {
354 $this->initLanguage($rcp);
355 $this->initMail();
356 $this->setSubject($subject);
357 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
358 $this->appendBody("\n\n" . $text);
359 $this->appendBody(
360 "\n\n" . $this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)
361 );
362 $this->appendBody("\n");
363 if ($this->getAssignmentId() > 0) {
364 $this->appendBody(
365 $this->getLanguageText('exc_assignment') . ": " .
367 );
368 }
369 $this->appendBody("\n\n");
370 $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
371 $this->appendBody("\n");
372 $this->appendBody($link);
373 $this->getMail()->appendInstallationSignature(true);
374 $this->sendMail(array($rcp));
375 }
376
380 protected function initLanguage(int $a_usr_id): void
381 {
382 parent::initLanguage($a_usr_id);
383 $this->getLanguage()->loadLanguageModule('exc');
384 }
385}
Exercise assignment.
static lookupType(int $a_id)
const TYPE_UPLOAD
direct checks against const should be avoided, use type objects instead
static lookupTitle(int $a_id)
Exercise submission //TODO: This class has many static methods related to delivered "files".
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Exercise PermanentLink PermanentLinkManager $permanent_link
ILIAS Exercise InternalDomainService $domain
sendExerciseNotification(int $rcp, string $subject, string $text, string $link="")
initLanguage(int $a_usr_id)
Add language module exc.
getObjectTitle(bool $a_shorten=false)
sendMail(array $a_rcp, bool $a_parse_recipients=true)
getLanguageText(string $a_keyword)
setSubject(string $a_subject)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
User class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
getLanguage()