ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilExcAssMemberState.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
34{
38 protected $ass_id;
39
43 protected $user_id;
44
48 protected $assignment;
49
53 protected $member_id;
54
58 protected $team_id = 0;
59
63 protected $is_team = false;
64
70 protected function __construct(ilExAssignment $a_ass, ilObjUser $a_user, ilExcIndividualDeadline $a_idl, $a_time, ilLanguage $lng, ilExAssignmentTeam $a_team = null)
71 {
72 $this->time = $a_time;
73 $this->ass_id = $a_ass->getId();
74 $this->user_id = $a_user->getId();
75 $this->member_id = $a_user->getId();
76 $this->lng = $lng;
77
78 $this->assignment = $a_ass;
79
80 // check team status
81 $this->is_team = false;
82 if ($this->assignment->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
83 if ($a_team->getId()) {
84 $this->member_id = $a_team->getId();
85 $this->team_id = $a_team->getId();
86 $this->is_team = true;
87 }
88 }
89
90 $this->idl = $a_idl;
91 }
92
100 public static function getInstanceByIds($a_ass_id, $a_user_id = 0)
101 {
102 global $DIC;
103
104 $lng = $DIC->language();
105 $user = ($a_user_id > 0)
106 ? new ilObjUser($a_user_id)
107 : $DIC->user();
108
109 $ass = new ilExAssignment($a_ass_id);
110
111 $member_id = $user->getId();
112 $is_team = false;
113 $team = null;
114 if ($ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) { // better move this to ilExcIndividualDeadline
115 $team = ilExAssignmentTeam::getInstanceByUserId($a_ass_id, $user->getId());
116 if ($team->getId()) {
117 $member_id = $team->getId();
118 $is_team = true;
119 }
120 }
121
122 // note: team may be not null, but is_team still false
124
125 return self::getInstance($ass, $user, $idl, time(), $lng, $team);
126 }
127
133 public static function getInstance(ilExAssignment $a_ass, ilObjUser $a_user, ilExcIndividualDeadline $a_idl, $a_time, ilLanguage $lng, ilExAssignmentTeam $a_team = null)
134 {
135 return new self($a_ass, $a_user, $a_idl, $a_time, $lng, $a_team);
136 }
137
144 {
145 return $this->idl;
146 }
147
148
155 public function getGeneralStart()
156 {
157 return $this->assignment->getStartTime();
158 }
159
166 {
167 if ($this->getGeneralStart()) {
168 return $this->getTimePresentation($this->getGeneralStart());
169 }
170 return "";
171 }
172
178 public function getIndividualStart()
179 {
180 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
181 return $this->idl->getStartingTimestamp();
182 }
183 return 0;
184 }
185
186
192 public function hasGenerallyStarted()
193 {
194 return !$this->assignment->notStartedYet();
195 }
196
203 public function getCalculatedDeadline()
204 {
205 $calculated_deadline = 0;
206 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
207 if ($this->idl->getStartingTimestamp() && $this->assignment->getRelativeDeadline()) {
208 $calculated_deadline = $this->idl->getStartingTimestamp() + ($this->assignment->getRelativeDeadline() * 24 * 60 * 60);
209 }
210 if ($this->assignment->getRelDeadlineLastSubmission() > 0 &&
211 $calculated_deadline > $this->assignment->getRelDeadlineLastSubmission()) {
212 $calculated_deadline = $this->assignment->getRelDeadlineLastSubmission();
213 }
214 }
215 return $calculated_deadline;
216 }
217
223 public function getRelativeDeadline()
224 {
225 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
226 return $this->assignment->getRelativeDeadline();
227 }
228 return 0;
229 }
230
237 {
238 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
239 return $this->assignment->getRelDeadlineLastSubmission();
240 }
241 return 0;
242 }
243
244
251 {
252 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE) {
253 return $this->getRelativeDeadline() . " " . $this->lng->txt("days");
254 }
255 return "";
256 }
257
265 public function getOfficialDeadline()
266 {
267 $dl = $this->idl->getIndividualDeadline(); // team or user individual deadline
268
269 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE) { // absolute deadline
270 return max($this->assignment->getDeadline(), $dl); // take what's greater: idl or abs deadline
271 }
272
273 // relative deadline: take max idl or calculated deadline
274 return max($this->getCalculatedDeadline(), $dl);
275 }
276
277
284 {
285 if ($this->getOfficialDeadline() > 0) {
286 return $this->getTimePresentation($this->getOfficialDeadline());
287 }
288
289 return "";
290 }
291
298 {
299 if ($this->getLastSubmissionOfRelativeDeadline() > 0) {
301 }
302
303 return "";
304 }
305
306
307
313 public function exceededOfficialDeadline()
314 {
315 $od = $this->getOfficialDeadline();
316 if ($od && $od < time()) {
317 return true;
318 }
319 return false;
320 }
321
329 {
331 $official_deadline = $this->getOfficialDeadline();
332 if ($official_deadline == 0) {
333 return $lng->txt("exc_no_deadline_specified");
334 }
335 if ($official_deadline - $this->time <= 0) {
336 $time_str = $lng->txt("exc_time_over_short");
337 } else {
338 $time_str = ilUtil::period2String(new ilDateTime($official_deadline, IL_CAL_UNIX));
339 }
340
341 return $time_str;
342 }
343
349 public function getIndividualDeadline()
350 {
351 if ($this->idl->getIndividualDeadline() > $this->getCommonDeadline()) {
352 return $this->idl->getIndividualDeadline();
353 }
354 return 0;
355 }
356
357
364 {
365 if ($this->getIndividualDeadline() > 0) {
366 return $this->getTimePresentation($this->getIndividualDeadline());
367 }
368
369 return "";
370 }
371
377 public function getCommonDeadline()
378 {
379 if ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE) { // absolute deadline
380 return $this->assignment->getDeadline();
381 }
382
383 return $this->getCalculatedDeadline();
384 }
385
392 {
393 if ($this->getCommonDeadline() > 0) {
394 return $this->getTimePresentation($this->getCommonDeadline());
395 }
396
397 return "no deadline";
398 }
399
405 public function getEffectiveDeadline()
406 {
407 return max($this->getOfficialDeadline(), $this->assignment->getExtendedDeadline());
408 }
409
415 public function getPeerReviewDeadline()
416 {
417 if ($this->assignment->getPeerReview() &&
418 $this->assignment->getPeerReviewDeadline()) {
419 return $this->assignment->getPeerReviewDeadline();
420 }
421 return 0;
422 }
423
430 {
431 if ($this->getPeerReviewDeadline() > 0) {
432 return $this->getTimePresentation($this->getPeerReviewDeadline());
433 }
434
435 return "no peer review deadline";
436 }
437
443 public function isPeerReviewAllowed()
444 {
445 if ($this->assignment->getPeerReview() && $this->hasSubmissionEndedForAllUsers()
446 && ($this->getPeerReviewDeadline() == 0 || $this->getPeerReviewDeadline() > $this->time)) {
447 return true;
448 }
449
450 return false;
451 }
452
458 protected function getTimePresentation($a_timestamp)
459 {
460 if ($a_timestamp > 0) {
461 return ilDatePresentation::formatDate(new ilDateTime($a_timestamp, IL_CAL_UNIX));
462 }
463
464 return "";
465 }
466
472 public function areInstructionsVisible()
473 {
474 return $this->hasSubmissionStarted();
475 }
476
483 /*
484 function getLateSubmissionWarning()
485 {
486 $lng = $this->lng;
487 $late_dl = "";
488
489 // official deadline is done, but submission still allowed
490 if ($this->inLateSubmissionPhase())
491 {
492 // extended deadline date should not be presented anywhere
493 $late_dl = $this->getTimePresentation($this->getOfficialDeadline());
494 $late_dl = "<br />".sprintf($lng->txt("exc_late_submission_warning"), $late_dl);
495 $late_dl = '<span class="warning">'.$late_dl.'</span>';
496 }
497
498 return $late_dl;
499 }*/
500
507 public function inLateSubmissionPhase()
508 {
509 // official deadline is done, but submission still allowed
510 if ($this->getOfficialDeadline() &&
511 $this->getOfficialDeadline() < $this->time &&
512 $this->isSubmissionAllowed()) {
513 return true;
514 }
515 return false;
516 }
517
518
526 public function hasSubmissionStarted()
527 {
528 if ($this->hasGenerallyStarted() && ($this->assignment->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE ||
529 $this->getIndividualStart() > 0)) {
530 return true;
531 }
532 return false;
533 }
534
540 public function hasSubmissionEnded()
541 {
542 if ($this->getEffectiveDeadline() == 0) {
543 return false;
544 }
545
546 if ($this->time > $this->getEffectiveDeadline()) {
547 return true;
548 }
549 return false;
550 }
551
559 {
560 $global_subm_end = max($this->getEffectiveDeadline(), $this->assignment->getLastPersonalDeadline());
561
562 if ($global_subm_end == 0) {
563 return false;
564 }
565
566 if ($this->time > $global_subm_end) {
567 return true;
568 }
569 return false;
570 }
571
572
573
580 public function isSubmissionAllowed()
581 {
582 if ($this->hasSubmissionStarted() && !$this->hasSubmissionEnded()) {
583 return true;
584 }
585 return false;
586 }
587
594 {
595 $access = false;
596
597 if (!$this->assignment->getFeedbackFile()) {
598 return false;
599 }
600
601 // global feedback / sample solution
602 if ($this->assignment->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_DEADLINE) {
603 $access = $this->hasSubmissionEndedForAllUsers();
604 } elseif ($this->assignment->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_CUSTOM) {
605 $access = $this->assignment->afterCustomDate();
606 } else {
607 $access = $submission->hasSubmitted();
608 }
609
610 return $access;
611 }
612}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Exercise assignment team.
static getInstanceByUserId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
Exercise assignment.
getId()
Get assignment id.
Exercise submission //TODO: This class has to much static methods related to delivered "files".
Handles everything about the state (current phase) of a user in an assignment using assignment,...
getPeerReviewDeadlinePresentation()
Get common deadline presentation.
areInstructionsVisible()
Instructions visible.
getOfficialDeadline()
Get official deadline (individual deadline, fixed deadline or calculated deadline (using relative dea...
hasSubmissionEnded()
Check if the submission phase has ended for the current user.
getTimePresentation($a_timestamp)
Get common deadline presentation.
getRemainingTimePresentation()
Remaining time presentation (based on official deadline)
getIndividualStart()
Get individual start.
getEffectiveDeadline()
Get effective deadline (max of official deadline and grace end period) for the user.
exceededOfficialDeadline()
Check if official deadline exists and has ended.
__construct(ilExAssignment $a_ass, ilObjUser $a_user, ilExcIndividualDeadline $a_idl, $a_time, ilLanguage $lng, ilExAssignmentTeam $a_team=null)
ilExcAssMemberState constructor.
hasSubmissionStarted()
Check if the submission phase has started for the current user.
isPeerReviewAllowed()
Is submission currently allowed.
getIndividualDeadlinePresentation()
Get common deadline presentation.
getLastSubmissionOfRelativeDeadline()
Get last submission for relative deadline.
getCommonDeadline()
Get common deadline (no individual deadline or grace period included)
getRelativeDeadline()
Get relative deadline.
getGeneralStart()
Get general start.
getLastSubmissionOfRelativeDeadlinePresentation()
Get last submission for relative deadlines.
getIndividualDeadline()
Get individual deadline.
getCommonDeadlinePresentation()
Get common deadline presentation.
isSubmissionAllowed()
Is submission currently allowed.
isGlobalFeedbackFileAccessible(ilExSubmission $submission)
Is global feedback file accessible?
getRelativeDeadlinePresentation()
Get relative deadline presentation.
getIndividualDeadlineObject()
Get individual deadline object.
inLateSubmissionPhase()
Get late submission warning.
getPeerReviewDeadline()
Get peer review deadline.
getOfficialDeadlinePresentation()
Get official deadline presentation.
getCalculatedDeadline()
Calculated deadline is only given, if a relative deadline is given and the user started the assignmen...
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)
hasSubmissionEndedForAllUsers()
Has submission ended for all users.
static getInstance(ilExAssignment $a_ass, ilObjUser $a_user, ilExcIndividualDeadline $a_idl, $a_time, ilLanguage $lng, ilExAssignmentTeam $a_team=null)
Get instance by dependencies.
getGeneralStartPresentation()
Get start presentation.
static getInstance($a_ass_id, $a_participant_id, $a_is_team=false)
Get instance.
language handling
getId()
get object id @access public
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
$lng
$DIC
Definition: xapitoken.php:46