ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestManScoringParticipantNotification.php
Go to the documentation of this file.
1 <?php
2 
3 require_once 'Services/Mail/classes/class.ilMailNotification.php';
4 
5 
7 {
8  private $userId = null;
9  private $questionGuiList = null;
10  private $notificationData = null;
11 
12  public function __construct($userId, $testRefId)
13  {
15 
16  $this->setRecipient($userId);
17  $this->setRefId($testRefId);
18 
19  $this->initLanguage( $this->getRecipient() );
20  $this->getLanguage()->loadLanguageModule('assessment');
21 
22  $this->initMail()->enableSoap(false);
23  }
24 
25  public function send()
26  {
27  $this->buildSubject();
28 
29  $this->buildBody();
30 
31  $this->sendMail(
32  $this->getRecipients(), array('system')
33  );
34  }
35 
36  private function buildSubject()
37  {
38  $info = $this->getAdditionalInformation();
39 
40  $this->setSubject( sprintf($this->getLanguageText('tst_notify_manscoring_done_body_msg_subject'), $info['test_title']) );
41  }
42 
43  private function buildBody()
44  {
45  // Salutation
46 
47  $this->setBody(
48  ilMail::getSalutation( $this->getRecipient(), $this->getLanguage() )
49  );
50  $this->appendBody("\n\n");
51 
52  // Message (What has happened?)
53 
54  $this->appendBody( $this->getLanguageText('tst_notify_manscoring_done_body_msg_topic') );
55  $this->appendBody("\n\n");
56 
57  $info = $this->getAdditionalInformation();
58 
59  $this->appendBody( $this->getLanguageText('obj_tst').': '.$info['test_title'] );
60  $this->appendBody("\n");
61  $this->appendBody( $this->getLanguageText('pass').': '.$info['test_pass'] );
62  $this->appendBody("\n\n");
63 
64  foreach($info['questions_gui_list'] as $questionId => $questionGui)
65  {
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 TODO 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  {
107  $feedback = preg_replace('/<br(.*\/)>/m', "\n", $feedback);
108  $feedback = strip_tags($feedback);
109  }
110 
111  return $feedback;
112  }
113 }
114