ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PropertyAggregatedResults.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  public function __construct(
26  private readonly int $question_id,
27  private readonly int $number_of_answers = 0,
28  private readonly float $available_points = 0.0,
29  private readonly float $total_achieved_points = 0.0,
30  ) {
31  }
32 
33  public function getQuestionId(): int
34  {
35  return $this->question_id;
36  }
37 
38  public function getNumberOfAnswers(): int
39  {
40  return $this->number_of_answers;
41  }
42 
43  public function getAveragePoints(): float
44  {
45  if ($this->number_of_answers === 0) {
46  return 0.0;
47  }
48  return $this->total_achieved_points / $this->number_of_answers;
49  }
50 
51  public function getPercentageOfPointsAchieved(): float
52  {
53  if ($this->number_of_answers === 0.0
54  || $this->available_points === 0.0) {
55  return 0.0;
56  }
57  return ($this->total_achieved_points / ($this->number_of_answers * $this->available_points)) * 100;
58  }
59 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(private readonly int $question_id, private readonly int $number_of_answers=0, private readonly float $available_points=0.0, private readonly float $total_achieved_points=0.0,)