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