ILIAS  release_8 Revision v8.24
class.ilExcAssMemberState.php
Go to the documentation of this file.
1<?php
2
47{
48 protected int $ass_id;
49 protected int $user_id;
51 protected int $time;
52 protected ilLanguage $lng;
53
58 protected ?int $member_id;
59 protected ?int $team_id = 0;
60 protected bool $is_team = false;
62
63 protected function __construct(
64 ilExAssignment $a_ass,
65 ilObjUser $a_user,
67 int $a_time,
69 ilExAssignmentTeam $a_team = null
70 ) {
71 $this->time = $a_time;
72 $this->ass_id = $a_ass->getId();
73 $this->user_id = $a_user->getId();
74 $this->member_id = $a_user->getId();
75 $this->lng = $lng;
76
77 $this->assignment = $a_ass;
78
79 // check team status
80 $this->is_team = false;
81 if ($this->assignment->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
82 if ($a_team->getId()) {
83 $this->member_id = $a_team->getId();
84 $this->team_id = $a_team->getId();
85 $this->is_team = true;
86 }
87 }
88
89 $this->idl = $a_idl;
90 }
91
92 // Get instance by IDs (recommended for consumer code)
93 public static function getInstanceByIds(
94 int $a_ass_id,
95 int $a_user_id = 0
97 global $DIC;
98
99 $lng = $DIC->language();
100 $user = ($a_user_id > 0)
101 ? new ilObjUser($a_user_id)
102 : $DIC->user();
103
104 $ass = new ilExAssignment($a_ass_id);
105
106 $member_id = $user->getId();
107 $is_team = false;
108 $team = null;
109 if ($ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) { // better move this to ilExcIndividualDeadline
110 $team = ilExAssignmentTeam::getInstanceByUserId($a_ass_id, $user->getId());
111 if ($team->getId()) {
112 $member_id = $team->getId();
113 $is_team = true;
114 }
115 }
116
117 // note: team may be not null, but is_team still false
119
120 return self::getInstance($ass, $user, $idl, time(), $lng, $team);
121 }
122
126 public static function getInstance(
127 ilExAssignment $a_ass,
128 ilObjUser $a_user,
130 int $a_time,
132 ilExAssignmentTeam $a_team = null
134 return new self($a_ass, $a_user, $a_idl, $a_time, $lng, $a_team);
135 }
136
138 {
139 return $this->idl;
140 }
141
142 public function getGeneralStart(): ?int
143 {
144 return $this->assignment->getStartTime();
145 }
146
151 public function getGeneralStartPresentation(): string
152 {
153 if ($this->getGeneralStart()) {
154 return $this->getTimePresentation($this->getGeneralStart());
155 }
156 return "";
157 }
158
159 public function getIndividualStart(): int
160 {
161 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
162 return $this->idl->getStartingTimestamp();
163 }
164 return 0;
165 }
166
167 public function hasGenerallyStarted(): bool
168 {
169 return !$this->assignment->notStartedYet();
170 }
171
177 public function getCalculatedDeadline(): int
178 {
179 $calculated_deadline = 0;
180 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
181 if ($this->idl->getStartingTimestamp() && $this->assignment->getRelativeDeadline()) {
182 $calculated_deadline = $this->idl->getStartingTimestamp() + ($this->assignment->getRelativeDeadline() * 24 * 60 * 60);
183 }
184 if ($this->assignment->getRelDeadlineLastSubmission() > 0 &&
185 $calculated_deadline > $this->assignment->getRelDeadlineLastSubmission()) {
186 $calculated_deadline = $this->assignment->getRelDeadlineLastSubmission();
187 }
188 }
189 return $calculated_deadline;
190 }
191
192 public function getRelativeDeadline(): int
193 {
194 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
195 return $this->assignment->getRelativeDeadline();
196 }
197 return 0;
198 }
199
201 {
202 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
203 return $this->assignment->getRelDeadlineLastSubmission();
204 }
205 return 0;
206 }
207
208 public function getRelativeDeadlinePresentation(): string
209 {
210 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
211 return $this->getRelativeDeadline() . " " . $this->lng->txt("days");
212 }
213 return "";
214 }
215
221 public function getOfficialDeadline(): int
222 {
223 $dl = $this->idl->getIndividualDeadline(); // team or user individual deadline
224
225 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE) { // absolute deadline
226 return max($this->assignment->getDeadline(), $dl); // take what's greater: idl or abs deadline
227 }
228
229 // relative deadline: take max idl or calculated deadline
230 return max($this->getCalculatedDeadline(), $dl);
231 }
232
237 public function getOfficialDeadlinePresentation(): string
238 {
239 if ($this->getOfficialDeadline() > 0) {
240 return $this->getTimePresentation($this->getOfficialDeadline());
241 }
242
243 return "";
244 }
245
251 {
252 if ($this->getLastSubmissionOfRelativeDeadline() > 0) {
253 return $this->getTimePresentation($this->getLastSubmissionOfRelativeDeadline());
254 }
255
256 return "";
257 }
258
259 // Check if official deadline exists and has ended
260 public function exceededOfficialDeadline(): bool
261 {
262 $od = $this->getOfficialDeadline();
263 if ($od && $od < time()) {
264 return true;
265 }
266 return false;
267 }
268
274 public function getRemainingTimePresentation(): string
275 {
277 $official_deadline = $this->getOfficialDeadline();
278 if ($official_deadline == 0) {
279 return $lng->txt("exc_no_deadline_specified");
280 }
281 if ($official_deadline - $this->time <= 0) {
282 $time_str = $lng->txt("exc_time_over_short");
283 } else {
284 $time_str = ilLegacyFormElementsUtil::period2String(new ilDateTime($official_deadline, IL_CAL_UNIX));
285 }
286
287 return $time_str;
288 }
289
290 public function getIndividualDeadline(): int
291 {
292 if ($this->idl->getIndividualDeadline() > $this->getCommonDeadline()) {
293 return $this->idl->getIndividualDeadline();
294 }
295 return 0;
296 }
297
302 public function getIndividualDeadlinePresentation(): string
303 {
304 if ($this->getIndividualDeadline() > 0) {
305 return $this->getTimePresentation($this->getIndividualDeadline());
306 }
307
308 return "";
309 }
310
311 // Get common deadline (no individual deadline or grace period included)
312 public function getCommonDeadline(): int
313 {
314 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE) { // absolute deadline
315 return $this->assignment->getDeadline();
316 }
317
318 return $this->getCalculatedDeadline();
319 }
320
325 public function getCommonDeadlinePresentation(): string
326 {
327 if ($this->getCommonDeadline() > 0) {
328 return $this->getTimePresentation($this->getCommonDeadline());
329 }
330
331 return "no deadline";
332 }
333
334 // Get effective deadline (max of official deadline and grace end period) for the user
335 public function getEffectiveDeadline(): int
336 {
337 return max($this->getOfficialDeadline(), $this->assignment->getExtendedDeadline());
338 }
339
340 public function getPeerReviewDeadline(): int
341 {
342 if ($this->assignment->getPeerReview() &&
343 $this->assignment->getPeerReviewDeadline()) {
344 return $this->assignment->getPeerReviewDeadline();
345 }
346 return 0;
347 }
348
353 public function getPeerReviewDeadlinePresentation(): string
354 {
355 if ($this->getPeerReviewDeadline() > 0) {
356 return $this->getTimePresentation($this->getPeerReviewDeadline());
357 }
358
359 return "no peer review deadline";
360 }
361
362 // Is peer reviewing currently allowed
363 public function isPeerReviewAllowed(): bool
364 {
365 if ($this->assignment->getPeerReview() && $this->hasSubmissionEndedForAllUsers()
366 && ($this->getPeerReviewDeadline() == 0 || $this->getPeerReviewDeadline() > $this->time)) {
367 return true;
368 }
369
370 return false;
371 }
372
378 protected function getTimePresentation($a_timestamp): string
379 {
380 if ($a_timestamp > 0) {
381 return ilDatePresentation::formatDate(new ilDateTime($a_timestamp, IL_CAL_UNIX));
382 }
383
384 return "";
385 }
386
387 public function areInstructionsVisible(): bool
388 {
389 return $this->hasSubmissionStarted();
390 }
391
392 public function inLateSubmissionPhase(): bool
393 {
394 // official deadline is done, but submission still allowed
395 if ($this->getOfficialDeadline() &&
396 $this->getOfficialDeadline() < $this->time &&
397 $this->isSubmissionAllowed()) {
398 return true;
399 }
400 return false;
401 }
402
403
409 public function hasSubmissionStarted(): bool
410 {
411 if ($this->hasGenerallyStarted() && ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE ||
412 $this->getIndividualStart() > 0)) {
413 return true;
414 }
415 return false;
416 }
417
418 // Check if the submission phase has ended for the current user
419 public function hasSubmissionEnded(): bool
420 {
421 if ($this->getEffectiveDeadline() == 0) {
422 return false;
423 }
424
425 if ($this->time > $this->getEffectiveDeadline()) {
426 return true;
427 }
428 return false;
429 }
430
431 // Has submission ended for all users
432 public function hasSubmissionEndedForAllUsers(): bool
433 {
434 $global_subm_end = max($this->getEffectiveDeadline(), $this->assignment->getLastPersonalDeadline());
435
436 if ($global_subm_end == 0) {
437 return false;
438 }
439
440 if ($this->time > $global_subm_end) {
441 return true;
442 }
443 return false;
444 }
445
446 public function isSubmissionAllowed(): bool
447 {
448 if ($this->hasSubmissionStarted() && !$this->hasSubmissionEnded()) {
449 return true;
450 }
451 return false;
452 }
453
454 // Is global feedback file accessible?
455 public function isGlobalFeedbackFileAccessible(ilExSubmission $submission): bool
456 {
457 if (!$this->assignment->getFeedbackFile()) {
458 return false;
459 }
460
461 // global feedback / sample solution
462 if ($this->assignment->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_DEADLINE) {
463 $access = $this->hasSubmissionEndedForAllUsers();
464 } elseif ($this->assignment->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_CUSTOM) {
465 $access = $this->assignment->afterCustomDate();
466 } else {
467 $access = $submission->hasSubmitted();
468 }
469
470 return $access;
471 }
472}
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByUserId(int $a_assignment_id, int $a_user_id, bool $a_create_on_demand=false)
Exercise assignment.
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...
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
getOfficialDeadline()
Get official deadline (individual deadline, fixed deadline or calculated deadline (using relative dea...
getRemainingTimePresentation()
Remaining time presentation (based on official deadline)
static getInstance(ilExAssignment $a_ass, ilObjUser $a_user, ilExcIndividualDeadline $a_idl, int $a_time, ilLanguage $lng, ilExAssignmentTeam $a_team=null)
Usually you should prefer to use getInstanceByIds.
hasSubmissionStarted()
Check if the submission phase has started for the current user (if the assignment is generally starte...
__construct(ilExAssignment $a_ass, ilObjUser $a_user, ilExcIndividualDeadline $a_idl, int $a_time, ilLanguage $lng, ilExAssignmentTeam $a_team=null)
int $member_id
either user id or team id, if this is a team assignment and the user is member of a team,...
isGlobalFeedbackFileAccessible(ilExSubmission $submission)
ilExcIndividualDeadline $idl
getCalculatedDeadline()
Calculated deadline is only given, if a relative deadline is given and the user started the assignmen...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_ass_id, int $a_participant_id, bool $a_is_team=false)
language handling
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
User class.
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']
global $DIC
Definition: feed.php:28
$lng