ILIAS  Release_4_2_x_branch Revision 61807
 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 
34 include_once "./classes/class.ilObject.php";
35 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
36 
38 {
44  var $name;
45 
51  var $login;
52 
58  var $user_id;
59 
65  var $reached;
66 
73 
79  var $mark;
80 
87 
93  var $markECTS;
94 
101 
108 
115 
122 
129 
135  var $passed;
136 
142  var $passes;
143 
150 
156  private $passScoring;
157 
158  public function __sleep()
159  {
160  return array('questions', 'passes', 'passed', 'lastVisit', 'firstVisit', 'timeOfWork', 'numberOfQuestions',
161  'questionsWorkedThrough', 'markECTS', 'mark_official', 'mark', 'maxpoints', 'reached', 'user_id', 'login',
162  'name', 'passScoring');
163  }
164 
171  {
172  $this->passes = array();
173  $this->questions = array();
174  $this->passed = FALSE;
175  $this->passScoring = $passScoring;
176  }
177 
178  function getPassScoring()
179  {
180  return $this->passScoring;
181  }
182 
184  {
185  $this->passScoring = $passScoring;
186  }
187 
188  function getPassed()
189  {
190  return $this->passed;
191  }
192 
193  function setPassed($a_passed)
194  {
195  $this->passed = ($a_passed ? TRUE : FALSE);
196  }
197 
198  function getName()
199  {
200  return $this->name;
201  }
202 
203  function setName($a_name)
204  {
205  $this->name = $a_name;
206  }
207 
208  function getLogin()
209  {
210  return $this->login;
211  }
212 
213  function setLogin($a_login)
214  {
215  $this->login = $a_login;
216  }
217 
218  function getReached()
219  {
220  return $this->getReachedPoints($this->getScoredPass());
221  }
222 
223  function setReached($a_reached)
224  {
225  $this->reached = $a_reached;
226  }
227 
228  function getMaxpoints()
229  {
230  return $this->getAvailablePoints($this->getScoredPass());
231  }
232 
233  function setMaxpoints($a_max_points)
234  {
235  $this->maxpoints = $a_max_points;
236  }
237 
239  {
240  return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
241  }
242 
243  function getMark()
244  {
245  return $this->mark;
246  }
247 
248  function setMark($a_mark)
249  {
250  $this->mark = $a_mark;
251  }
252 
253  function getECTSMark()
254  {
255  return $this->markECTS;
256  }
257 
258  function setECTSMark($a_mark_ects)
259  {
260  $this->markECTS = $a_mark_ects;
261  }
262 
264  {
265  $questionpass = $this->getScoredPass();
266  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
267  if (is_object($this->passes[$questionpass]))
268  {
269  return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
270  }
271  return 0;
272  }
273 
275  {
276  $this->questionsWorkedThrough = $a_nr;
277  }
278 
280  {
281  $questionpass = $this->getScoredPass();
282  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
283  if (is_object($this->passes[$questionpass]))
284  {
285  return $this->passes[$questionpass]->getQuestionCount();
286  }
287  return 0;
288 // return $this->numberOfQuestions;
289  }
290 
291  function setNumberOfQuestions($a_nr)
292  {
293  $this->numberOfQuestions = $a_nr;
294  }
295 
297  {
298  return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
299  }
300 
301  function getTimeOfWork()
302  {
303  $time = 0;
304  foreach ($this->passes as $pass)
305  {
306  $time += $pass->getWorkingTime();
307  }
308  return $time;
309  }
310 
311  function setTimeOfWork($a_time_of_work)
312  {
313  $this->timeOfWork = $a_time_of_work;
314  }
315 
316  function getFirstVisit()
317  {
318  return $this->firstVisit;
319  }
320 
321  function setFirstVisit($a_time)
322  {
323  $this->firstVisit = $a_time;
324  }
325 
326  function getLastVisit()
327  {
328  return $this->lastVisit;
329  }
330 
331  function setLastVisit($a_time)
332  {
333  $this->lastVisit = $a_time;
334  }
335 
336  function getPasses()
337  {
338  return $this->passes;
339  }
340 
341  function addPass($pass_nr, $pass)
342  {
343  $this->passes[$pass_nr] = $pass;
344  }
345 
346  function &getPass($pass_nr)
347  {
348  if (array_key_exists($pass_nr, $this->passes))
349  {
350  return $this->passes[$pass_nr];
351  }
352  else
353  {
354  return NULL;
355  }
356  }
357 
358  function getPassCount()
359  {
360  return count($this->passes);
361  }
362 
363  function getScoredPass()
364  {
365  if ($this->getPassScoring() == 1)
366  {
367  return $this->getBestPass();
368  }
369  else
370  {
371  return $this->getLastPass();
372  }
373  }
374 
375  function getBestPass()
376  {
377  $bestpoints = 0;
378  $bestpass = 0;
379  foreach ($this->passes as $pass)
380  {
381  $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
382  if ($reached > $bestpoints)
383  {
384  $bestpoints = $reached;
385  $bestpass = $pass->getPass();
386  }
387  }
388  return $bestpass;
389  }
390 
391  function getLastPass()
392  {
393  $lastpass = 0;
394  foreach (array_keys($this->passes) as $pass)
395  {
396  if ($pass > $lastpass) $lastpass = $pass;
397  }
398  return $lastpass;
399  }
400 
401  function addQuestionTitle($question_id, $question_title)
402  {
403  $this->questionTitles[$question_id] = $question_title;
404  }
405 
406  function getQuestionTitles()
407  {
408  return $this->questionTitles;
409  }
410 
411  function &getQuestions($pass = 0)
412  {
413  if (array_key_exists($pass, $this->questions))
414  {
415  return $this->questions[$pass];
416  }
417  else
418  {
419  return NULL;
420  }
421  }
422 
423  function addQuestion($original_id, $question_id, $max_points, $sequence = NULL, $pass = 0)
424  {
425  if( !isset($this->questions[$pass]) )
426  {
427  $this->questions[$pass] = array();
428  }
429 
430  $this->questions[$pass][] = array(
431  "id" => $question_id,
432  "o_id" => $original_id,
433  "points" => $max_points,
434  "sequence" => $sequence
435  );
436  }
437 
438  function &getQuestion($index, $pass = 0)
439  {
440  if (array_key_exists($index, $this->questions[$pass]))
441  {
442  return $this->questions[$pass][$index];
443  }
444  else
445  {
446  return NULL;
447  }
448  }
449 
450  function getQuestionCount($pass = 0)
451  {
452  $count = 0;
453  if (array_key_exists($pass, $this->passes))
454  {
455  $count = $this->passes[$pass]->getQuestionCount();
456  }
457  return $count;
458  }
459 
460  function getReachedPoints($pass = 0)
461  {
462  $reached = 0;
463  if (array_key_exists($pass, $this->passes))
464  {
465  $reached = $this->passes[$pass]->getReachedPoints();
466  }
467  $reached = ($reached < 0) ? 0 : $reached;
468  $reached = round($reached, 2);
469  return $reached;
470  }
471 
472  function getAvailablePoints($pass = 0)
473  {
474  $available = 0;
475  if (!is_object($this->passes[$pass])) $pass = 0;
476  if (!is_object($this->passes[$pass])) return 0;
477  $available = $this->passes[$pass]->getMaxPoints();
478  $available = round($available, 2);
479  return $available;
480  }
481 
483  {
484  $reached = $this->getReachedPoints($pass);
485  $available = $this->getAvailablePoints($pass);
486  $percent = ($available > 0 ) ? $reached / $available : 0;
487  return $percent;
488  }
489 
490  function setUserID($a_usr_id)
491  {
492  $this->user_id = $a_usr_id;
493  }
494 
495  function getUserID()
496  {
497  return $this->user_id;
498  }
499 
500  function setMarkOfficial($a_mark_official)
501  {
502  $this->mark_official = $a_mark_official;
503  }
504 
505  function getMarkOfficial()
506  {
507  return $this->mark_official;
508  }
509 
510 } // END ilTestEvaluationUserData
511 
512 ?>