ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilPRGAssignment.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
29{
31
32 public const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
33 public const DATE_FORMAT = 'Y-m-d';
34
35 public const NO_RESTARTED_ASSIGNMENT = -1;
36
37 public const AUTO_ASSIGNED_BY_ROLE = -1;
38 public const AUTO_ASSIGNED_BY_ORGU = -2;
39 public const AUTO_ASSIGNED_BY_COURSE = -3;
40 public const AUTO_ASSIGNED_BY_GROUP = -4;
41 public const AUTO_ASSIGNED_BY_RESTART = -5;
42
43 protected int $id;
44 protected int $usr_id;
45 protected ?\DateTimeImmutable $last_change = null;
46 protected ?int $last_change_by = null;
47 protected ?\DateTimeImmutable $restart_date = null;
49 protected bool $manually_assigned;
53 protected array $progresses = [];
57
58 public function __construct(int $id, int $usr_id)
59 {
60 $this->id = $id;
61 $this->usr_id = $usr_id;
62 $this->events = new PRGNullEvents();
63 }
64
65 public function getId(): int
66 {
67 return $this->id;
68 }
69
70 public function getUserId(): int
71 {
72 return $this->usr_id;
73 }
74
75 public function getLastChangeBy(): int
76 {
78 }
79
80 public function getLastChange(): ?\DateTimeImmutable
81 {
82 return $this->last_change;
83 }
84
85 public function withLastChange(
87 \DateTimeImmutable $last_change
88 ): self {
89 if ($this->getLastChange()
90 && $this->getLastChange()->format(self::DATE_TIME_FORMAT) > $last_change->format(self::DATE_TIME_FORMAT)
91 ) {
92 throw new ilException(
93 "Cannot set last change to an earlier date:"
94 . "\ncurrent: " . $this->getLastChange()->format(self::DATE_TIME_FORMAT)
95 . "\nnew: " . $last_change,
96 1
97 );
98 }
99 $clone = clone $this;
100 $clone->last_change = $last_change;
101 $clone->last_change_by = $last_change_by;
102 return $clone;
103 }
104
105 public function getRestartDate(): ?\DateTimeImmutable
106 {
107 return $this->restart_date;
108 }
109
110 public function getRestartedAssignmentId(): int
111 {
112 return $this->restarted_asssignment_id;
113 }
114
115 public function isRestarted(): bool
116 {
117 return $this->getRestartedAssignmentId() !== -1;
118 }
119
120 public function withRestarted(
121 int $restarted_asssignment_id,
122 ?\DateTimeImmutable $restart_date = null
123 ): self {
124 $clone = clone $this;
125 $clone->restarted_asssignment_id = $restarted_asssignment_id;
126 $clone->restart_date = $restart_date;
127 return $clone;
128 }
129
130 public function isManuallyAssigned(): bool
131 {
132 return $this->manually_assigned;
133 }
134
135 public function withManuallyAssigned(bool $manual): self
136 {
137 $clone = clone $this;
138 $clone->manually_assigned = $manual;
139 return $clone;
140 }
141
142 public function withUserInformation(ilPRGUserInformation $user_info): self
143 {
144 $clone = clone $this;
145 $clone->user_info = $user_info;
146 return $clone;
147 }
149 {
150 return $this->user_info;
151 }
152
153
154 public function withProgressTree(ilPRGProgress $progress): self
155 {
156 $clone = clone $this;
157 $clone->progress = $progress;
158 return $clone;
159 }
161 {
162 return $this->progress;
163 }
164
165 public function getRootId(): int
166 {
167 return $this->progress->getNodeId();
168 }
169
170 public function getProgresses(array &$ret = [], ?ilPRGProgress $pgs = null): array
171 {
172 if (!$pgs) {
173 $pgs = $this->getProgressTree();
174 }
175
176 $ret[] = $pgs;
177 foreach ($pgs->getSubnodes() as $id => $sub) {
178 $this->getProgresses($ret, $sub);
179 }
180 return $ret;
181 }
182
183 public function getProgressForNode(int $node_id): ilPRGProgress
184 {
185 $pgs = $this->getProgressTree();
186 $path = $pgs->findSubnodePath((string) $node_id);
187
188 foreach ($path as $hop) {
189 if ($pgs->getId() !== $hop) {
190 $pgs = $pgs->getSubnode($hop);
191 }
192 }
193 return $pgs;
194 }
195
197 DateTimeImmutable $deadline
198 ): array {
199 return array_values(array_filter(
200 $this->getProgresses(),
201 fn($pgs) => ! is_null($pgs->getDeadline()) && $pgs->getDeadline() <= $deadline
202 ));
203 }
204
205 public function withEvents(StudyProgrammeEvents $events): self
206 {
207 $clone = clone $this;
208 $clone->events = $events;
209 return $clone;
210 }
211
213 {
214 return $this->events;
215 }
216}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Base class for ILIAS Exception handling.
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
withManuallyAssigned(bool $manual)
DateTimeImmutable $restart_date
withRestarted(int $restarted_asssignment_id, ?\DateTimeImmutable $restart_date=null)
withProgressTree(ilPRGProgress $progress)
DateTimeImmutable $last_change
getProgresses(array &$ret=[], ?ilPRGProgress $pgs=null)
withUserInformation(ilPRGUserInformation $user_info)
withEvents(StudyProgrammeEvents $events)
__construct(int $id, int $usr_id)
withLastChange(int $last_change_by, \DateTimeImmutable $last_change)
ilPRGUserInformation $user_info
getProgressesWithDeadline(DateTimeImmutable $deadline)
StudyProgrammeEvents $events
getProgressForNode(int $node_id)
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
Additional information about a user, used in context of assignments.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait ilPRGAssignmentActions
This trait is for (physical) separation of code only; it is actually just part of an ilPRGAssignment ...
if(!file_exists('../ilias.ini.php'))