ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilTestEvaluationPassData.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
28 {
32  public array $answeredQuestions;
33  private ?\DateTimeImmutable $start_time = null;
34  private ?\DateTimeImmutable $last_access_time = null;
35  private int $workingtime;
36  private int $questioncount;
37  private float $maxpoints;
38  private float $reachedpoints;
39  private ?Mark $mark = null;
41  private int $pass;
42  private string $exam_id = '';
44 
45  public function __sleep()
46  {
47  return ['answeredQuestions', 'pass', 'nrOfAnsweredQuestions', 'reachedpoints',
48  'maxpoints', 'questioncount', 'workingtime', 'examId'];
49  }
50 
56  public function __construct()
57  {
58  $this->answeredQuestions = [];
59  }
60 
61  public function getNrOfAnsweredQuestions(): int
62  {
64  }
65 
66  public function setNrOfAnsweredQuestions(int $nrOfAnsweredQuestions): void
67  {
68  $this->nrOfAnsweredQuestions = $nrOfAnsweredQuestions;
69  }
70 
71  public function getReachedPoints(): float
72  {
73  return $this->reachedpoints;
74  }
75 
76  public function setReachedPoints(float $reachedpoints): void
77  {
78  $this->reachedpoints = $reachedpoints;
79  }
80 
81  public function getMaxPoints(): float
82  {
83  return $this->maxpoints;
84  }
85 
86  public function setMaxPoints(float $maxpoints): void
87  {
88  $this->maxpoints = $maxpoints;
89  }
90 
91  public function getReachedPointsInPercent(): float
92  {
93  return $this->getMaxPoints() ? $this->getReachedPoints() / $this->getMaxPoints() * 100.0 : 0.0;
94  }
95 
96  public function getMark(): ?Mark
97  {
98  return $this->mark;
99  }
100 
101  public function setMark(Mark $mark): void
102  {
103  $this->mark = $mark;
104  }
105 
106  public function getQuestionCount(): int
107  {
108  return $this->questioncount;
109  }
110 
111  public function setQuestionCount(int $questioncount): void
112  {
113  $this->questioncount = $questioncount;
114  }
115 
116  public function getStartTime(): ?\DateTimeImmutable
117  {
118  return $this->start_time;
119  }
120 
121  public function setStartTime(?string $start_time): void
122  {
123  if ($start_time !== null) {
124  $this->start_time = new \DateTimeImmutable($start_time);
125  }
126  }
127 
129  {
131  }
132 
133  public function setLastAccessTime(?string $last_access_time): void
134  {
135  if ($last_access_time !== null) {
136  $this->last_access_time = new \DateTimeImmutable($last_access_time);
137  }
138  }
139 
140  public function getWorkingTime(): int
141  {
142  return $this->workingtime;
143  }
144 
145  public function setWorkingTime(int $workingtime): void
146  {
147  $this->workingtime = $workingtime;
148  }
149 
150  public function getPass(): int
151  {
152  return $this->pass;
153  }
154 
155  public function setPass(int $pass): void
156  {
157  $this->pass = $pass;
158  }
159 
160  public function getAnsweredQuestions(): array
161  {
163  }
164 
165  public function addAnsweredQuestion(
166  int $question_id,
167  float $max_points,
168  float $reached_points,
169  bool $is_answered,
170  ?int $sequence = null,
171  int $manual = 0
172  ): void {
173  $this->answeredQuestions[] = [
174  'id' => $question_id,
175  'points' => round($max_points, 2),
176  'reached' => round($reached_points, 2),
177  'isAnswered' => $is_answered,
178  'sequence' => $sequence,
179  'manual' => $manual
180  ];
181  }
182 
183  public function getAnsweredQuestion(int $index): ?array
184  {
185  if (array_key_exists($index, $this->answeredQuestions)) {
186  return $this->answeredQuestions[$index];
187  }
188 
189  return null;
190  }
191 
192  public function getAnsweredQuestionByQuestionId(int $question_id): ?array
193  {
194  foreach ($this->answeredQuestions as $question) {
195  if ($question['id'] == $question_id) {
196  return $question;
197  }
198  }
199  return null;
200  }
201 
202  public function getAnsweredQuestionCount(): int
203  {
204  return count($this->answeredQuestions);
205  }
206 
207  public function getExamId(): string
208  {
209  return $this->exam_id;
210  }
211 
212  public function setExamId(string $exam_id): void
213  {
214  $this->exam_id = $exam_id;
215  }
216 
218  {
219  if ($this->status_of_attempt) {
221  }
222 
223  return StatusOfAttempt::FINISHED_BY_UNKNOWN;
224  }
225 
226  public function setStatusOfAttempt(?StatusOfAttempt $status_of_attempt): void
227  {
228  $this->status_of_attempt = $status_of_attempt;
229  }
230 }
A class defining marks for assessment test objects.
Definition: Mark.php:35
setLastAccessTime(?string $last_access_time)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addAnsweredQuestion(int $question_id, float $max_points, float $reached_points, bool $is_answered, ?int $sequence=null, int $manual=0)
setStatusOfAttempt(?StatusOfAttempt $status_of_attempt)
setNrOfAnsweredQuestions(int $nrOfAnsweredQuestions)