ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTestManScoringParticipantNotification.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Mail/classes/class.ilMailNotification.php';
5
6
8{
9 private $userId = null;
10 private $questionGuiList = null;
11 private $notificationData = null;
12
13 public function __construct($userId, $testRefId)
14 {
16
17 $this->setRecipient($userId);
18 $this->setRefId($testRefId);
19
20 $this->initLanguage($this->getRecipient());
21 $this->getLanguage()->loadLanguageModule('assessment');
22
23 $this->initMail();
24 }
25
26 public function send()
27 {
28 $this->buildSubject();
29
30 $this->buildBody();
31
32 $this->sendMail(
33 $this->getRecipients()
34 );
35 }
36
37 private function buildSubject()
38 {
39 $info = $this->getAdditionalInformation();
40
41 $this->setSubject(sprintf($this->getLanguageText('tst_notify_manscoring_done_body_msg_subject'), $info['test_title']));
42 }
43
44 private function buildBody()
45 {
46 // Salutation
47
48 $this->setBody(
50 );
51 $this->appendBody("\n\n");
52
53 // Message (What has happened?)
54
55 $this->appendBody($this->getLanguageText('tst_notify_manscoring_done_body_msg_topic'));
56 $this->appendBody("\n\n");
57
58 $info = $this->getAdditionalInformation();
59
60 $this->appendBody($this->getLanguageText('obj_tst') . ': ' . $info['test_title']);
61 $this->appendBody("\n");
62 $this->appendBody($this->getLanguageText('pass') . ': ' . $info['test_pass']);
63 $this->appendBody("\n\n");
64
65 foreach ($info['questions_gui_list'] as $questionId => $questionGui) {
66 $points = $info['questions_scoring_data'][$questionId]['points'];
67 $feedback = $info['questions_scoring_data'][$questionId]['feedback'];
68
69 $feedback = $this->convertFeedbackForMail($feedback);
70
71 $this->appendBody($this->getLanguageText('tst_question') . ': ' . $questionGui->object->getTitle());
72 $this->appendBody("\n");
73 $this->appendBody($this->getLanguageText('tst_reached_points') . ': ' . $points);
74 $this->appendBody("\n");
75 $this->appendBody($this->getLanguageText('set_manual_feedback') . ":\n" . $feedback);
76 $this->appendBody("\n\n");
77 }
78
79 // Task (What do I have to do?
80
81 /* NOTHING REQUIRED FOR PARTICIPANT */
82
83 // Explanation (Why do I receive the following message?)
84
85 $this->appendBody("\n");
86 $this->appendBody($this->getLanguageText('tst_notify_manscoring_done_body_msg_reason'));
87
88 // Signature
89
90 $this->getMail()->appendInstallationSignature(true);
91 }
92
93 private function setRecipient($userId)
94 {
95 $this->setRecipients(array($userId));
96 }
97
98 private function getRecipient()
99 {
100 return current($this->getRecipients());
101 }
102
103 private function convertFeedbackForMail($feedback)
104 {
105 if (strip_tags($feedback) != $feedback) {
106 $feedback = preg_replace('/<br(.*\/)>/m', "\n", $feedback);
107 $feedback = strip_tags($feedback);
108 }
109
110 return $feedback;
111 }
112}
An exception for terminatinating execution or to throw for unit testing.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
sendMail(array $a_rcp, $a_parse_recipients=true)
initLanguage($a_usr_id)
Init language.
getRecipients()
get array of recipients
static getSalutation($a_usr_id, ilLanguage $a_language=null)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc