19declare(strict_types=1);
33 private readonly ?
int $active_id =
null,
34 private readonly ?
int $test_id =
null,
35 private readonly ?
string $anonymous_id =
null,
36 private readonly
string $firstname =
'',
37 private readonly
string $lastname =
'',
38 private readonly
string $login =
'',
39 private readonly ?
string $importname =
null,
40 private readonly
string $matriculation =
'',
41 private int $extra_time = 0,
42 private readonly
int $attempts = 0,
43 private ?
string $client_ip_from =
null,
44 private ?
string $client_ip_to =
null,
45 private readonly ?
int $invitation_date =
null,
46 private readonly ?
bool $submitted =
null,
47 private readonly ?
int $last_started_attempt =
null,
48 private readonly ?
int $last_finished_attempt =
null,
49 private readonly
bool $unfinished_attempts =
false,
50 private readonly ?\DateTimeImmutable $first_access =
null,
51 private readonly ?\DateTimeImmutable $last_access =
null,
52 private readonly
bool $scoring_finalized =
false
63 return $this->active_id;
68 return $this->test_id;
73 return $this->anonymous_id;
78 return $this->firstname;
83 return $this->lastname;
93 return $this->importname;
98 return $this->matriculation;
103 return $this->extra_time;
108 $clone = clone $this;
109 $clone->extra_time += $extra_time;
115 return $this->attempts;
120 return $this->client_ip_from;
128 $clone = clone $this;
129 $clone->client_ip_from = $ip;
135 return $this->client_ip_to;
143 $clone = clone $this;
144 $clone->client_ip_to = $ip;
150 return $this->invitation_date > 0;
155 return $this->submitted;
160 if (!$processing_time) {
164 return $processing_time + $this->extra_time * 60;
169 return $this->last_started_attempt;
174 return $this->last_finished_attempt;
179 return $this->unfinished_attempts;
184 return $this->first_access;
189 return $this->last_access;
194 return $this->attempt_overview?->hasAnsweredQuestions() ??
false;
198 int $processing_time,
199 bool $reset_time_on_new_attempt
204 if ($reset_time_on_new_attempt) {
205 $start = $this->running_attempt_start?->getTimestamp();
208 if ($start ===
null) {
212 $remaining += $start;
213 if ($this->submitted) {
214 $remaining -= $this->
getLastAccess()?->getTimestamp() ?? time();
216 $remaining -= time();
219 return max(0, $remaining);
224 return $this->attempt_overview;
229 $clone = clone $this;
230 $clone->attempt_overview = $attempt_overview;
236 $clone = clone $this;
237 $clone->running_attempt_start = $start_date;
243 return $this->scoring_finalized;
248 if ($this->user_id ===
ANONYMOUS_USER_ID && $this->importname !==
null && $this->importname !==
'') {
249 return "{$this->importname} ({$language->txt('imported')})";
252 if ($anonymous_test) {
253 return $language->
txt(
'anonymous');
258 if ($this->firstname) {
259 $display_name .= $this->firstname .
' ';
261 if ($this->lastname) {
262 $display_name .= $this->lastname;
265 return $display_name;
hasAnsweredQuestionsForScoredAttempt()
getDisplayName(Language $language, bool $anonymous_test=false)
getTotalDuration(?int $processing_time)
withClientIpFrom(?string $ip)
withRunningAttemptStart(\DateTimeImmutable $start_date)
withAttemptOverviewInformation(?AttemptOverview $attempt_overview)
AttemptOverview $attempt_overview
__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 $importname=null, 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, private readonly bool $scoring_finalized=false)
withAddedExtraTime(int $extra_time)
getRemainingDuration(int $processing_time, bool $reset_time_on_new_attempt)
withClientIpTo(?string $ip)
DateTimeImmutable $running_attempt_start
getAttemptOverviewInformation()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...