ILIAS  trunk Revision v12.0_alpha-439-g30457d6d0bc
ILIAS\Test\Results\Data\AttemptOverview Class Reference
+ Collaboration diagram for ILIAS\Test\Results\Data\AttemptOverview:

Public Member Functions

 __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)
 
 getActiveId ()
 
 getAttempt ()
 
 getExamId ()
 
 getStartedDate ()
 
 getNrOfAnsweredQuestions ()
 
 getNrOfTotalQuestions ()
 
 hasAnsweredQuestions ()
 
 getMark ()
 
 hasPassingMark ()
 
 getReachedPoints ()
 
 getAvailablePoints ()
 
 getReachedPointsInPercent ()
 
 getStatusOfAttempt ()
 
 getNrOfAttempts ()
 
 getTotalTimeOnTask ()
 
 getAsDescriptiveListing (Language $lng, UIFactory $ui_factory, array $environment)
 
 getHumanReadableTotalTimeOnTask ()
 

Private Member Functions

 buildHumanReadableTime (int $time)
 

Detailed Description

Definition at line 30 of file AttemptOverview.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Results\Data\AttemptOverview::__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 
)

Definition at line 32 of file AttemptOverview.php.

50 {
51 }

Member Function Documentation

◆ buildHumanReadableTime()

ILIAS\Test\Results\Data\AttemptOverview::buildHumanReadableTime ( int  $time)
private

Definition at line 166 of file AttemptOverview.php.

166 : string
167 {
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);
174 }

◆ getActiveId()

ILIAS\Test\Results\Data\AttemptOverview::getActiveId ( )

Definition at line 53 of file AttemptOverview.php.

53 : int
54 {
55 return $this->active_id;
56 }

◆ getAsDescriptiveListing()

ILIAS\Test\Results\Data\AttemptOverview::getAsDescriptiveListing ( Language  $lng,
UIFactory  $ui_factory,
array  $environment 
)

Definition at line 131 of file AttemptOverview.php.

135 : DescriptiveListing {
136 $is_finished = $this->getStatusOfAttempt()->isFinished();
137 $items = [
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() ?? '-'
142 : '-'
143 ];
144
145 return $ui_factory->listing()->descriptive(
146 $items + [
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 : '-',
157 ]
158 );
159 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
global $lng
Definition: privfeed.php:31

◆ getAttempt()

ILIAS\Test\Results\Data\AttemptOverview::getAttempt ( )

Definition at line 58 of file AttemptOverview.php.

58 : int
59 {
60 return $this->attempt_id;
61 }

◆ getAvailablePoints()

ILIAS\Test\Results\Data\AttemptOverview::getAvailablePoints ( )

Definition at line 103 of file AttemptOverview.php.

103 : float
104 {
105 return $this->available_points;
106 }

◆ getExamId()

ILIAS\Test\Results\Data\AttemptOverview::getExamId ( )

Definition at line 63 of file AttemptOverview.php.

63 : string
64 {
65 return $this->exam_id;
66 }

◆ getHumanReadableTotalTimeOnTask()

ILIAS\Test\Results\Data\AttemptOverview::getHumanReadableTotalTimeOnTask ( )

Definition at line 161 of file AttemptOverview.php.

161 : string
162 {
163 return $this->buildHumanReadableTime($this->total_time_on_task);
164 }

◆ getMark()

ILIAS\Test\Results\Data\AttemptOverview::getMark ( )

Definition at line 88 of file AttemptOverview.php.

88 : ?string
89 {
90 return $this->mark?->getShortName();
91 }

◆ getNrOfAnsweredQuestions()

ILIAS\Test\Results\Data\AttemptOverview::getNrOfAnsweredQuestions ( )

Definition at line 73 of file AttemptOverview.php.

73 : int
74 {
75 return $this->nr_of_answered_questions;
76 }

◆ getNrOfAttempts()

ILIAS\Test\Results\Data\AttemptOverview::getNrOfAttempts ( )

Definition at line 121 of file AttemptOverview.php.

121 : int
122 {
123 return $this->nr_of_attempts;
124 }

◆ getNrOfTotalQuestions()

ILIAS\Test\Results\Data\AttemptOverview::getNrOfTotalQuestions ( )

Definition at line 78 of file AttemptOverview.php.

78 : int
79 {
80 return $this->nr_of_questions_in_attempt;
81 }

◆ getReachedPoints()

ILIAS\Test\Results\Data\AttemptOverview::getReachedPoints ( )

Definition at line 98 of file AttemptOverview.php.

98 : float
99 {
100 return $this->reached_points;
101 }

◆ getReachedPointsInPercent()

ILIAS\Test\Results\Data\AttemptOverview::getReachedPointsInPercent ( )

Definition at line 108 of file AttemptOverview.php.

108 : float
109 {
110 if ($this->reached_points === 0.0 || $this->available_points === 0.0) {
111 return 0.0;
112 }
113 return $this->reached_points / $this->available_points * 100;
114 }

◆ getStartedDate()

ILIAS\Test\Results\Data\AttemptOverview::getStartedDate ( )

Definition at line 68 of file AttemptOverview.php.

68 : ?\DateTimeImmutable
69 {
70 return $this->attempt_started_date;
71 }

◆ getStatusOfAttempt()

ILIAS\Test\Results\Data\AttemptOverview::getStatusOfAttempt ( )

Definition at line 116 of file AttemptOverview.php.

117 {
118 return $this->status_of_attempt;
119 }

◆ getTotalTimeOnTask()

ILIAS\Test\Results\Data\AttemptOverview::getTotalTimeOnTask ( )

Definition at line 126 of file AttemptOverview.php.

126 : int
127 {
128 return $this->total_time_on_task;
129 }

◆ hasAnsweredQuestions()

ILIAS\Test\Results\Data\AttemptOverview::hasAnsweredQuestions ( )

Definition at line 83 of file AttemptOverview.php.

83 : bool
84 {
85 return $this->nr_of_answered_questions > 0;
86 }

◆ hasPassingMark()

ILIAS\Test\Results\Data\AttemptOverview::hasPassingMark ( )

Definition at line 93 of file AttemptOverview.php.

93 : bool
94 {
95 return $this->mark?->getPassed() ?? false;
96 }

The documentation for this class was generated from the following file: