ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationUserData.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
35 include_once "./Services/Object/classes/class.ilObject.php";
36 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
37 
39 {
45  var $name;
46 
52  var $login;
53 
59  var $user_id;
60 
66  var $reached;
67 
74 
80  var $mark;
81 
88 
94  var $markECTS;
95 
102 
109 
116 
123 
130 
136  var $passed;
137 
143  var $passes;
144 
151 
157  private $passScoring;
158 
159  public function __sleep()
160  {
161  return array('questions', 'passes', 'passed', 'lastVisit', 'firstVisit', 'timeOfWork', 'numberOfQuestions',
162  'questionsWorkedThrough', 'markECTS', 'mark_official', 'mark', 'maxpoints', 'reached', 'user_id', 'login',
163  'name', 'passScoring');
164  }
165 
172  {
173  $this->passes = array();
174  $this->questions = array();
175  $this->passed = FALSE;
176  $this->passScoring = $passScoring;
177  }
178 
179  function getPassScoring()
180  {
181  return $this->passScoring;
182  }
183 
185  {
186  $this->passScoring = $passScoring;
187  }
188 
189  function getPassed()
190  {
191  return $this->passed;
192  }
193 
194  function setPassed($a_passed)
195  {
196  $this->passed = ($a_passed ? TRUE : FALSE);
197  }
198 
199  function getName()
200  {
201  return $this->name;
202  }
203 
204  function setName($a_name)
205  {
206  $this->name = $a_name;
207  }
208 
209  function getLogin()
210  {
211  return $this->login;
212  }
213 
214  function setLogin($a_login)
215  {
216  $this->login = $a_login;
217  }
218 
219  function getReached()
220  {
221  return $this->getReachedPoints($this->getScoredPass());
222  }
223 
224  function setReached($a_reached)
225  {
226  $this->reached = $a_reached;
227  }
228 
229  function getMaxpoints()
230  {
231  return $this->getAvailablePoints($this->getScoredPass());
232  }
233 
234  function setMaxpoints($a_max_points)
235  {
236  $this->maxpoints = $a_max_points;
237  }
238 
240  {
241  return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
242  }
243 
244  function getMark()
245  {
246  return $this->mark;
247  }
248 
249  function setMark($a_mark)
250  {
251  $this->mark = $a_mark;
252  }
253 
254  function getECTSMark()
255  {
256  return $this->markECTS;
257  }
258 
259  function setECTSMark($a_mark_ects)
260  {
261  $this->markECTS = $a_mark_ects;
262  }
263 
265  {
266  $questionpass = $this->getScoredPass();
267  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
268  if (is_object($this->passes[$questionpass]))
269  {
270  return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
271  }
272  return 0;
273  }
274 
276  {
277  $this->questionsWorkedThrough = $a_nr;
278  }
279 
281  {
282  $questionpass = $this->getScoredPass();
283  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
284  if (is_object($this->passes[$questionpass]))
285  {
286  return $this->passes[$questionpass]->getQuestionCount();
287  }
288  return 0;
289 // return $this->numberOfQuestions;
290  }
291 
292  function setNumberOfQuestions($a_nr)
293  {
294  $this->numberOfQuestions = $a_nr;
295  }
296 
298  {
299  return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
300  }
301 
302  function getTimeOfWork()
303  {
304  $time = 0;
305  foreach ($this->passes as $pass)
306  {
307  $time += $pass->getWorkingTime();
308  }
309  return $time;
310  }
311 
312  function setTimeOfWork($a_time_of_work)
313  {
314  $this->timeOfWork = $a_time_of_work;
315  }
316 
317  function getFirstVisit()
318  {
319  return $this->firstVisit;
320  }
321 
322  function setFirstVisit($a_time)
323  {
324  $this->firstVisit = $a_time;
325  }
326 
327  function getLastVisit()
328  {
329  return $this->lastVisit;
330  }
331 
332  function setLastVisit($a_time)
333  {
334  $this->lastVisit = $a_time;
335  }
336 
337  function getPasses()
338  {
339  return $this->passes;
340  }
341 
342  function addPass($pass_nr, $pass)
343  {
344  $this->passes[$pass_nr] = $pass;
345  }
346 
347  function &getPass($pass_nr)
348  {
349  if (array_key_exists($pass_nr, $this->passes))
350  {
351  return $this->passes[$pass_nr];
352  }
353  else
354  {
355  return NULL;
356  }
357  }
358 
359  function getPassCount()
360  {
361  return count($this->passes);
362  }
363 
364  function getScoredPass()
365  {
366  if ($this->getPassScoring() == 1)
367  {
368  return $this->getBestPass();
369  }
370  else
371  {
372  return $this->getLastPass();
373  }
374  }
375 
376  function getBestPass()
377  {
378  $bestpoints = 0;
379  $bestpass = 0;
380 
381  $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
382 
383  foreach( $this->passes as $pass )
384  {
385  $reached = $this->getReachedPointsInPercentForPass( $pass->getPass() );
386 
387  if($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists) )
388  {
389  $bestpoints = $reached;
390  $bestpass = $pass->getPass();
391  }
392  }
393 
394  return $bestpass;
395  }
396 
397  function getLastPass()
398  {
399  $lastpass = 0;
400  foreach (array_keys($this->passes) as $pass)
401  {
402  if ($pass > $lastpass) $lastpass = $pass;
403  }
404  return $lastpass;
405  }
406 
407  function addQuestionTitle($question_id, $question_title)
408  {
409  $this->questionTitles[$question_id] = $question_title;
410  }
411 
412  function getQuestionTitles()
413  {
414  return $this->questionTitles;
415  }
416 
417  function &getQuestions($pass = 0)
418  {
419  if (array_key_exists($pass, $this->questions))
420  {
421  return $this->questions[$pass];
422  }
423  else
424  {
425  return NULL;
426  }
427  }
428 
429  function addQuestion($original_id, $question_id, $max_points, $sequence = NULL, $pass = 0)
430  {
431  if( !isset($this->questions[$pass]) )
432  {
433  $this->questions[$pass] = array();
434  }
435 
436  $this->questions[$pass][] = array(
437  "id" => $question_id,
438  "o_id" => $original_id,
439  "points" => $max_points,
440  "sequence" => $sequence
441  );
442  }
443 
444  function &getQuestion($index, $pass = 0)
445  {
446  if (array_key_exists($index, $this->questions[$pass]))
447  {
448  return $this->questions[$pass][$index];
449  }
450  else
451  {
452  return NULL;
453  }
454  }
455 
456  function getQuestionCount($pass = 0)
457  {
458  $count = 0;
459  if (array_key_exists($pass, $this->passes))
460  {
461  $count = $this->passes[$pass]->getQuestionCount();
462  }
463  return $count;
464  }
465 
466  function getReachedPoints($pass = 0)
467  {
468  $reached = 0;
469  if (array_key_exists($pass, $this->passes))
470  {
471  $reached = $this->passes[$pass]->getReachedPoints();
472  }
473  $reached = ($reached < 0) ? 0 : $reached;
474  $reached = round($reached, 2);
475  return $reached;
476  }
477 
478  function getAvailablePoints($pass = 0)
479  {
480  $available = 0;
481  if (!is_object($this->passes[$pass])) $pass = 0;
482  if (!is_object($this->passes[$pass])) return 0;
483  $available = $this->passes[$pass]->getMaxPoints();
484  $available = round($available, 2);
485  return $available;
486  }
487 
489  {
490  $reached = $this->getReachedPoints($pass);
491  $available = $this->getAvailablePoints($pass);
492  $percent = ($available > 0 ) ? $reached / $available : 0;
493  return $percent;
494  }
495 
496  function setUserID($a_usr_id)
497  {
498  $this->user_id = $a_usr_id;
499  }
500 
501  function getUserID()
502  {
503  return $this->user_id;
504  }
505 
506  function setMarkOfficial($a_mark_official)
507  {
508  $this->mark_official = $a_mark_official;
509  }
510 
511  function getMarkOfficial()
512  {
513  return $this->mark_official;
514  }
515 
522  public function getScoredPassObject()
523  {
524  if ($this->getPassScoring() == 1)
525  {
526  return $this->getBestPassObject();
527  }
528  else
529  {
530  return $this->getLastPassObject();
531  }
532  }
533 
540  {
541  return $this->getRequestedHintsCount($this->getScoredPass());
542  }
543 
551  public function getRequestedHintsCount($pass)
552  {
553  if( !isset($this->passes[$pass]) || !($this->passes[$pass] instanceof ilTestEvaluationPassData) )
554  {
555  throw new ilTestException("invalid pass index given: $pass");
556  }
557 
558  $requestedHintsCount = $this->passes[$pass]->getRequestedHintsCount();
559 
560  return $requestedHintsCount;
561  }
562 
569  public function getBestPassObject()
570  {
571  $bestpoints = 0;
572  $bestpassObject = 0;
573 
574  $obligationsAnsweredPassExists = $this->doesObligationsAnsweredPassExist();
575 
576  foreach( $this->passes as $pass )
577  {
578  $reached = $this->getReachedPointsInPercentForPass( $pass->getPass() );
579 
580  if($reached >= $bestpoints && ($pass->areObligationsAnswered() || !$obligationsAnsweredPassExists) )
581  {
582  $bestpoints = $reached;
583  $bestpassObject = $pass;
584  }
585  }
586 
587  return $bestpassObject;
588  }
589 
596  public function getLastPassObject()
597  {
598  $lastpassIndex = 0;
599 
600  foreach( array_keys($this->passes) as $passIndex )
601  {
602  if ($passIndex > $lastpassIndex) $lastpassIndex = $passIndex;
603  }
604 
605  $lastpassObject = $this->passes[$lastpassIndex];
606 
607  return $lastpassObject;
608  }
609 
617  {
618  foreach( $this->passes as $pass )
619  {
620  if( $pass->areObligationsAnswered() )
621  {
622  return true;
623  }
624  }
625 
626  return false;
627  }
628 
635  public function areObligationsAnswered()
636  {
637  return $this->getScoredPassObject()->areObligationsAnswered();
638  }
639 
640 } // END ilTestEvaluationUserData