ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
15 include_once "./Services/Object/classes/class.ilObject.php";
16 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
17 
19 {
25  public $name;
26 
32  public $login;
33 
39  public $user_id;
40 
46  public $reached;
47 
53  public $maxpoints;
54 
60  public $mark;
61 
68 
74  public $markECTS;
75 
82 
89 
95  public $timeOfWork;
96 
102  public $firstVisit;
103 
109  public $lastVisit;
110 
116  public $passed;
117 
123  public $passes;
124 
130  public $questions;
131 
137  private $passScoring;
138 
139  public function __sleep()
140  {
141  return array('questions', 'passes', 'passed', 'lastVisit', 'firstVisit', 'timeOfWork', 'numberOfQuestions',
142  'questionsWorkedThrough', 'markECTS', 'mark_official', 'mark', 'maxpoints', 'reached', 'user_id', 'login',
143  'name', 'passScoring');
144  }
145 
151  public function __construct($passScoring)
152  {
153  $this->passes = array();
154  $this->questions = array();
155  $this->passed = false;
156  $this->passScoring = $passScoring;
157  }
158 
159  public function getPassScoring()
160  {
161  return $this->passScoring;
162  }
163 
164  public function setPassScoring($passScoring)
165  {
166  $this->passScoring = $passScoring;
167  }
168 
169  public function getPassed()
170  {
171  return $this->passed;
172  }
173 
174  public function setPassed($a_passed)
175  {
176  $this->passed = ($a_passed ? true : false);
177  }
178 
179  public function getName()
180  {
181  return $this->name;
182  }
183 
184  public function setName($a_name)
185  {
186  $this->name = $a_name;
187  }
188 
189  public function getLogin()
190  {
191  return $this->login;
192  }
193 
194  public function setLogin($a_login)
195  {
196  $this->login = $a_login;
197  }
198 
199  public function getReached()
200  {
201  return $this->getReachedPoints($this->getScoredPass());
202  }
203 
204  public function setReached($a_reached)
205  {
206  $this->reached = $a_reached;
207  }
208 
209  public function getMaxpoints()
210  {
211  return $this->getAvailablePoints($this->getScoredPass());
212  }
213 
214  public function setMaxpoints($a_max_points)
215  {
216  $this->maxpoints = $a_max_points;
217  }
218 
219  public function getReachedPointsInPercent()
220  {
221  return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
222  }
223 
224  public function getMark()
225  {
226  return $this->mark;
227  }
228 
229  public function setMark($a_mark)
230  {
231  $this->mark = $a_mark;
232  }
233 
234  public function getECTSMark()
235  {
236  return $this->markECTS;
237  }
238 
239  public function setECTSMark($a_mark_ects)
240  {
241  $this->markECTS = $a_mark_ects;
242  }
243 
244  public function getQuestionsWorkedThrough()
245  {
246  $questionpass = $this->getScoredPass();
247  if (!is_object($this->passes[$questionpass])) {
248  $questionpass = 0;
249  }
250  if (is_object($this->passes[$questionpass])) {
251  return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
252  }
253  return 0;
254  }
255 
256  public function setQuestionsWorkedThrough($a_nr)
257  {
258  $this->questionsWorkedThrough = $a_nr;
259  }
260 
261  public function getNumberOfQuestions()
262  {
263  $questionpass = $this->getScoredPass();
264  if (!is_object($this->passes[$questionpass])) {
265  $questionpass = 0;
266  }
267  if (is_object($this->passes[$questionpass])) {
268  return $this->passes[$questionpass]->getQuestionCount();
269  }
270  return 0;
271  // return $this->numberOfQuestions;
272  }
273 
274  public function setNumberOfQuestions($a_nr)
275  {
276  $this->numberOfQuestions = $a_nr;
277  }
278 
280  {
281  return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
282  }
283 
284  public function getTimeOfWork()
285  {
286  $time = 0;
287  foreach ($this->passes as $pass) {
288  $time += $pass->getWorkingTime();
289  }
290  return $time;
291  }
292 
293  public function setTimeOfWork($a_time_of_work)
294  {
295  $this->timeOfWork = $a_time_of_work;
296  }
297 
298  public function getFirstVisit()
299  {
300  return $this->firstVisit;
301  }
302 
303  public function setFirstVisit($a_time)
304  {
305  $this->firstVisit = $a_time;
306  }
307 
308  public function getLastVisit()
309  {
310  return $this->lastVisit;
311  }
312 
313  public function setLastVisit($a_time)
314  {
315  $this->lastVisit = $a_time;
316  }
317 
318  public function getPasses()
319  {
320  return $this->passes;
321  }
322 
323  public function addPass($pass_nr, $pass)
324  {
325  $this->passes[$pass_nr] = $pass;
326  }
327 
328  public function &getPass($pass_nr)
329  {
330  if (array_key_exists($pass_nr, $this->passes)) {
331  return $this->passes[$pass_nr];
332  } else {
333  return null;
334  }
335  }
336 
337  public function getPassCount()
338  {
339  return count($this->passes);
340  }
341 
342  public function getScoredPass()
343  {
344  if ($this->getPassScoring() == 1) {
345  return $this->getBestPass();
346  } else {
347  return $this->getLastPass();
348  }
349  }
350 
351  public function getBestPass()
352  {
353  $bestpoints = 0;
354  $bestpass = 0;
355 
356  $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
357 
358  foreach ($this->passes as $pass) {
359  $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
360 
361  if ($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists)) {
362  $bestpoints = $reached;
363  $bestpass = $pass->getPass();
364  }
365  }
366 
367  return $bestpass;
368  }
369 
370  public function getLastPass()
371  {
372  $lastpass = 0;
373  foreach (array_keys($this->passes) as $pass) {
374  if ($pass > $lastpass) {
375  $lastpass = $pass;
376  }
377  }
378  return $lastpass;
379  }
380 
381  public function addQuestionTitle($question_id, $question_title)
382  {
383  $this->questionTitles[$question_id] = $question_title;
384  }
385 
386  public function getQuestionTitles()
387  {
388  return $this->questionTitles;
389  }
390 
391  public function &getQuestions($pass = 0)
392  {
393  if (array_key_exists($pass, $this->questions)) {
394  return $this->questions[$pass];
395  } else {
396  return null;
397  }
398  }
399 
400  public function addQuestion($original_id, $question_id, $max_points, $sequence = null, $pass = 0)
401  {
402  if (!isset($this->questions[$pass])) {
403  $this->questions[$pass] = array();
404  }
405 
406  $this->questions[$pass][] = array(
407  "id" => $question_id, // the so called "aid" from any historical time
408  "o_id" => $original_id, // when the "aid" was valid this was the "id"
409  "points" => $max_points,
410  "sequence" => $sequence
411  );
412  }
413 
414  public function &getQuestion($index, $pass = 0)
415  {
416  if (array_key_exists($index, $this->questions[$pass])) {
417  return $this->questions[$pass][$index];
418  } else {
419  return null;
420  }
421  }
422 
423  public function getQuestionCount($pass = 0)
424  {
425  $count = 0;
426  if (array_key_exists($pass, $this->passes)) {
427  $count = $this->passes[$pass]->getQuestionCount();
428  }
429  return $count;
430  }
431 
432  public function getReachedPoints($pass = 0)
433  {
434  $reached = 0;
435  if (array_key_exists($pass, $this->passes)) {
436  $reached = $this->passes[$pass]->getReachedPoints();
437  }
438  $reached = ($reached < 0) ? 0 : $reached;
439  $reached = round($reached, 2);
440  return $reached;
441  }
442 
443  public function getAvailablePoints($pass = 0)
444  {
445  $available = 0;
446  if (!is_object($this->passes[$pass])) {
447  $pass = 0;
448  }
449  if (!is_object($this->passes[$pass])) {
450  return 0;
451  }
452  $available = $this->passes[$pass]->getMaxPoints();
453  $available = round($available, 2);
454  return $available;
455  }
456 
458  {
459  $reached = $this->getReachedPoints($pass);
460  $available = $this->getAvailablePoints($pass);
461  $percent = ($available > 0) ? $reached / $available : 0;
462  return $percent;
463  }
464 
465  public function setUserID($a_usr_id)
466  {
467  $this->user_id = $a_usr_id;
468  }
469 
470  public function getUserID()
471  {
472  return $this->user_id;
473  }
474 
475  public function setMarkOfficial($a_mark_official)
476  {
477  $this->mark_official = $a_mark_official;
478  }
479 
480  public function getMarkOfficial()
481  {
482  return $this->mark_official;
483  }
484 
491  public function getScoredPassObject()
492  {
493  if ($this->getPassScoring() == 1) {
494  return $this->getBestPassObject();
495  } else {
496  return $this->getLastPassObject();
497  }
498  }
499 
506  {
507  return $this->getRequestedHintsCount($this->getScoredPass());
508  }
509 
517  public function getRequestedHintsCount($pass)
518  {
519  if (!isset($this->passes[$pass]) || !($this->passes[$pass] instanceof ilTestEvaluationPassData)) {
520  throw new ilTestException("invalid pass index given: $pass");
521  }
522 
523  $requestedHintsCount = $this->passes[$pass]->getRequestedHintsCount();
524 
525  return $requestedHintsCount;
526  }
527 
534  public function getBestPassObject()
535  {
536  $bestpoints = 0;
537  $bestpassObject = 0;
538 
539  $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
540 
541  foreach ($this->passes as $pass) {
542  $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
543 
544  if ($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists)) {
545  $bestpoints = $reached;
546  $bestpassObject = $pass;
547  }
548  }
549 
550  return $bestpassObject;
551  }
552 
559  public function getLastPassObject()
560  {
561  $lastpassIndex = 0;
562 
563  foreach (array_keys($this->passes) as $passIndex) {
564  if ($passIndex > $lastpassIndex) {
565  $lastpassIndex = $passIndex;
566  }
567  }
568 
569  $lastpassObject = $this->passes[$lastpassIndex];
570 
571  return $lastpassObject;
572  }
573 
581  {
582  foreach ($this->passes as $pass) {
583  if ($pass->areObligationsAnswered()) {
584  return true;
585  }
586  }
587 
588  return false;
589  }
590 
597  public function areObligationsAnswered()
598  {
599  return $this->getScoredPassObject()->areObligationsAnswered();
600  }
601 } // END ilTestEvaluationUserData
getRequestedHintsCount($pass)
returns the count of hints requested by participant for given testpass
addQuestionTitle($question_id, $question_title)
$index
Definition: metadata.php:60
Base Exception for all Exceptions relating to Modules/Test.
getScoredPassObject()
returns the object of class ilTestEvaluationPassData that relates to the the scored test pass (best p...
$time
Definition: cron.php:21
Create styles array
The data for the language used.
getBestPassObject()
returns the object of class ilTestEvaluationPassData that relates to the the best test pass ...
getLastPassObject()
returns the object of class ilTestEvaluationPassData that relates to the the last test pass ...
addQuestion($original_id, $question_id, $max_points, $sequence=null, $pass=0)
doesObligationsAnsweredPassExist()
returns the fact wether a test pass with all obligations answered exists or not
__construct($passScoring)
Constructor.
getRequestedHintsCountFromScoredPass()
returns the count of hints requested by participant for scored testpass
areObligationsAnswered()
returns the fact wether all obligations in the scored test pass are answered or not ...