ILIAS  release_8 Revision v8.24
class.ilTestEvaluationUserData.php
Go to the documentation of this file.
1<?php
28include_once "./Services/Object/classes/class.ilObject.php";
29include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
30
32{
38 public $name;
39
45 public $login;
46
52 public $user_id;
53
57 protected $submitted;
58
64 public $reached;
65
71 public $maxpoints;
72
78 public $mark;
79
86
92 public $markECTS;
93
100
107
114
121
128
134 public $passed;
135
141 public $passes;
142
143
149
156
161
162 public function __sleep()
163 {
164 return array('questions', 'passes', 'passed', 'lastVisit', 'firstVisit', 'timeOfWork', 'numberOfQuestions',
165 'questionsWorkedThrough', 'markECTS', 'mark_official', 'mark', 'maxpoints', 'reached', 'user_id', 'login',
166 'name', 'passScoring');
167 }
168
174 public function __construct($passScoring)
175 {
176 $this->passes = array();
177 $this->questions = array();
178 $this->passed = false;
179 $this->passScoring = $passScoring;
180 }
181
182 public function getPassScoring()
183 {
184 return $this->passScoring;
185 }
186
187 public function setPassScoring($passScoring): void
188 {
189 $this->passScoring = $passScoring;
190 }
191
192 public function getPassed(): bool
193 {
194 return $this->passed;
195 }
196
197 public function setPassed($a_passed): void
198 {
199 $this->passed = ($a_passed ? true : false);
200 }
201
202 public function getName(): string
203 {
204 return $this->name;
205 }
206
207 public function setName($a_name): void
208 {
209 $this->name = $a_name;
210 }
211
212 public function getLogin(): string
213 {
214 return $this->login ?? '';
215 }
216
217 public function setLogin($a_login): void
218 {
219 $this->login = $a_login;
220 }
221
225 public function isSubmitted(): bool
226 {
227 return $this->submitted;
228 }
229
233 public function setSubmitted($submitted): void
234 {
235 $this->submitted = $submitted;
236 }
237
238 public function getReached(): float
239 {
240 return $this->getReachedPoints($this->getScoredPass());
241 }
242
243 public function setReached($a_reached)
244 {
245 $this->reached = $a_reached;
246 }
247
248 public function getMaxpoints()
249 {
250 return $this->getAvailablePoints($this->getScoredPass());
251 }
252
253 public function setMaxpoints($a_max_points): void
254 {
255 $this->maxpoints = $a_max_points;
256 }
257
259 {
260 return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
261 }
262
263 public function getMark(): string
264 {
265 return $this->mark;
266 }
267
268 public function setMark($a_mark): void
269 {
270 $this->mark = $a_mark;
271 }
272
273 public function getECTSMark(): ?string
274 {
275 return $this->markECTS;
276 }
277
278 public function setECTSMark($a_mark_ects): void
279 {
280 $this->markECTS = $a_mark_ects;
281 }
282
284 {
285 $questionpass = $this->getScoredPass();
286 if (!is_object($this->passes[$questionpass])) {
287 $questionpass = 0;
288 }
289 if (is_object($this->passes[$questionpass])) {
290 return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
291 }
292 return 0;
293 }
294
295 public function setQuestionsWorkedThrough($a_nr)
296 {
297 $this->questionsWorkedThrough = $a_nr;
298 }
299
300 public function getNumberOfQuestions(): int
301 {
302 $questionpass = $this->getScoredPass();
303 if (!is_object($this->passes[$questionpass])) {
304 $questionpass = 0;
305 }
306 if (is_object($this->passes[$questionpass])) {
307 return $this->passes[$questionpass]->getQuestionCount();
308 }
309 return 0;
310 // return $this->numberOfQuestions;
311 }
312
313 public function setNumberOfQuestions($a_nr)
314 {
315 $this->numberOfQuestions = $a_nr;
316 }
317
319 {
320 return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
321 }
322
323 public function getTimeOfWork(): int
324 {
325 $time = 0;
326 foreach ($this->passes as $pass) {
327 $time += $pass->getWorkingTime();
328 }
329 return $time;
330 }
331
332 public function setTimeOfWork($a_time_of_work)
333 {
334 $this->timeOfWork = $a_time_of_work;
335 }
336
337 public function getFirstVisit(): string
338 {
339 return $this->firstVisit;
340 }
341
342 public function setFirstVisit($a_time)
343 {
344 $this->firstVisit = $a_time;
345 }
346
347 public function getLastVisit(): string
348 {
349 return $this->lastVisit;
350 }
351
352 public function setLastVisit($a_time)
353 {
354 $this->lastVisit = $a_time;
355 }
356
357 public function getPasses(): array
358 {
359 return $this->passes;
360 }
361
366 public function addPass($pass_nr, $pass)
367 {
368 $this->passes[$pass_nr] = $pass;
369 }
370
375 public function getPass($pass_nr): ?ilTestEvaluationPassData
376 {
377 if (array_key_exists($pass_nr, $this->passes)) {
378 return $this->passes[$pass_nr];
379 } else {
380 return null;
381 }
382 }
383
384 public function getPassCount(): int
385 {
386 return count($this->passes);
387 }
388
389 public function getScoredPass()
390 {
391 if ($this->getPassScoring() == 1) {
392 return $this->getBestPass();
393 } else {
394 return $this->getLastPass();
395 }
396 }
401 public function getBestPass()
402 {
403 $bestpoints = 0;
404 $bestpass = null;
405
406 $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
407
408 foreach ($this->passes as $pass) {
409 $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
410
411 if (($reached > $bestpoints
412 && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists))
413 || !isset($bestpass)) {
414 $bestpoints = $reached;
415 $bestpass = $pass->getPass();
416 }
417 }
418
419 return (int) $bestpass;
420 }
421
422 public function getLastPass()
423 {
424 $lastpass = 0;
425 foreach (array_keys($this->passes) as $pass) {
426 if ($pass > $lastpass) {
427 $lastpass = $pass;
428 }
429 }
430 return $lastpass;
431 }
435 public function getFinishedPasses()
436 {
437 return $this->getLastFinishedPass() === null ? 0 : $this->getLastFinishedPass() + 1;
438 }
439
443 public function getLastFinishedPass()
444 {
446 }
447
451 public function setLastFinishedPass($pass = null)
452 {
453 $this->lastFinishedPass = $pass;
454 }
455 public function addQuestionTitle($question_id, $question_title)
456 {
457 $this->questionTitles[$question_id] = $question_title;
458 }
459
460 public function getQuestionTitles()
461 {
462 return $this->questionTitles;
463 }
464
465 public function getQuestions($pass = 0)
466 {
467 if (array_key_exists($pass, $this->questions)) {
468 return $this->questions[$pass];
469 } else {
470 return null;
471 }
472 }
473
474 public function addQuestion($original_id, $question_id, $max_points, $sequence = null, $pass = 0)
475 {
476 if (!isset($this->questions[$pass])) {
477 $this->questions[$pass] = array();
478 }
479
480 $this->questions[$pass][] = array(
481 "id" => $question_id, // the so called "aid" from any historical time
482 "o_id" => $original_id, // when the "aid" was valid this was the "id"
483 "points" => $max_points,
484 "sequence" => $sequence
485 );
486 }
487
488 public function getQuestion($index, $pass = 0)
489 {
490 if (array_key_exists($index, $this->questions[$pass])) {
491 return $this->questions[$pass][$index];
492 } else {
493 return null;
494 }
495 }
496
497 public function getQuestionCount($pass = 0): int
498 {
499 $count = 0;
500 if (array_key_exists($pass, $this->passes)) {
501 $count = $this->passes[$pass]->getQuestionCount();
502 }
503 return $count;
504 }
505
506 public function getReachedPoints($pass = 0): float
507 {
508 $reached = 0;
509 if (array_key_exists($pass, $this->passes)) {
510 $reached = $this->passes[$pass]->getReachedPoints();
511 }
512 $reached = ($reached < 0) ? 0 : $reached;
513 $reached = round($reached, 2);
514 return $reached;
515 }
516
517 public function getAvailablePoints($pass = 0)
518 {
519 $available = 0;
520 if (!is_object($this->passes[$pass])) {
521 $pass = 0;
522 }
523 if (!is_object($this->passes[$pass])) {
524 return 0;
525 }
526 $available = $this->passes[$pass]->getMaxPoints();
527 $available = round($available, 2);
528 return $available;
529 }
530
531 public function getReachedPointsInPercentForPass($pass = 0)
532 {
533 $reached = $this->getReachedPoints($pass);
534 $available = $this->getAvailablePoints($pass);
535 $percent = ($available > 0) ? $reached / $available : 0;
536 return $percent;
537 }
538
539 public function setUserID($a_usr_id)
540 {
541 $this->user_id = $a_usr_id;
542 }
543
544 public function getUserID(): ?int
545 {
546 return $this->user_id;
547 }
548
549 public function setMarkOfficial($a_mark_official)
550 {
551 $this->mark_official = $a_mark_official;
552 }
553
554 public function getMarkOfficial(): string
555 {
557 }
558
565 public function getScoredPassObject()
566 {
567 if ($this->getPassScoring() == 1) {
568 return $this->getBestPassObject();
569 } else {
570 return $this->getLastPassObject();
571 }
572 }
573
580 {
581 return $this->getRequestedHintsCount($this->getScoredPass());
582 }
583
587 public function getExamIdFromScoredPass(): string
588 {
589 $examId = '';
590 $scoredPass = $this->getScoredPass();
591
592 if (isset($this->passes[$scoredPass]) && $this->passes[$scoredPass] instanceof ilTestEvaluationPassData) {
593 $examId = $this->passes[$scoredPass]->getExamId();
594 }
595
596 return $examId;
597 }
598
606 public function getRequestedHintsCount($pass): int
607 {
608 if (!isset($this->passes[$pass]) || !($this->passes[$pass] instanceof ilTestEvaluationPassData)) {
609 throw new ilTestException("invalid pass index given: $pass");
610 }
611
612 $requestedHintsCount = $this->passes[$pass]->getRequestedHintsCount();
613
614 return $requestedHintsCount;
615 }
616
623 public function getBestPassObject()
624 {
625 $bestpoints = 0;
626 $bestpassObject = 0;
627
628 $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
629
630 foreach ($this->passes as $pass) {
631 $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
632
633 if ($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists)) {
634 $bestpoints = $reached;
635 $bestpassObject = $pass;
636 }
637 }
638
639 return $bestpassObject;
640 }
641
649 {
650 $lastpassIndex = 0;
651
652 foreach (array_keys($this->passes) as $passIndex) {
653 if ($passIndex > $lastpassIndex) {
654 $lastpassIndex = $passIndex;
655 }
656 }
657
658 $lastpassObject = $this->passes[$lastpassIndex];
659
660 return $lastpassObject;
661 }
662
669 public function doesObligationsAnsweredPassExist(): bool
670 {
671 foreach ($this->passes as $pass) {
672 if ($pass->areObligationsAnswered()) {
673 return true;
674 }
675 }
676
677 return false;
678 }
679
686 public function areObligationsAnswered(): bool
687 {
688 return $this->getScoredPassObject()->areObligationsAnswered();
689 }
690} // END ilTestEvaluationUserData
return true
addQuestion($original_id, $question_id, $max_points, $sequence=null, $pass=0)
areObligationsAnswered()
returns the fact wether all obligations in the scored test pass are answered or not
getRequestedHintsCount($pass)
returns the count of hints requested by participant for given testpass
getBestPassObject()
returns the object of class ilTestEvaluationPassData that relates to the the best test pass
getBestPass()
This is used in the export of test results Aligned with ilObjTest::_getBestPass: from passes with equ...
addQuestionTitle($question_id, $question_title)
getScoredPassObject()
returns the object of class ilTestEvaluationPassData that relates to the the scored test pass (best p...
getLastPassObject()
returns the object of class ilTestEvaluationPassData that relates to the the last test pass
doesObligationsAnsweredPassExist()
returns the fact wether a test pass with all obligations answered exists or not
$passScoring
Pass Scoring (Last pass = 0, Best pass = 1)
getRequestedHintsCountFromScoredPass()
returns the count of hints requested by participant for scored testpass
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$index
Definition: metadata.php:145