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;
155 return $this->invitation_date > 0;
160 return $this->submitted;
165 if (!$processing_time) {
169 return $processing_time + $this->extra_time * 60;
174 return $this->last_started_attempt;
179 return $this->last_finished_attempt;
184 return $this->unfinished_attempts;
189 return $this->first_access;
194 return $this->last_access;
199 return $this->attempt_overview?->hasAnsweredQuestions() ??
false;
203 int $processing_time,
204 bool $reset_time_on_new_attempt
209 if ($reset_time_on_new_attempt) {
210 $start = $this->running_attempt_start?->getTimestamp();
213 if ($start ===
null) {
217 $remaining += $start;
218 if ($this->submitted) {
219 $remaining -= $this->
getLastAccess()?->getTimestamp() ?? time();
221 $remaining -= time();
224 return max(0, $remaining);
229 return $this->attempt_overview;
234 $clone = clone $this;
235 $clone->attempt_overview = $attempt_overview;
241 $clone = clone $this;
242 $clone->running_attempt_start = $start_date;
248 return $this->scoring_finalized;
253 if ($this->user_id ===
ANONYMOUS_USER_ID && $this->importname !==
null && $this->importname !==
'') {
254 return "{$this->importname} ({$language->txt('imported')})";
257 if ($anonymous_test) {
258 return $language->
txt(
'anonymous');
261 if ($this->
login ===
'' && $this->firstname ===
'' && $this->lastname ===
'') {
262 return $language->
txt(
'user_deleted');
267 if ($this->lastname !==
'') {
268 $display_name .= $this->lastname;
271 if ($this->firstname !==
'') {
272 $display_name .= $display_name ===
''
274 :
", {$this->firstname}";
277 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|LanguageIdentifier $a_topic, ?int $n=null)
$n selects a plural form, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...