ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilIndividualAssessmentPrimitiveInternalNotificator.php
Go to the documentation of this file.
1<?php
2require_once 'Services/Mail/classes/class.ilMailNotification.php';
3require_once 'Modules/IndividualAssessment/interfaces/Notification/interface.ilIndividualAssessmentNotificator.php';
9 const OCCASION_FAILED = 0;
11
12 protected $occasion;
13 protected $reciever;
14
15 public function __construct() {
16 parent::__construct();
17 $this->setLangModules(array('iass'));
18 }
19
23 public function withReciever(ilIndividualAssessmentMember $member) {
24 $clone = clone $this;
25 $clone->reciever = $member;
26 $clone->ref_id = $member->assessment()->getRefId();
27 return $clone;
28 }
29
33 public function withOccasionFailed() {
34 $clone = clone $this;
35 $clone->occasion = self::OCCASION_FAILED;
36 return $clone;
37 }
38
42 public function withOccasionCompleted() {
43 $clone = clone $this;
44 $clone->occasion = self::OCCASION_COMPLETED;
45 return $clone;
46 }
47
51 public function send() {
52 if(! $this->reciever instanceof ilIndividualAssessmentMember || !in_array($this->occasion, array(self::OCCASION_COMPLETED,self::OCCASION_FAILED))) {
53 throw new ilIndividualAssessmentException('can\'t notify');
54 }
55 $this->initLanguage($this->reciever->id());
56 $this->initMail();
57 $subject = $this->occasion === self::OCCASION_COMPLETED
58 ? $this->getLanguageText('iass_subj_notification_completed')
59 : $this->getLanguageText('iass_subj_notification_failed');
60 $message = $this->occasion === self::OCCASION_COMPLETED
61 ? $this->getLanguageText('iass_mess_notification_completed')
62 : $this->getLanguageText('iass_mess_notification_failed');
63 $assessment_title = $this->reciever->assessment()->getTitle();
64 $this->setSubject(
65 sprintf($subject, $assessment_title)
66 );
67 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
68 $this->appendBody("\n\n");
69 $this->appendBody(sprintf($message, $assessment_title));
70 $this->appendBody("\n\n");
71 $this->appendBody($this->reciever->record());
72 $this->appendBody("\n\n");
73 $this->appendBody($this->createPermanentLink());
74 $this->getMail()->appendInstallationSignature(true);
75 $this->sendMail(array($this->reciever->id()),array('system'));
76 }
77}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Edit the record of a user, set LP.
assessment()
Get the ilObjIndividualAssessment corresponding to this membership.
withReciever(ilIndividualAssessmentMember $member)
Define the member, that should recieve the message.ilIndividualAssessmentNotificator $this
withOccasionFailed()
Set message mode to failed.ilIndividualAssessmentNotificator $this
withOccasionCompleted()
Set message mode to completed.ilIndividualAssessmentNotificator $this
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
initLanguage($a_usr_id)
Init language.
setLangModules(array $a_modules)
Set lang modules.
createPermanentLink($a_params=array(), $a_append='')
Basic method collection should be implemented by a notificator used by Individual assessment.