ILIAS  release_8 Revision v8.24
class.ilTestManScoringParticipantNotification.php
Go to the documentation of this file.
1<?php
2
20{
21 public function __construct($userId, $testRefId)
22 {
24
25 $this->setRecipient($userId);
26 $this->setRefId($testRefId);
27
28 $this->initLanguage($this->getRecipient());
29 $this->getLanguage()->loadLanguageModule('assessment');
30
31 $this->initMail();
32 }
33
34 public function send(): void
35 {
36 $this->buildSubject();
37
38 $this->buildBody();
39
40 $this->sendMail(
41 $this->getRecipients()
42 );
43 }
44
45 private function buildSubject(): void
46 {
47 $info = $this->getAdditionalInformation();
48
49 $this->setSubject(sprintf($this->getLanguageText('tst_notify_manscoring_done_body_msg_subject'), $info['test_title']));
50 }
51
52 private function buildBody(): void
53 {
54 // Salutation
55
56 $this->setBody(
58 );
59 $this->appendBody("\n\n");
60
61 // Message (What has happened?)
62
63 $this->appendBody($this->getLanguageText('tst_notify_manscoring_done_body_msg_topic'));
64 $this->appendBody("\n\n");
65
66 $info = $this->getAdditionalInformation();
67
68 $this->appendBody($this->getLanguageText('obj_tst') . ': ' . $info['test_title']);
69 $this->appendBody("\n");
70 $this->appendBody($this->getLanguageText('pass') . ': ' . $info['test_pass']);
71 $this->appendBody("\n\n");
72
73 foreach ($info['questions_gui_list'] as $questionId => $questionGui) {
74 $points = $info['questions_scoring_data'][$questionId]['points'];
75 $feedback = $info['questions_scoring_data'][$questionId]['feedback'];
76
77 $feedback = $this->convertFeedbackForMail($feedback);
78
79 $this->appendBody($this->getLanguageText('tst_question') . ': ' . $questionGui->object->getTitleForHTMLOutput());
80 $this->appendBody("\n");
81 $this->appendBody($this->getLanguageText('tst_reached_points') . ': ' . $points);
82 $this->appendBody("\n");
83 $this->appendBody($this->getLanguageText('set_manual_feedback') . ":\n" . $feedback);
84 $this->appendBody("\n\n");
85 }
86
87 // Task (What do I have to do?
88
89 /* NOTHING REQUIRED FOR PARTICIPANT */
90
91 // Explanation (Why do I receive the following message?)
92
93 $this->appendBody("\n");
94 $this->appendBody($this->getLanguageText('tst_notify_manscoring_done_body_msg_reason'));
95
96 // Signature
97
98 $this->getMail()->appendInstallationSignature(true);
99 }
100
101 private function setRecipient($userId): void
102 {
103 $this->setRecipients(array($userId));
104 }
105
106 private function getRecipient()
107 {
108 return current($this->getRecipients());
109 }
110
111 private function convertFeedbackForMail($feedback): ?string
112 {
113 if (strip_tags($feedback) != $feedback) {
114 $feedback = preg_replace('/<br(.*\/)>/m', "\n", $feedback);
115 $feedback = strip_tags($feedback);
116 }
117
118 return $feedback;
119 }
120}
Base class for course/group mail notifications.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc