ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestEvaluationPassData.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
35 {
39  public array $answeredQuestions;
40  private int $workingtime;
41  private int $questioncount;
42  private float $maxpoints;
43  private float $reachedpoints;
45  private int $pass;
46  private ?int $requestedHintsCount = null;
47  private ?float $deductedHintPoints = null;
48  private bool $obligationsAnswered = false;
49  private string $exam_id = '';
50 
51  public function __sleep()
52  {
53  return array('answeredQuestions', 'pass', 'nrOfAnsweredQuestions', 'reachedpoints',
54  'maxpoints', 'questioncount', 'workingtime', 'examId');
55  }
56 
62  public function __construct()
63  {
64  $this->answeredQuestions = [];
65  }
66 
67  public function getNrOfAnsweredQuestions(): int
68  {
70  }
71 
72  public function setNrOfAnsweredQuestions(int $nrOfAnsweredQuestions): void
73  {
74  $this->nrOfAnsweredQuestions = $nrOfAnsweredQuestions;
75  }
76 
77  public function getReachedPoints(): float
78  {
79  return $this->reachedpoints;
80  }
81 
82  public function setReachedPoints(float $reachedpoints): void
83  {
84  $this->reachedpoints = $reachedpoints;
85  }
86 
87  public function getMaxPoints(): float
88  {
89  return $this->maxpoints;
90  }
91 
92  public function setMaxPoints(float $maxpoints): void
93  {
94  $this->maxpoints = $maxpoints;
95  }
96 
97  public function getQuestionCount(): int
98  {
99  return $this->questioncount;
100  }
101 
102  public function setQuestionCount(int $questioncount): void
103  {
104  $this->questioncount = $questioncount;
105  }
106 
107  public function getWorkingTime(): int
108  {
109  return $this->workingtime;
110  }
111 
112  public function setWorkingTime(int $workingtime): void
113  {
114  $this->workingtime = $workingtime;
115  }
116 
117  public function getPass(): int
118  {
119  return $this->pass;
120  }
121 
122  public function setPass(int $pass): void
123  {
124  $this->pass = $pass;
125  }
126 
127  public function getAnsweredQuestions(): array
128  {
130  }
131 
132  public function addAnsweredQuestion(
133  int $question_id,
134  float $max_points,
135  float $reached_points,
136  bool $isAnswered,
137  ?int $sequence = null,
138  int $manual = 0
139  ): void {
140  $this->answeredQuestions[] = [
141  "id" => $question_id,
142  "points" => round($max_points, 2),
143  "reached" => round($reached_points, 2),
144  'isAnswered' => $isAnswered,
145  "sequence" => $sequence,
146  'manual' => $manual
147  ];
148  }
149 
150  public function getAnsweredQuestion(int $index): ?array
151  {
152  if (array_key_exists($index, $this->answeredQuestions)) {
153  return $this->answeredQuestions[$index];
154  }
155 
156  return null;
157  }
158 
159  public function getAnsweredQuestionByQuestionId(int $question_id): ?array
160  {
161  foreach ($this->answeredQuestions as $question) {
162  if ($question["id"] == $question_id) {
163  return $question;
164  }
165  }
166  return null;
167  }
168 
169  public function getAnsweredQuestionCount(): int
170  {
171  return count($this->answeredQuestions);
172  }
173 
174  public function getRequestedHintsCount(): ?int
175  {
177  }
178 
179  public function setRequestedHintsCount(int $requestedHintsCount): void
180  {
181  $this->requestedHintsCount = $requestedHintsCount;
182  }
183 
184  public function getDeductedHintPoints(): ?float
185  {
187  }
188 
189  public function setDeductedHintPoints(float $deductedHintPoints): void
190  {
191  $this->deductedHintPoints = $deductedHintPoints;
192  }
193 
194  public function setObligationsAnswered(bool $obligationsAnswered): void
195  {
196  $this->obligationsAnswered = $obligationsAnswered;
197  }
198 
199  public function getExamId(): string
200  {
201  return $this->exam_id;
202  }
203 
204  public function setExamId(string $exam_id): void
205  {
206  $this->exam_id = $exam_id;
207  }
208 
216  public function areObligationsAnswered(): ?bool
217  {
218  if (!is_null($this->obligationsAnswered)) {
220  }
221 
222  if (is_array($this->answeredQuestions) && $this->answeredQuestions !== []) {
223  foreach ($this->answeredQuestions as $question) {
224  if (!$question['isAnswered']) {
225  return false;
226  }
227  }
228 
229  return true;
230  }
231 
232  throw new ilTestEvaluationException(
233  'Neither the boolean property ilTestEvaluationPassData::obligationsAnswered was set, ' .
234  'nor the property array property ilTestEvaluationPassData::answeredQuestions contains elements!'
235  );
236  }
237 }
addAnsweredQuestion(int $question_id, float $max_points, float $reached_points, bool $isAnswered, ?int $sequence=null, int $manual=0)
setObligationsAnswered(bool $obligationsAnswered)
setDeductedHintPoints(float $deductedHintPoints)
setRequestedHintsCount(int $requestedHintsCount)
setNrOfAnsweredQuestions(int $nrOfAnsweredQuestions)
areObligationsAnswered()
getter for property obligationsAnswered.