ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  var $name;
26 
32  var $login;
33 
39  var $user_id;
40 
46  var $reached;
47 
54 
60  var $mark;
61 
68 
74  var $markECTS;
75 
82 
89 
96 
103 
110 
116  var $passed;
117 
123  var $passes;
124 
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 
152  {
153  $this->passes = array();
154  $this->questions = array();
155  $this->passed = FALSE;
156  $this->passScoring = $passScoring;
157  }
158 
159  function getPassScoring()
160  {
161  return $this->passScoring;
162  }
163 
165  {
166  $this->passScoring = $passScoring;
167  }
168 
169  function getPassed()
170  {
171  return $this->passed;
172  }
173 
174  function setPassed($a_passed)
175  {
176  $this->passed = ($a_passed ? TRUE : FALSE);
177  }
178 
179  function getName()
180  {
181  return $this->name;
182  }
183 
184  function setName($a_name)
185  {
186  $this->name = $a_name;
187  }
188 
189  function getLogin()
190  {
191  return $this->login;
192  }
193 
194  function setLogin($a_login)
195  {
196  $this->login = $a_login;
197  }
198 
199  function getReached()
200  {
201  return $this->getReachedPoints($this->getScoredPass());
202  }
203 
204  function setReached($a_reached)
205  {
206  $this->reached = $a_reached;
207  }
208 
209  function getMaxpoints()
210  {
211  return $this->getAvailablePoints($this->getScoredPass());
212  }
213 
214  function setMaxpoints($a_max_points)
215  {
216  $this->maxpoints = $a_max_points;
217  }
218 
220  {
221  return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
222  }
223 
224  function getMark()
225  {
226  return $this->mark;
227  }
228 
229  function setMark($a_mark)
230  {
231  $this->mark = $a_mark;
232  }
233 
234  function getECTSMark()
235  {
236  return $this->markECTS;
237  }
238 
239  function setECTSMark($a_mark_ects)
240  {
241  $this->markECTS = $a_mark_ects;
242  }
243 
245  {
246  $questionpass = $this->getScoredPass();
247  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
248  if (is_object($this->passes[$questionpass]))
249  {
250  return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
251  }
252  return 0;
253  }
254 
256  {
257  $this->questionsWorkedThrough = $a_nr;
258  }
259 
261  {
262  $questionpass = $this->getScoredPass();
263  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
264  if (is_object($this->passes[$questionpass]))
265  {
266  return $this->passes[$questionpass]->getQuestionCount();
267  }
268  return 0;
269 // return $this->numberOfQuestions;
270  }
271 
272  function setNumberOfQuestions($a_nr)
273  {
274  $this->numberOfQuestions = $a_nr;
275  }
276 
278  {
279  return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
280  }
281 
282  function getTimeOfWork()
283  {
284  $time = 0;
285  foreach ($this->passes as $pass)
286  {
287  $time += $pass->getWorkingTime();
288  }
289  return $time;
290  }
291 
292  function setTimeOfWork($a_time_of_work)
293  {
294  $this->timeOfWork = $a_time_of_work;
295  }
296 
297  function getFirstVisit()
298  {
299  return $this->firstVisit;
300  }
301 
302  function setFirstVisit($a_time)
303  {
304  $this->firstVisit = $a_time;
305  }
306 
307  function getLastVisit()
308  {
309  return $this->lastVisit;
310  }
311 
312  function setLastVisit($a_time)
313  {
314  $this->lastVisit = $a_time;
315  }
316 
317  function getPasses()
318  {
319  return $this->passes;
320  }
321 
322  function addPass($pass_nr, $pass)
323  {
324  $this->passes[$pass_nr] = $pass;
325  }
326 
327  function &getPass($pass_nr)
328  {
329  if (array_key_exists($pass_nr, $this->passes))
330  {
331  return $this->passes[$pass_nr];
332  }
333  else
334  {
335  return NULL;
336  }
337  }
338 
339  function getPassCount()
340  {
341  return count($this->passes);
342  }
343 
344  function getScoredPass()
345  {
346  if ($this->getPassScoring() == 1)
347  {
348  return $this->getBestPass();
349  }
350  else
351  {
352  return $this->getLastPass();
353  }
354  }
355 
356  function getBestPass()
357  {
358  $bestpoints = 0;
359  $bestpass = 0;
360 
361  $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
362 
363  foreach( $this->passes as $pass )
364  {
365  $reached = $this->getReachedPointsInPercentForPass( $pass->getPass() );
366 
367  if($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists) )
368  {
369  $bestpoints = $reached;
370  $bestpass = $pass->getPass();
371  }
372  }
373 
374  return $bestpass;
375  }
376 
377  function getLastPass()
378  {
379  $lastpass = 0;
380  foreach (array_keys($this->passes) as $pass)
381  {
382  if ($pass > $lastpass) $lastpass = $pass;
383  }
384  return $lastpass;
385  }
386 
387  function addQuestionTitle($question_id, $question_title)
388  {
389  $this->questionTitles[$question_id] = $question_title;
390  }
391 
392  function getQuestionTitles()
393  {
394  return $this->questionTitles;
395  }
396 
397  function &getQuestions($pass = 0)
398  {
399  if (array_key_exists($pass, $this->questions))
400  {
401  return $this->questions[$pass];
402  }
403  else
404  {
405  return NULL;
406  }
407  }
408 
409  function addQuestion($original_id, $question_id, $max_points, $sequence = NULL, $pass = 0)
410  {
411  if( !isset($this->questions[$pass]) )
412  {
413  $this->questions[$pass] = array();
414  }
415 
416  $this->questions[$pass][] = array(
417  "id" => $question_id,
418  "o_id" => $original_id,
419  "points" => $max_points,
420  "sequence" => $sequence
421  );
422  }
423 
424  function &getQuestion($index, $pass = 0)
425  {
426  if (array_key_exists($index, $this->questions[$pass]))
427  {
428  return $this->questions[$pass][$index];
429  }
430  else
431  {
432  return NULL;
433  }
434  }
435 
436  function getQuestionCount($pass = 0)
437  {
438  $count = 0;
439  if (array_key_exists($pass, $this->passes))
440  {
441  $count = $this->passes[$pass]->getQuestionCount();
442  }
443  return $count;
444  }
445 
446  function getReachedPoints($pass = 0)
447  {
448  $reached = 0;
449  if (array_key_exists($pass, $this->passes))
450  {
451  $reached = $this->passes[$pass]->getReachedPoints();
452  }
453  $reached = ($reached < 0) ? 0 : $reached;
454  $reached = round($reached, 2);
455  return $reached;
456  }
457 
458  function getAvailablePoints($pass = 0)
459  {
460  $available = 0;
461  if (!is_object($this->passes[$pass])) $pass = 0;
462  if (!is_object($this->passes[$pass])) return 0;
463  $available = $this->passes[$pass]->getMaxPoints();
464  $available = round($available, 2);
465  return $available;
466  }
467 
469  {
470  $reached = $this->getReachedPoints($pass);
471  $available = $this->getAvailablePoints($pass);
472  $percent = ($available > 0 ) ? $reached / $available : 0;
473  return $percent;
474  }
475 
476  function setUserID($a_usr_id)
477  {
478  $this->user_id = $a_usr_id;
479  }
480 
481  function getUserID()
482  {
483  return $this->user_id;
484  }
485 
486  function setMarkOfficial($a_mark_official)
487  {
488  $this->mark_official = $a_mark_official;
489  }
490 
491  function getMarkOfficial()
492  {
493  return $this->mark_official;
494  }
495 
502  public function getScoredPassObject()
503  {
504  if ($this->getPassScoring() == 1)
505  {
506  return $this->getBestPassObject();
507  }
508  else
509  {
510  return $this->getLastPassObject();
511  }
512  }
513 
520  {
521  return $this->getRequestedHintsCount($this->getScoredPass());
522  }
523 
531  public function getRequestedHintsCount($pass)
532  {
533  if( !isset($this->passes[$pass]) || !($this->passes[$pass] instanceof ilTestEvaluationPassData) )
534  {
535  throw new ilTestException("invalid pass index given: $pass");
536  }
537 
538  $requestedHintsCount = $this->passes[$pass]->getRequestedHintsCount();
539 
540  return $requestedHintsCount;
541  }
542 
549  public function getBestPassObject()
550  {
551  $bestpoints = 0;
552  $bestpassObject = 0;
553 
554  $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
555 
556  foreach( $this->passes as $pass )
557  {
558  $reached = $this->getReachedPointsInPercentForPass( $pass->getPass() );
559 
560  if($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists) )
561  {
562  $bestpoints = $reached;
563  $bestpassObject = $pass;
564  }
565  }
566 
567  return $bestpassObject;
568  }
569 
576  public function getLastPassObject()
577  {
578  $lastpassIndex = 0;
579 
580  foreach( array_keys($this->passes) as $passIndex )
581  {
582  if ($passIndex > $lastpassIndex) $lastpassIndex = $passIndex;
583  }
584 
585  $lastpassObject = $this->passes[$lastpassIndex];
586 
587  return $lastpassObject;
588  }
589 
597  {
598  foreach( $this->passes as $pass )
599  {
600  if( $pass->areObligationsAnswered() )
601  {
602  return true;
603  }
604  }
605 
606  return false;
607  }
608 
615  public function areObligationsAnswered()
616  {
617  return $this->getScoredPassObject()->areObligationsAnswered();
618  }
619 
620 } // END ilTestEvaluationUserData