ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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 ()
 
 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 159 of file AttemptOverview.php.

Referenced by ILIAS\Test\Results\Data\AttemptOverview\getAsDescriptiveListing(), and ILIAS\Test\Results\Data\AttemptOverview\getHumanReadableTotalTimeOnTask().

159  : string
160  {
161  $diff_seconds = $time;
162  $diff_hours = floor($diff_seconds / 3600);
163  $diff_seconds -= $diff_hours * 3600;
164  $diff_minutes = floor($diff_seconds / 60);
165  $diff_seconds -= $diff_minutes * 60;
166  return sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
167  }
+ Here is the caller graph for this function:

◆ 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 126 of file AttemptOverview.php.

References ILIAS\Test\Results\Data\AttemptOverview\buildHumanReadableTime(), ILIAS\Test\Results\Data\AttemptOverview\getReachedPointsInPercent(), and ILIAS\Language\Language\txt().

131  $items = [
132  $lng->txt('tst_stat_result_resultspoints') => $this->reached_points
133  . ' ' . strtolower($lng->txt('of')) . ' ' . $this->available_points
134  . ' (' . sprintf('%2.2f', $this->getReachedPointsInPercent()) . ' %)',
135  $lng->txt('tst_stat_result_resultsmarks') => $this->mark?->getShortName() ?? ''
136  ];
137 
138  return $ui_factory->listing()->descriptive(
139  $items + [
140  $lng->txt('tst_stat_result_timeontask') => $this->buildHumanReadableTime($this->time_on_task),
141  $lng->txt('tst_stat_result_firstvisit') => $this->attempt_started_date
142  ?->setTimezone($environment['timezone'])
143  ->format($environment['datetimeformat']) ?? '',
144  $lng->txt('tst_stat_result_lastvisit') => $this->last_access
145  ?->setTimezone($environment['timezone'])
146  ->format($environment['datetimeformat']) ?? '',
147  $lng->txt('tst_nr_of_passes') => (string) $this->nr_of_attempts,
148  $lng->txt('scored_pass') => (string) ($this->scored_attempt + 1),
149  $lng->txt('tst_stat_result_rank_participant') => (string) $this->rank
150  ]
151  );
152  }
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:

◆ 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 154 of file AttemptOverview.php.

References ILIAS\Test\Results\Data\AttemptOverview\buildHumanReadableTime().

154  : string
155  {
156  return $this->buildHumanReadableTime($this->total_time_on_task);
157  }
+ Here is the call graph for this function:

◆ 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.

Referenced by ILIAS\Test\Results\Data\AttemptOverview\getAsDescriptiveListing().

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  }
+ Here is the caller graph for this function:

◆ 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  }

◆ 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: