19declare(strict_types=1);
33 private readonly
int $active_id,
34 private readonly
int $attempt_id,
35 private readonly ResultPresentationSettings $settings,
36 private readonly
string $exam_id =
'',
37 private readonly
float $reached_points = 0.0,
38 private readonly
float $available_points = 0.0,
39 private readonly ?
Mark $mark =
null,
40 private readonly
int $nr_of_answered_questions = 0,
41 private readonly
int $nr_of_questions_in_attempt = 0,
42 private readonly
int $time_on_task = 0,
43 private readonly
int $total_time_on_task = 0,
44 private readonly ?\DateTimeImmutable $attempt_started_date =
null,
45 private readonly ?\DateTimeImmutable $last_access =
null,
46 private readonly
int $nr_of_attempts = 0,
47 private readonly ?
int $scored_attempt =
null,
48 private readonly ?
int $rank = 0,
49 private readonly
StatusOfAttempt $status_of_attempt = StatusOfAttempt::NOT_YET_STARTED
55 return $this->active_id;
60 return $this->attempt_id;
65 return $this->exam_id;
70 return $this->attempt_started_date;
75 return $this->nr_of_answered_questions;
80 return $this->nr_of_questions_in_attempt;
85 return $this->nr_of_answered_questions > 0;
90 return $this->mark?->getShortName();
95 return $this->mark?->getPassed() ??
false;
100 return $this->reached_points;
105 return $this->available_points;
110 if ($this->reached_points === 0.0 || $this->available_points === 0.0) {
113 return $this->reached_points / $this->available_points * 100;
118 return $this->status_of_attempt;
123 return $this->nr_of_attempts;
128 return $this->total_time_on_task;
133 UIFactory $ui_factory,
135 ): DescriptiveListing {
138 $lng->txt(
'tst_stat_result_resultspoints') =>
139 "{$this->getReachedPoints()} " . strtolower(
$lng->txt(
'of')) .
" {$this->getAvailablePoints()} (" . sprintf(
'%2.2f', $this->
getReachedPointsInPercent()) .
' %)',
140 $lng->
txt(
'tst_stat_result_resultsmarks') => $is_finished
141 ? $this->mark?->getShortName() ??
'-'
145 return $ui_factory->listing()->descriptive(
147 $lng->txt(
'tst_stat_result_timeontask') => $this->buildHumanReadableTime($this->time_on_task),
148 $lng->txt(
'tst_stat_result_firstvisit') => $this->attempt_started_date
149 ?->setTimezone($environment[
'timezone'])
150 ->format($environment[
'datetimeformat']) ??
'',
151 $lng->txt(
'tst_stat_result_lastvisit') => $this->last_access
152 ?->setTimezone($environment[
'timezone'])
153 ->format($environment[
'datetimeformat']) ??
'',
154 $lng->txt(
'tst_nr_of_passes') => (
string) $this->nr_of_attempts,
155 $lng->txt(
'scored_pass') => $is_finished && $this->scored_attempt !==
null ? (
string) ($this->scored_attempt + 1) :
'-',
156 $lng->txt(
'tst_stat_result_rank_participant') => $is_finished ? (
string) $this->rank :
'-',
163 return $this->buildHumanReadableTime($this->total_time_on_task);
168 $diff_seconds = $time;
169 $diff_hours = floor($diff_seconds / 3600);
170 $diff_seconds -= $diff_hours * 3600;
171 $diff_minutes = floor($diff_seconds / 60);
172 $diff_seconds -= $diff_minutes * 60;
173 return sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
Builds a Color from either hex- or rgb values.
getNrOfAnsweredQuestions()
buildHumanReadableTime(int $time)
getHumanReadableTotalTimeOnTask()
getAsDescriptiveListing(Language $lng, UIFactory $ui_factory, array $environment)
getReachedPointsInPercent()
__construct(private readonly int $active_id, private readonly int $attempt_id, private readonly ResultPresentationSettings $settings, private readonly string $exam_id='', private readonly float $reached_points=0.0, private readonly float $available_points=0.0, private readonly ?Mark $mark=null, private readonly int $nr_of_answered_questions=0, private readonly int $nr_of_questions_in_attempt=0, private readonly int $time_on_task=0, private readonly int $total_time_on_task=0, private readonly ?\DateTimeImmutable $attempt_started_date=null, private readonly ?\DateTimeImmutable $last_access=null, private readonly int $nr_of_attempts=0, private readonly ?int $scored_attempt=null, private readonly ?int $rank=0, private readonly StatusOfAttempt $status_of_attempt=StatusOfAttempt::NOT_YET_STARTED)
A class defining marks for assessment test objects.
txt(string $a_topic, string $a_default_lang_fallback_mod="")