ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
TestOverview.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Results\Data;
22 
26 
28 {
29  public function __construct(
30  private readonly int $test_obj_id,
31  private readonly int $total_number_of_participants = 0,
32  private readonly int $total_number_of_participants_with_finished_attempts = 0,
33  private readonly int $total_number_of_participants_with_passing_result = 0,
34  private readonly int $average_time_on_task_with_finished_attempts = 0,
35  private readonly int $average_time_on_task_passed = 0,
36  private readonly int $rank_of_median = 0,
37  private readonly string $mark_of_median = '',
38  private readonly float $points_of_median = 0,
39  private readonly float $average_points_passed = 0
40  ) {
41  }
42 
43  public function getTestObjId(): int
44  {
45  return $this->test_obj_id;
46  }
47 
48  public function getAsDescriptiveListing(
49  Language $lng,
50  UIFactory $ui_factory
52  return $ui_factory->listing()->descriptive([
53  $lng->txt('tst_eval_total_persons') => (string) $this->total_number_of_participants,
54  $lng->txt('tst_stat_result_rank_median') => (string) $this->rank_of_median,
55  $lng->txt('tst_stat_result_median') => sprintf('%2.2f', $this->points_of_median),
56  $lng->txt('tst_stat_result_mark_median') => $this->mark_of_median,
57  $lng->txt('tst_eval_total_finished') => (string) $this->total_number_of_participants_with_finished_attempts,
58  $lng->txt('tst_eval_total_finished_average_time') => $this->buildHumanReadableTime(
59  $this->average_time_on_task_with_finished_attempts
60  ),
61  $lng->txt('tst_eval_total_passed') => (string) $this->total_number_of_participants_with_passing_result,
62  $lng->txt('tst_eval_total_passed_average_time') => $this->buildHumanReadableTime(
63  $this->average_time_on_task_passed
64  ),
65  $lng->txt('tst_eval_total_passed_average_points') => sprintf('%2.2f', $this->average_points_passed)
66  ]);
67  }
68 
69  private function buildHumanReadableTime(int $time): string
70  {
71  $diff_seconds = $time;
72  $diff_hours = floor($diff_seconds / 3600);
73  $diff_seconds -= $diff_hours * 3600;
74  $diff_minutes = floor($diff_seconds / 60);
75  $diff_seconds -= $diff_minutes * 60;
76  return sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
77  }
78 }
__construct(private readonly int $test_obj_id, private readonly int $total_number_of_participants=0, private readonly int $total_number_of_participants_with_finished_attempts=0, private readonly int $total_number_of_participants_with_passing_result=0, private readonly int $average_time_on_task_with_finished_attempts=0, private readonly int $average_time_on_task_passed=0, private readonly int $rank_of_median=0, private readonly string $mark_of_median='', private readonly float $points_of_median=0, private readonly float $average_points_passed=0)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
global $lng
Definition: privfeed.php:31
getAsDescriptiveListing(Language $lng, UIFactory $ui_factory)