ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTestEvaluationUserData.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
15include_once "./Services/Object/classes/class.ilObject.php";
16include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
17
19{
25 public $name;
26
32 public $login;
33
39 public $user_id;
40
44 protected $submitted;
45
51 public $reached;
52
58 public $maxpoints;
59
65 public $mark;
66
73
79 public $markECTS;
80
87
94
101
108
115
121 public $passed;
122
128 public $passes;
129
130
136
143
150
151 public function __sleep()
152 {
153 return array('questions', 'passes', 'passed', 'lastVisit', 'firstVisit', 'timeOfWork', 'numberOfQuestions',
154 'questionsWorkedThrough', 'markECTS', 'mark_official', 'mark', 'maxpoints', 'reached', 'user_id', 'login',
155 'name', 'passScoring');
156 }
157
163 public function __construct($passScoring)
164 {
165 $this->passes = array();
166 $this->questions = array();
167 $this->passed = false;
168 $this->passScoring = $passScoring;
169 }
170
171 public function getPassScoring()
172 {
173 return $this->passScoring;
174 }
175
177 {
178 $this->passScoring = $passScoring;
179 }
180
181 public function getPassed()
182 {
183 return $this->passed;
184 }
185
186 public function setPassed($a_passed)
187 {
188 $this->passed = ($a_passed ? true : false);
189 }
190
191 public function getName()
192 {
193 return $this->name;
194 }
195
196 public function setName($a_name)
197 {
198 $this->name = $a_name;
199 }
200
201 public function getLogin()
202 {
203 return $this->login;
204 }
205
206 public function setLogin($a_login)
207 {
208 $this->login = $a_login;
209 }
210
214 public function isSubmitted()
215 {
216 return $this->submitted;
217 }
218
222 public function setSubmitted($submitted)
223 {
224 $this->submitted = $submitted;
225 }
226
227 public function getReached()
228 {
229 return $this->getReachedPoints($this->getScoredPass());
230 }
231
232 public function setReached($a_reached)
233 {
234 $this->reached = $a_reached;
235 }
236
237 public function getMaxpoints()
238 {
239 return $this->getAvailablePoints($this->getScoredPass());
240 }
241
242 public function setMaxpoints($a_max_points)
243 {
244 $this->maxpoints = $a_max_points;
245 }
246
248 {
249 return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
250 }
251
252 public function getMark()
253 {
254 return $this->mark;
255 }
256
257 public function setMark($a_mark)
258 {
259 $this->mark = $a_mark;
260 }
261
262 public function getECTSMark()
263 {
264 return $this->markECTS;
265 }
266
267 public function setECTSMark($a_mark_ects)
268 {
269 $this->markECTS = $a_mark_ects;
270 }
271
273 {
274 $questionpass = $this->getScoredPass();
275 if (!is_object($this->passes[$questionpass])) {
276 $questionpass = 0;
277 }
278 if (is_object($this->passes[$questionpass])) {
279 return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
280 }
281 return 0;
282 }
283
284 public function setQuestionsWorkedThrough($a_nr)
285 {
286 $this->questionsWorkedThrough = $a_nr;
287 }
288
289 public function getNumberOfQuestions()
290 {
291 $questionpass = $this->getScoredPass();
292 if (!is_object($this->passes[$questionpass])) {
293 $questionpass = 0;
294 }
295 if (is_object($this->passes[$questionpass])) {
296 return $this->passes[$questionpass]->getQuestionCount();
297 }
298 return 0;
299 // return $this->numberOfQuestions;
300 }
301
302 public function setNumberOfQuestions($a_nr)
303 {
304 $this->numberOfQuestions = $a_nr;
305 }
306
308 {
309 return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
310 }
311
312 public function getTimeOfWork()
313 {
314 $time = 0;
315 foreach ($this->passes as $pass) {
316 $time += $pass->getWorkingTime();
317 }
318 return $time;
319 }
320
321 public function setTimeOfWork($a_time_of_work)
322 {
323 $this->timeOfWork = $a_time_of_work;
324 }
325
326 public function getFirstVisit()
327 {
328 return $this->firstVisit;
329 }
330
331 public function setFirstVisit($a_time)
332 {
333 $this->firstVisit = $a_time;
334 }
335
336 public function getLastVisit()
337 {
338 return $this->lastVisit;
339 }
340
341 public function setLastVisit($a_time)
342 {
343 $this->lastVisit = $a_time;
344 }
345
346 public function getPasses()
347 {
348 return $this->passes;
349 }
350
355 public function addPass($pass_nr, $pass)
356 {
357 $this->passes[$pass_nr] = $pass;
358 }
359
364 public function getPass($pass_nr)
365 {
366 if (array_key_exists($pass_nr, $this->passes)) {
367 return $this->passes[$pass_nr];
368 } else {
369 return null;
370 }
371 }
372
373 public function getPassCount()
374 {
375 return count($this->passes);
376 }
377
378 public function getScoredPass()
379 {
380 if ($this->getPassScoring() == 1) {
381 return $this->getBestPass();
382 } else {
383 return $this->getLastPass();
384 }
385 }
386
391 public function getBestPass()
392 {
393 $bestpoints = 0;
394 $bestpass = null;
395
396 $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
397
398 foreach ($this->passes as $pass) {
399 $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
400
401 if (($reached > $bestpoints
402 && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists))
403 || !isset($bestpass)) {
404 $bestpoints = $reached;
405 $bestpass = $pass->getPass();
406 }
407 }
408
409 return (int) $bestpass;
410 }
411
412 public function getLastPass()
413 {
414 $lastpass = 0;
415 foreach (array_keys($this->passes) as $pass) {
416 if ($pass > $lastpass) {
417 $lastpass = $pass;
418 }
419 }
420 return $lastpass;
421 }
422
426 public function getFinishedPasses()
427 {
428 return $this->getLastFinishedPass() === null ? 0 : $this->getLastFinishedPass() + 1;
429 }
430
434 public function getLastFinishedPass()
435 {
437 }
438
442 public function setLastFinishedPass($pass = null)
443 {
444 $this->lastFinishedPass = $pass;
445 }
446
447 public function addQuestionTitle($question_id, $question_title)
448 {
449 $this->questionTitles[$question_id] = $question_title;
450 }
451
452 public function getQuestionTitles()
453 {
454 return $this->questionTitles;
455 }
456
457 public function getQuestions($pass = 0)
458 {
459 if (array_key_exists($pass, $this->questions)) {
460 return $this->questions[$pass];
461 } else {
462 return null;
463 }
464 }
465
466 public function addQuestion($original_id, $question_id, $max_points, $sequence = null, $pass = 0)
467 {
468 if (!isset($this->questions[$pass])) {
469 $this->questions[$pass] = array();
470 }
471
472 $this->questions[$pass][] = array(
473 "id" => $question_id, // the so called "aid" from any historical time
474 "o_id" => $original_id, // when the "aid" was valid this was the "id"
475 "points" => $max_points,
476 "sequence" => $sequence
477 );
478 }
479
480 public function getQuestion($index, $pass = 0)
481 {
482 if (array_key_exists($index, $this->questions[$pass])) {
483 return $this->questions[$pass][$index];
484 } else {
485 return null;
486 }
487 }
488
489 public function getQuestionCount($pass = 0)
490 {
491 $count = 0;
492 if (array_key_exists($pass, $this->passes)) {
493 $count = $this->passes[$pass]->getQuestionCount();
494 }
495 return $count;
496 }
497
498 public function getReachedPoints($pass = 0)
499 {
500 $reached = 0;
501 if (array_key_exists($pass, $this->passes)) {
502 $reached = $this->passes[$pass]->getReachedPoints();
503 }
504 $reached = ($reached < 0) ? 0 : $reached;
505 $reached = round($reached, 2);
506 return $reached;
507 }
508
509 public function getAvailablePoints($pass = 0)
510 {
511 $available = 0;
512 if (!is_object($this->passes[$pass])) {
513 $pass = 0;
514 }
515 if (!is_object($this->passes[$pass])) {
516 return 0;
517 }
518 $available = $this->passes[$pass]->getMaxPoints();
519 $available = round($available, 2);
520 return $available;
521 }
522
524 {
526 $available = $this->getAvailablePoints($pass);
527 $percent = ($available > 0) ? $reached / $available : 0;
528 return $percent;
529 }
530
531 public function setUserID($a_usr_id)
532 {
533 $this->user_id = $a_usr_id;
534 }
535
536 public function getUserID()
537 {
538 return $this->user_id;
539 }
540
541 public function setMarkOfficial($a_mark_official)
542 {
543 $this->mark_official = $a_mark_official;
544 }
545
546 public function getMarkOfficial()
547 {
549 }
550
557 public function getScoredPassObject()
558 {
559 if ($this->getPassScoring() == 1) {
560 return $this->getBestPassObject();
561 } else {
562 return $this->getLastPassObject();
563 }
564 }
565
572 {
573 return $this->getRequestedHintsCount($this->getScoredPass());
574 }
575
579 public function getExamIdFromScoredPass() : string
580 {
581 $examId = '';
582 $scoredPass = $this->getScoredPass();
583
584 if (isset($this->passes[$scoredPass]) && $this->passes[$scoredPass] instanceof ilTestEvaluationPassData) {
585 $examId = $this->passes[$scoredPass]->getExamId();
586 }
587
588 return $examId;
589 }
590
599 {
600 if (!isset($this->passes[$pass]) || !($this->passes[$pass] instanceof ilTestEvaluationPassData)) {
601 throw new ilTestException("invalid pass index given: $pass");
602 }
603
604 $requestedHintsCount = $this->passes[$pass]->getRequestedHintsCount();
605
606 return $requestedHintsCount;
607 }
608
615 public function getBestPassObject()
616 {
617 $bestpoints = 0;
618 $bestpassObject = 0;
619
620 $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
621
622 foreach ($this->passes as $pass) {
623 $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
624
625 if ($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists)) {
626 $bestpoints = $reached;
627 $bestpassObject = $pass;
628 }
629 }
630
631 return $bestpassObject;
632 }
633
640 public function getLastPassObject()
641 {
642 $lastpassIndex = 0;
643
644 foreach (array_keys($this->passes) as $passIndex) {
645 if ($passIndex > $lastpassIndex) {
646 $lastpassIndex = $passIndex;
647 }
648 }
649
650 $lastpassObject = $this->passes[$lastpassIndex];
651
652 return $lastpassObject;
653 }
654
662 {
663 foreach ($this->passes as $pass) {
664 if ($pass->areObligationsAnswered()) {
665 return true;
666 }
667 }
668
669 return false;
670 }
671
678 public function areObligationsAnswered()
679 {
680 return $this->getScoredPassObject()->areObligationsAnswered();
681 }
682} // END ilTestEvaluationUserData
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
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
getRequestedHintsCountFromScoredPass()
returns the count of hints requested by participant for scored testpass
Base Exception for all Exceptions relating to Modules/Test.
$index
Definition: metadata.php:128
login()
Definition: login.php:2