ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilIndividualAssessmentPrimitiveInternalNotificator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 public const OCCASION_FAILED = 0;
27 public const OCCASION_COMPLETED = 1;
28
29 protected int $occasion;
31
32 public function __construct()
33 {
35 $this->setLangModules(array('iass'));
36 }
37
41 public function withReceiver(
44 $clone = clone $this;
45 $clone->receiver = $member;
46 $clone->ref_id = $member->assessment()->getRefId();
47 return $clone;
48 }
49
54 {
55 $clone = clone $this;
56 $clone->occasion = self::OCCASION_FAILED;
57 return $clone;
58 }
59
64 {
65 $clone = clone $this;
66 $clone->occasion = self::OCCASION_COMPLETED;
67 return $clone;
68 }
69
73 public function send(): void
74 {
75 if (
76 !$this->receiver instanceof ilIndividualAssessmentMember ||
77 !in_array($this->occasion, array(self::OCCASION_COMPLETED, self::OCCASION_FAILED))
78 ) {
79 throw new ilIndividualAssessmentException('can\'t notify');
80 }
81 $this->initLanguage($this->receiver->id());
82 $this->initMail();
83 $subject = $this->occasion === self::OCCASION_COMPLETED
84 ? $this->getLanguageText('iass_subj_notification_completed')
85 : $this->getLanguageText('iass_subj_notification_failed');
86 $message = $this->occasion === self::OCCASION_COMPLETED
87 ? $this->getLanguageText('iass_mess_notification_completed')
88 : $this->getLanguageText('iass_mess_notification_failed');
89 $assessment_title = $this->receiver->assessment()->getTitle();
90 $this->setSubject(
91 sprintf($subject, $assessment_title)
92 );
93 $this->setBody(ilMail::getSalutation($this->receiver->id(), $this->getLanguage()));
94 $this->appendBody("\n\n");
95 $this->appendBody(sprintf($message, $assessment_title));
96 $this->appendBody("\n\n");
97 $this->appendBody($this->receiver->record());
98 $this->appendBody("\n\n");
99 $this->appendBody($this->createPermanentLink());
100 $this->getMail()->appendInstallationSignature(true);
101 $this->sendMail(array($this->receiver->id()));
102 }
103}
Edit the record of a user, set LP.
withReceiver(ilIndividualAssessmentMember $member)
Define the member, that should receive the message.
setLangModules(array $a_modules)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
Basic method collection should be implemented by a notificator used by Individual assessment.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$message
Definition: xapiexit.php:31