ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilStudyProgrammeProgress.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5
21{
22
23 // The progress of a user on a program node can have different status that
24 // determine how the node is taken into account for calculation of the learning
25 // progress.
26
27 // User needs to be successful in the node, but currently isn't.
29 // User has completed the node successfully according to the program nodes
30 // mode.
32 // User was marked as successful in the node without actually having
33 // successfully completed the program node according to his mode.
35 // The user does not need to be successful in this node.
37 // The user does not need to be successful in this node.
38 const STATUS_FAILED = 5;
39
40 public static $STATUS = array( self::STATUS_IN_PROGRESS
41 , self::STATUS_COMPLETED
42 , self::STATUS_ACCREDITED
43 , self::STATUS_NOT_RELEVANT
44 , self::STATUS_FAILED
45 );
46
47 const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
48 const DATE_FORMAT = 'Y-m-d';
49
61 protected $id;
62
68 protected $assignment_id;
69
75 protected $prg_id;
76
83 protected $usr_id;
91 protected $points;
92
98 protected $points_cur;
99
105 protected $status;
106
115 protected $completion_by;
116
117
124 protected $last_change;
125
132
139
146
152 protected $deadline;
153
159 protected $vq_date;
160
161
167 protected $invalidated = false;
168 public function __construct(int $id)
169 {
170 $this->id = $id;
171 }
172
178 public function getId()
179 {
180 return $this->id;
181 }
182
186 public function getAssignmentId() : int
187 {
189 }
190 public function setAssignmentId(int $a_id) : ilStudyProgrammeProgress
191 {
192 $this->assignment_id = $a_id;
193 return $this;
194 }
198 public function getNodeId() : int
199 {
200 return $this->prg_id;
201 }
202 public function setNodeId(int $a_id) : ilStudyProgrammeProgress
203 {
204 $this->prg_id = $a_id;
205 return $this;
206 }
210 public function getUserId() : int
211 {
212 return $this->usr_id;
213 }
214 public function setUserId(int $a_id) : ilStudyProgrammeProgress
215 {
216 $this->usr_id = $a_id;
217 return $this;
218 }
219
225 public function getAmountOfPoints() : int
226 {
227 return $this->points;
228 }
229
237 public function setAmountOfPoints(int $a_points) : ilStudyProgrammeProgress
238 {
239 if ($a_points < 0) {
240 throw new ilException("ilStudyProgrammeProgress::setAmountOfPoints: "
241 . "Expected a number >= 0 as argument, got '$a_points'");
242 }
243
244 $this->points = $a_points;
245
246 $this->updateLastChange();
247 return $this;
248 }
249
253 public function getCurrentAmountOfPoints() : int
254 {
255 return $this->points_cur;
256 }
257
266 public function setCurrentAmountOfPoints(int $a_points) : ilStudyProgrammeProgress
267 {
268 if ($a_points < 0) {
269 throw new ilException("ilStudyProgrammeProgress::setCurrentAmountOfPoints: "
270 . "Expected a number >= 0 as argument, got '$a_points'.");
271 }
272
273 $this->points_cur = $a_points;
274 $this->updateLastChange();
275 return $this;
276 }
277
283 public function getStatus() : int
284 {
285 return $this->status;
286 }
287
293 public function setStatus(int $a_status) : ilStudyProgrammeProgress
294 {
295 if (!in_array($a_status, self::$STATUS)) {
296 throw new ilException("ilStudyProgrammeProgress::setStatus: No status: "
297 . "'$a_status'");
298 }
299
300 $this->status = $a_status;
301 $this->updateLastChange();
302 return $this;
303 }
304
311 public function setCompletionBy(int $a_id = null) : ilStudyProgrammeProgress
312 {
313 $this->completion_by = $a_id;
314 $this->updateLastChange();
315 return $this;
316 }
317
324 public function getCompletionBy()
325 {
327 }
333 public function getLastChangeBy()
334 {
336 }
337
346 public function setLastChangeBy(int $a_usr_id = null) : ilStudyProgrammeProgress
347 {
348 if (is_null($a_usr_id) || $a_usr_id < 0) {
349 throw new ilException("ilStudyProgrammeProgress::setLastChangeBy: '$a_usr_id' "
350 . "is no id of a user.");
351 }
352 $this->last_change_by = $a_usr_id;
353 return $this;
354 }
355
361 public function getLastChange() : DateTime
362 {
363 return DateTime::createFromFormat(self::DATE_TIME_FORMAT, $this->last_change);
364 }
365
376 public function updateLastChange()
377 {
378 $this->setLastChange(new DateTime());
379 return $this;
380 }
381
391 public function setLastChange(DateTime $a_timestamp) : ilStudyProgrammeProgress
392 {
393 $this->last_change = $a_timestamp->format(self::DATE_TIME_FORMAT);
394 return $this;
395 }
396
401 {
402 $this->assignment_date = $assignment_date;
403 return $this;
404 }
405
409 public function getAssignmentDate() : DateTime
410 {
412 }
413
418 {
419 $this->completion_date = $completion_date;
420 return $this;
421 }
422
428 public function getCompletionDate()
429 {
431 }
432
438 public function getDeadline()
439 {
440 return $this->deadline;
441 }
442
450 public function setDeadline(DateTime $deadline = null) : ilStudyProgrammeProgress
451 {
452 $this->deadline = $deadline;
453 return $this;
454 }
455
459 public function setValidityOfQualification(DateTime $date = null) : ilStudyProgrammeProgress
460 {
461 $this->vq_date = $date;
462 return $this;
463 }
464
468 public function getValidityOfQualification() : ?DateTime
469 {
470 return $this->vq_date;
471 }
472
477 {
478 if (!$this->vq_date || $this->vq_date->format('Y-m-d') > date('Y-m-d')) {
479 throw new ilException("may not invalidate non-expired progress");
480 }
481 $this->invalidated = true;
482 return $this;
483 }
484
485 public function isInvalidated() : bool
486 {
487 return $this->invalidated;
488 }
489}
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
Class ilStudyProgrammeProgress.
setAssignmentDate(DateTime $assignment_date)
Set the date of assignment.
getId()
Get the id of the progress.
setCurrentAmountOfPoints(int $a_points)
Set the amount of points the user currently has achieved on this node.
getAssignmentDate()
Get the date of assignment.
setStatus(int $a_status)
Set the status of this node.
setCompletionDate(DateTime $completion_date=null)
Set the timestamp of the complition of this progress.
setLastChangeBy(int $a_usr_id=null)
Set the id of the user who did the last change on this progress.
setCompletionBy(int $a_id=null)
Set the completion_by field.
setValidityOfQualification(DateTime $date=null)
Set limited validity of qualification date.
getAssignmentId()
Get the assignment, this progress belongs to.
getAmountOfPoints()
Get the amount of points the user needs to achieve on the subnodes of this node.
getStatus()
Get the status the user has on this node.
getUserId()
Get the id of the user this progress is for.
getValidityOfQualification()
Get the limited validity of qualification date.
setAmountOfPoints(int $a_points)
Get the amount of points the user needs to achieve on the subnodes of this node.
setDeadline(DateTime $deadline=null)
Set the deadline of this progress.
getLastChange()
Get the timestamp of the last change on this progress.
updateLastChange()
Update the last change timestamp to the current time.
getCompletionBy()
Get the id of object or user that lead to the successful completion of this node.
getLastChangeBy()
Get the id of the user who did the last change on this assignment.
setLastChange(DateTime $a_timestamp)
Set the last change timestamp to the given time.
getCurrentAmountOfPoints()
Get the amount of points the user currently has achieved on the node.
getCompletionDate()
Get the timestamp of the complition of this progress.
getNodeId()
Get the id of the program node this progress belongs to.
getDeadline()
Get the deadline of this progress.