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