19 declare(strict_types=1);
32 private readonly ?
int $active_id =
null,
33 private readonly ?
int $test_id =
null,
34 private readonly ?
string $anonymous_id =
null,
35 private readonly
string $firstname =
'',
36 private readonly
string $lastname =
'',
37 private readonly
string $login =
'',
38 private readonly
string $matriculation =
'',
39 private int $extra_time = 0,
40 private readonly
int $attempts = 0,
41 private ?
string $client_ip_from =
null,
42 private ?
string $client_ip_to =
null,
43 private readonly ?
int $invitation_date =
null,
44 private readonly ?
bool $submitted =
null,
45 private readonly ?
int $last_started_attempt =
null,
46 private readonly ?
int $last_finished_attempt =
null,
47 private readonly
bool $unfinished_attempts =
false,
60 return $this->active_id;
65 return $this->test_id;
70 return $this->anonymous_id;
75 return $this->firstname;
80 return $this->lastname;
90 return $this->matriculation;
95 return $this->extra_time;
100 $clone = clone $this;
101 $clone->extra_time += $extra_time;
107 return $this->attempts;
112 return $this->client_ip_from;
120 $clone = clone $this;
121 $clone->client_ip_from = $ip;
127 return $this->client_ip_to;
135 $clone = clone $this;
136 $clone->client_ip_to = $ip;
142 return $this->invitation_date > 0;
147 return $this->submitted;
152 if (!$processing_time) {
156 return $processing_time + $this->extra_time * 60;
161 return $this->last_started_attempt;
166 return $this->last_finished_attempt;
171 return $this->unfinished_attempts;
176 return $this->first_access;
181 return $this->last_access;
186 return $this->attempt_overview?->hasAnsweredQuestions() ??
false;
190 int $processing_time,
191 bool $reset_time_on_new_attempt
196 if ($reset_time_on_new_attempt) {
197 $start = $this->running_attempt_start?->getTimestamp();
200 if ($start ===
null) {
204 $remaining += $start;
205 if ($this->submitted) {
206 $remaining -= $this->
getLastAccess()?->getTimestamp() ?? time();
208 $remaining -= time();
211 return max(0, $remaining);
221 $clone = clone $this;
228 $clone = clone $this;
229 $clone->running_attempt_start = $start_date;
withRunningAttemptStart(\DateTimeImmutable $start_date)
withAttemptOverviewInformation(?AttemptOverview $attempt_overview)
getAttemptOverviewInformation()
withAddedExtraTime(int $extra_time)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withClientIpTo(?string $ip)
DateTimeImmutable $running_attempt_start
getTotalDuration(?int $processing_time)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(private readonly int $user_id, private readonly ?int $active_id=null, private readonly ?int $test_id=null, private readonly ?string $anonymous_id=null, private readonly string $firstname='', private readonly string $lastname='', private readonly string $login='', private readonly string $matriculation='', private int $extra_time=0, private readonly int $attempts=0, private ?string $client_ip_from=null, private ?string $client_ip_to=null, private readonly ?int $invitation_date=null, private readonly ?bool $submitted=null, private readonly ?int $last_started_attempt=null, private readonly ?int $last_finished_attempt=null, private readonly bool $unfinished_attempts=false, private readonly ?\DateTimeImmutable $first_access=null, private readonly ?\DateTimeImmutable $last_access=null)
AttemptOverview $attempt_overview
hasAnsweredQuestionsForScoredAttempt()
getRemainingDuration(int $processing_time, bool $reset_time_on_new_attempt)
withClientIpFrom(?string $ip)