ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilIndividualAssessmentMember.php
Go to the documentation of this file.
1 <?php
2 require_once 'Modules/IndividualAssessment/classes/class.ilObjIndividualAssessment.php';
3 require_once 'Services/User/classes/class.ilObjUser.php';
4 require_once 'Modules/IndividualAssessment/exceptions/class.ilIndividualAssessmentException.php';
5 require_once 'Modules/IndividualAssessment/classes/Members/class.ilIndividualAssessmentMembers.php';
11  protected $iass;
12  protected $usr;
13 
14  protected $record;
15  protected $internal_note;
16  protected $examiner_id;
17  protected $notify;
18  protected $finalized;
19  protected $notification_ts;
20  protected $lp_status;
21 
23 
25  $this->internal_note = $data[ilIndividualAssessmentMembers::FIELD_INTERNAL_NOTE];
26  $this->examiner_id = $data[ilIndividualAssessmentMembers::FIELD_EXAMINER_ID];
27  $this->notify = $data[ilIndividualAssessmentMembers::FIELD_NOTIFY] ? true : false;
28  $this->finalized = $data[ilIndividualAssessmentMembers::FIELD_FINALIZED] ? true : false;
30  $this->notification_ts = $data[ilIndividualAssessmentMembers::FIELD_NOTIFICATION_TS];
31  $this->iass = $iass;
32  $this->usr = $usr;
33  }
34 
38  public function record() {
39  return $this->record;
40  }
41 
45  public function internalNote() {
46  return $this->internal_note;
47  }
48 
54  public function examinerId() {
55  return $this->examiner_id;
56  }
57 
63  public function notify() {
64  return $this->notify;
65  }
66 
75  if(!$this->finalized()) {
76  throw new ilIndividualAssessmentException('must finalize before notification');
77  }
78  if($this->notify) {
79  $notificator = (string)$this->lp_status === (string)ilIndividualAssessmentMembers::LP_COMPLETED ?
80  $notificator->withOccasionCompleted() :
81  $notificator->withOccasionFailed();
82  $notificator->withReciever($this)->send();
83  $this->notification_ts = time();
84  }
85  return $this;
86  }
87 
93  public function id() {
94  return $this->usr->getId();
95  }
96 
102  public function assessmentId() {
103  return $this->iass->getId();
104  }
105 
111  public function assessment() {
112  return $this->iass;
113  }
114 
120  public function finalized() {
121  return (string)$this->finalized === "1" ? true : false;
122  }
123 
129  public function mayBeFinalized() {
130  return ((string)$this->lp_status === (string)ilIndividualAssessmentMembers::LP_COMPLETED
131  ||(string)$this->lp_status === (string)ilIndividualAssessmentMembers::LP_FAILED)
132  && !$this->finalized();
133  }
134 
141  public function withRecord($record) {
142  assert('is_string($record) || $record === null');
143  if(!$this->finalized()) {
144  $clone = clone $this;
145  $clone->record = $record;
146  return $clone;
147  }
148  throw new ilIndividualAssessmentException('user allready finalized');
149  }
150 
157  public function withInternalNote($internal_note) {
158  assert('is_string($internal_note) || $internal_note === null');
159  if(!$this->finalized()) {
160  $clone = clone $this;
161  $clone->internal_note = $internal_note;
162  return $clone;
163  }
164  throw new ilIndividualAssessmentException('user allready finalized');
165  }
166 
173  public function withExaminerId($examiner_id) {
174  assert('is_numeric($examiner_id)');
175  if(!$this->finalized()) {
176  assert('ilObjUser::_exists($examiner_id)');
177  $clone = clone $this;
178  $clone->examiner_id = $examiner_id;
179  return $clone;
180  }
181  throw new ilIndividualAssessmentException('user allready finalized');
182  }
183 
190  public function withNotify($notify) {
191  assert('is_bool($notify)');
192  if(!$this->finalized()) {
193  $clone = clone $this;
194  $clone->notify = (bool)$notify;
195  return $clone;
196  }
197  throw new ilIndividualAssessmentException('user allready finalized');
198  }
199 
200  protected function LPStatusValid($lp_status) {
205  }
206 
213  public function withLPStatus($lp_status) {
214  if(!$this->finalized() && $this->LPStatusValid($lp_status)) {
215  $clone = clone $this;
216  $clone->lp_status = $lp_status;
217  return $clone;
218  }
219  throw new ilIndividualAssessmentException('user allready finalized or invalid learning progress status');
220  }
221 
227  public function lastname() {
228  return $this->usr->getLastname();
229  }
230 
236  public function firstname() {
237  return $this->usr->getFirstname();
238  }
239 
245  public function login() {
246  return $this->usr->getLogin();
247  }
248 
254  public function name() {
255  return $this->usr->getFullname();
256  }
257 
263  public function LPStatus() {
264  return $this->lp_status;
265  }
266 
272  public function withFinalized() {
273  if($this->mayBeFinalized()) {
274  $clone = clone $this;
275  $clone->finalized = 1;
276  return $clone;
277  }
278  throw new ilIndividualAssessmentException('user cant be finalized');
279  }
280 
286  public function notificationTS() {
287  return $this->notification_ts;
288  }
289 }
assessment()
Get the ilObjIndividualAssessment corresponding to this membership.
For the purpose of streamlining the grading and learning-process status definition outside of tests...
withReciever(ilIndividualAssessmentMember $member)
Define the member, that should recieve the message.
examinerId()
Get the user id of the examiner.
withFinalized()
Clone this object and finalize.
mayBeFinalized()
Can this membership be finalized?
Add rich text string
The name of the decorator.
notificationTS()
Get the timestamp, at which the notification was sent.
finalized()
Is this membership allready finalized?
withLPStatus($lp_status)
Clone this object and set LP-status.
withRecord($record)
Clone this object and set a record.
withOccasionFailed()
Set message mode to failed.
firstname()
Get the examinee firstname corresponding to this membership.
maybeSendNotification(ilIndividualAssessmentNotificator $notificator)
Notify a user, if he is supposed to be notified, using some notificator object.
lastname()
Get the examinee lastname corresponding to this membership.
Basic method collection should be implemented by a notificator used by Individual assessment...
withNotify($notify)
Clone this object and set wether the examinee should be notified.
withInternalNote($internal_note)
Clone this object and set an internal note.
login()
Get the examinee login corresponding to this membership.
withOccasionCompleted()
Set message mode to completed.
Create styles array
The data for the language used.
withExaminerId($examiner_id)
Clone this object and set an examiner_id.
Edit the record of a user, set LP.
name()
Get the examinee name corresponding to this membership.
notify()
Will the user be notified after finalization?
__construct(ilObjIndividualAssessment $iass, ilObjUser $usr, array $data)
assessmentId()
Get the ilObjIndividualAssessment id corresponding to this membership.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
id()
Get the user id corresponding to this membership.
LPStatus()
Get the LP-status corresponding to this membership.