ILIAS  release_8 Revision v8.24
class.ilPRGAssignment.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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
42 protected int $id;
43 protected int $usr_id;
44 protected ?\DateTimeImmutable $last_change = null;
45 protected ?int $last_change_by = null;
48 protected bool $manually_assigned;
52 protected array $progresses = [];
56
57 public function __construct(int $id, int $usr_id)
58 {
59 $this->id = $id;
60 $this->usr_id = $usr_id;
61 $this->events = new PRGNullEvents();
62 }
63
64 public function getId(): int
65 {
66 return $this->id;
67 }
68
69 public function getUserId(): int
70 {
71 return $this->usr_id;
72 }
73
74 public function getLastChangeBy(): int
75 {
77 }
78
79 public function getLastChange(): ?\DateTimeImmutable
80 {
81 return $this->last_change;
82 }
83
84 public function withLastChange(
86 \DateTimeImmutable $last_change
87 ): self {
88 if ($this->getLastChange()
89 && $this->getLastChange()->format(self::DATE_TIME_FORMAT) > $last_change->format(self::DATE_TIME_FORMAT)
90 ) {
91 throw new ilException(
92 "Cannot set last change to an earlier date:"
93 . "\ncurrent: " . $this->getLastChange()->format(self::DATE_TIME_FORMAT)
94 . "\nnew: " . $last_change,
95 1
96 );
97 }
98 $clone = clone $this;
99 $clone->last_change = $last_change;
100 $clone->last_change_by = $last_change_by;
101 return $clone;
102 }
103
104 public function getRestartDate(): ?\DateTimeImmutable
105 {
106 return $this->restart_date;
107 }
108
109 public function getRestartedAssignmentId(): int
110 {
111 return $this->restarted_asssignment_id;
112 }
113
114 public function isRestarted(): bool
115 {
116 return $this->getRestartedAssignmentId() !== -1;
117 }
118
119 public function withRestarted(
120 int $restarted_asssignment_id,
121 \DateTimeImmutable $restart_date = null
122 ): self {
123 $clone = clone $this;
124 $clone->restarted_asssignment_id = $restarted_asssignment_id;
125 $clone->restart_date = $restart_date;
126 return $clone;
127 }
128
129 public function isManuallyAssigned(): bool
130 {
131 return $this->manually_assigned;
132 }
133
134 public function withManuallyAssigned(bool $manual): self
135 {
136 $clone = clone $this;
137 $clone->manually_assigned = $manual;
138 return $clone;
139 }
140
141 public function withUserInformation(ilPRGUserInformation $user_info): self
142 {
143 $clone = clone $this;
144 $clone->user_info = $user_info;
145 return $clone;
146 }
148 {
149 return $this->user_info;
150 }
151
152
153 public function withProgressTree(ilPRGProgress $progress): self
154 {
155 $clone = clone $this;
156 $clone->progress = $progress;
157 return $clone;
158 }
160 {
161 return $this->progress;
162 }
163
164 public function getRootId(): int
165 {
166 return $this->progress->getNodeId();
167 }
168
169 public function getProgresses(array &$ret = [], ilPRGProgress $pgs = null): array
170 {
171 if (!$pgs) {
172 $pgs = $this->getProgressTree();
173 }
174
175 $ret[] = $pgs;
176 foreach ($pgs->getSubnodes() as $id => $sub) {
177 $this->getProgresses($ret, $sub);
178 }
179 return $ret;
180 }
181
182 public function getProgressForNode(int $node_id): ilPRGProgress
183 {
184 $pgs = $this->getProgressTree();
185 $path = $pgs->findSubnodePath((string) $node_id);
186
187 foreach ($path as $hop) {
188 if ($pgs->getId() !== $hop) {
189 $pgs = $pgs->getSubnode($hop);
190 }
191 }
192 return $pgs;
193 }
194
196 DateTimeImmutable $deadline
197 ): array {
198 return array_values(array_filter(
199 $this->getProgresses(),
200 fn ($pgs) => ! is_null($pgs->getDeadline()) && $pgs->getDeadline() <= $deadline
201 ));
202 }
203
204 public function withEvents(StudyProgrammeEvents $events): self
205 {
206 $clone = clone $this;
207 $clone->events = $events;
208 return $clone;
209 }
210
212 {
213 return $this->events;
214 }
215}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
withManuallyAssigned(bool $manual)
getProgresses(array &$ret=[], ilPRGProgress $pgs=null)
withProgressTree(ilPRGProgress $progress)
DateTimeImmutable $last_change
withRestarted(int $restarted_asssignment_id, \DateTimeImmutable $restart_date=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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
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', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
trait ilPRGAssignmentActions
This trait is for (physical) separation of code only; it is actually just part of an ilPRGAssignment ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:32