19declare(strict_types=1);
65 int $status = self::STATUS_NOT_RELEVANT
69 $this->last_change = new \DateTimeImmutable();
70 $this->assignment_date = new \DateTimeImmutable();
88 throw new ilException(
"ilPRGProgress::setAmountOfPoints: "
89 .
"Expected a number >= 0 as argument, got '$points'");
105 throw new ilException(
"ilPRGProgress::setAmountOfPoints: "
106 .
"Expected a number >= 0 as argument, got '$points'");
109 $clone = clone $this;
121 if (!in_array(
$status, self::$STATUS)) {
122 throw new ilException(
"No such status: " .
"'$status'");
127 "Changing progress with status " . $this->
getStatus()
128 .
" cannot change to status " .
"'$status'"
129 .
' (progress_id: ' . $this->
getId() .
')'
133 $clone = clone $this;
140 return is_null($this->status) ||
141 $this->status === $new_status ||
142 in_array($new_status, self::getAllowedTargetStatusFor($this->status));
147 switch ($status_from) {
196 $clone = clone $this;
204 return $this->assignment_date;
209 $clone = clone $this;
210 $clone->assignment_date = $assignment_date;
216 return $this->completion_date;
221 return $this->completion_by;
225 ?
int $usr_or_obj_id =
null,
226 ?\DateTimeImmutable $completion_date =
null
228 $clone = clone $this;
229 $clone->completion_by = $usr_or_obj_id;
230 $clone->completion_date = $completion_date;
236 return $this->deadline;
239 public function withDeadline(?\DateTimeImmutable $deadline =
null): self
241 $clone = clone $this;
242 $clone->deadline = $deadline;
248 return $this->vq_date;
253 $clone = clone $this;
254 $clone->vq_date = $date;
260 return $this->is_individual;
265 $clone = clone $this;
266 $clone->is_individual = $individual;
275 self::STATUS_COMPLETED,
276 self::STATUS_ACCREDITED
287 if (!$this->isSuccessful()) {
291 is_null($this->getValidityOfQualification()) ||
292 $this->getValidityOfQualification()->format(self::DATE_FORMAT) >= $now->format(self::DATE_FORMAT)
298 return $this->getStatus() != self::STATUS_NOT_RELEVANT;
303 return $this->getStatus() == self::STATUS_FAILED;
308 return $this->getStatus() == self::STATUS_ACCREDITED;
313 return $this->getStatus() == self::STATUS_IN_PROGRESS;
319 $children = $this->getSubnodes();
320 foreach ($children as $child_progress) {
321 if ($child_progress->isSuccessful()) {
322 $sum += $child_progress->getAmountOfPoints();
331 $children = $this->getSubnodes();
332 foreach ($children as $child_progress) {
333 if ($child_progress->isRelevant()) {
334 $sum += $child_progress->getAmountOfPoints();
342 if (!$this->vq_date) {
343 throw new ilException(
"may not invalidate non-expired progress (no invalidation date)");
345 if ($this->vq_date->format(self::DATE_FORMAT) > date(self::DATE_FORMAT)) {
346 $msg = $this->vq_date->format(self::DATE_FORMAT) .
' > ' . date(self::DATE_FORMAT);
347 throw new ilException(
"may not invalidate non-expired progress ($msg)");
349 return $this->withInvalidated(
true);
354 return $this->invalidated;
359 $clone = clone $this;
360 $clone->invalidated = $invalidated;
364 public function markAccredited(\DateTimeImmutable $date,
int $acting_usr_id): self
367 ->withStatus(self::STATUS_ACCREDITED)
368 ->withCompletion($acting_usr_id, $date)
369 ->withLastChange($acting_usr_id, $date);
375 ->withStatus(self::STATUS_IN_PROGRESS)
376 ->withCompletion(
null,
null)
377 ->withValidityOfQualification(
null)
378 ->withLastChange($acting_usr_id, $date);
381 public function markFailed(\DateTimeImmutable $date,
int $acting_usr_id): self
384 ->withStatus(self::STATUS_FAILED)
385 ->withCompletion(
null,
null)
386 ->withLastChange($acting_usr_id, $date);
389 public function markNotFailed(\DateTimeImmutable $date,
int $acting_usr_id): self
392 ->withStatus(self::STATUS_IN_PROGRESS)
393 ->withCompletion(
null,
null)
394 ->withLastChange($acting_usr_id, $date);
397 public function succeed(\DateTimeImmutable $date,
int $triggering_obj_id): self
400 ->withStatus(self::STATUS_COMPLETED)
401 ->withCompletion($triggering_obj_id, $date)
402 ->withLastChange($triggering_obj_id, $date);
408 ->withStatus(self::STATUS_NOT_RELEVANT)
409 ->withLastChange($acting_usr_id, $date)
410 ->withValidityOfQualification(
null)
412 ->withCompletion(
null,
null)
413 ->withCurrentAmountOfPoints(0)
414 ->withIndividualModifications(
true);
417 public function markRelevant(\DateTimeImmutable $date,
int $acting_usr_id): self
420 ->withStatus(self::STATUS_IN_PROGRESS)
421 ->withCompletion(
null,
null)
422 ->withLastChange($acting_usr_id, $date)
423 ->withIndividualModifications(
true);
Base class for ILIAS Exception handling.
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
getAchievedPointsOfChildren()
withLastChange(int $last_change_by, \DateTimeImmutable $last_change)
withCurrentAmountOfPoints(int $points_cur)
markFailed(\DateTimeImmutable $date, int $acting_usr_id)
DateTimeImmutable $deadline
markAccredited(\DateTimeImmutable $date, int $acting_usr_id)
hasValidQualification(\DateTimeImmutable $now)
There may be no qualification at all (since the PRG is not passed), or the qualification is valid or ...
DateTimeImmutable $last_change
withInvalidated(bool $invalidated)
withAmountOfPoints(int $points)
const COMPLETED_BY_SUBNODES
succeed(\DateTimeImmutable $date, int $triggering_obj_id)
withCompletion(?int $usr_or_obj_id=null, ?\DateTimeImmutable $completion_date=null)
withIndividualModifications(bool $individual)
hasIndividualModifications()
getPossiblePointsOfRelevantChildren()
isTransitionAllowedTo(int $new_status)
unmarkAccredited(\DateTimeImmutable $date, int $acting_usr_id)
DateTimeImmutable $assignment_date
withDeadline(?\DateTimeImmutable $deadline=null)
__construct(int $prg_obj_id, int $status=self::STATUS_NOT_RELEVANT)
withAssignmentDate(?\DateTimeImmutable $assignment_date)
withValidityOfQualification(?\DateTimeImmutable $date=null)
static getAllowedTargetStatusFor(int $status_from)
const STATUS_NOT_RELEVANT
getValidityOfQualification()
markRelevant(\DateTimeImmutable $date, int $acting_usr_id)
DateTimeImmutable $vq_date
getCurrentAmountOfPoints()
markNotFailed(\DateTimeImmutable $date, int $acting_usr_id)
DateTimeImmutable $completion_date
markNotRelevant(\DateTimeImmutable $date, int $acting_usr_id)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc