ILIAS  Release_3_10_x_branch Revision 61812
 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  //return $this->reached;
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  //return $this->maxpoints;
233  }
234 
235  function setMaxpoints($a_max_points)
236  {
237  $this->maxpoints = $a_max_points;
238  }
239 
241  {
242  return $this->getMaxPoints() ? $this->getReached() / $this->getMaxPoints() * 100.0 : 0;
243  }
244 
245  function getMark()
246  {
247  return $this->mark;
248  }
249 
250  function setMark($a_mark)
251  {
252  $this->mark = $a_mark;
253  }
254 
255  function getECTSMark()
256  {
257  return $this->markECTS;
258  }
259 
260  function setECTSMark($a_mark_ects)
261  {
262  $this->markECTS = $a_mark_ects;
263  }
264 
266  {
267  $questionpass = $this->getScoredPass();
268  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
269  if (is_object($this->passes[$questionpass]))
270  {
271  return $this->passes[$questionpass]->getNrOfAnsweredQuestions();
272  }
273  return 0;
274  }
275 
277  {
278  $this->questionsWorkedThrough = $a_nr;
279  }
280 
282  {
283  $questionpass = $this->getScoredPass();
284  if (!is_object($this->passes[$questionpass])) $questionpass = 0;
285  if (is_object($this->passes[$questionpass]))
286  {
287  return $this->passes[$questionpass]->getQuestionCount();
288  }
289  return 0;
290 // return $this->numberOfQuestions;
291  }
292 
293  function setNumberOfQuestions($a_nr)
294  {
295  $this->numberOfQuestions = $a_nr;
296  }
297 
299  {
300  return $this->getNumberOfQuestions() ? $this->getQuestionsWorkedThrough() / $this->getNumberOfQuestions() * 100.0 : 0;
301  }
302 
303  function getTimeOfWork()
304  {
305  $time = 0;
306  foreach ($this->passes as $pass)
307  {
308  $time += $pass->getWorkingTime();
309  }
310  return $time;
311  }
312 
313  function setTimeOfWork($a_time_of_work)
314  {
315  $this->timeOfWork = $a_time_of_work;
316  }
317 
318  function getFirstVisit()
319  {
320  return $this->firstVisit;
321  }
322 
323  function setFirstVisit($a_time)
324  {
325  $this->firstVisit = $a_time;
326  }
327 
328  function getLastVisit()
329  {
330  return $this->lastVisit;
331  }
332 
333  function setLastVisit($a_time)
334  {
335  $this->lastVisit = $a_time;
336  }
337 
338  function getPasses()
339  {
340  return $this->passes;
341  }
342 
343  function addPass($pass_nr, $pass)
344  {
345  $this->passes[$pass_nr] = $pass;
346  }
347 
348  function &getPass($pass_nr)
349  {
350  if (array_key_exists($pass_nr, $this->passes))
351  {
352  return $this->passes[$pass_nr];
353  }
354  else
355  {
356  return NULL;
357  }
358  }
359 
360  function getPassCount()
361  {
362  return count($this->passes);
363  }
364 
365  function getScoredPass()
366  {
367  if ($this->getPassScoring() == 1)
368  {
369  return $this->getBestPass();
370  }
371  else
372  {
373  return $this->getLastPass();
374  }
375  }
376 
377  function getBestPass()
378  {
379  $bestpoints = 0;
380  $bestpass = 0;
381  foreach ($this->passes as $pass)
382  {
383  $reached = $this->getReachedPointsInPercentForPass($pass->getPass());
384  if ($reached > $bestpoints)
385  {
386  $bestpoints = $reached;
387  $bestpass = $pass->getPass();
388  }
389  }
390  return $bestpass;
391  }
392 
393  function getLastPass()
394  {
395  $lastpass = 0;
396  foreach (array_keys($this->passes) as $pass)
397  {
398  if ($pass > $lastpass) $lastpass = $pass;
399  }
400  return $lastpass;
401  }
402 
403  function addQuestionTitle($question_id, $question_title)
404  {
405  $this->questionTitles[$question_id] = $question_title;
406  }
407 
408  function getQuestionTitles()
409  {
410  return $this->questionTitles;
411  }
412 
413  function &getQuestions($pass = 0)
414  {
415  if (array_key_exists($pass, $this->questions))
416  {
417  return $this->questions[$pass];
418  }
419  else
420  {
421  return NULL;
422  }
423  }
424 
425  function addQuestion($original_id, $question_id, $max_points, $sequence = NULL, $pass = 0)
426  {
427  if (!array_key_exists($pass, $this->questions)) $this->questions[$pass] = array();
428  array_push($this->questions[$pass], array("id" => $original_id, "aid" => $question_id, "points" => $max_points, "sequence" => $sequence));
429  }
430 
431  function &getQuestion($index, $pass = 0)
432  {
433  if (array_key_exists($index, $this->questions[$pass]))
434  {
435  return $this->questions[$pass][$index];
436  }
437  else
438  {
439  return NULL;
440  }
441  }
442 
443  function getQuestionCount($pass = 0)
444  {
445  $count = 0;
446  if (array_key_exists($pass, $this->passes))
447  {
448  $count = $this->passes[$pass]->getQuestionCount();
449  }
450  return $count;
451  }
452 
453  function getReachedPoints($pass = 0)
454  {
455  $reached = 0;
456  if (array_key_exists($pass, $this->passes))
457  {
458  $reached = $this->passes[$pass]->getReachedPoints();
459  }
460  $reached = ($reached < 0) ? 0 : $reached;
461  return $reached;
462  }
463 
464  function getAvailablePoints($pass = 0)
465  {
466  $available = 0;
467  if (!is_object($this->passes[$pass])) $pass = 0;
468  if (!is_object($this->passes[$pass])) return 0;
469  $available = $this->passes[$pass]->getMaxPoints();
470  return $available;
471  }
472 
474  {
475  $reached = $this->getReachedPoints($pass);
476  $available = $this->getAvailablePoints($pass);
477  $percent = ($available > 0 ) ? $reached / $available : 0;
478  return $percent;
479  }
480 
481  function setUserID($a_usr_id)
482  {
483  $this->user_id = $a_usr_id;
484  }
485 
486  function getUserID()
487  {
488  return $this->user_id;
489  }
490 
491  function setMarkOfficial($a_mark_official)
492  {
493  $this->mark_official = $a_mark_official;
494  }
495 
496  function getMarkOfficial()
497  {
498  return $this->mark_official;
499  }
500 
501 } // END ilTestEvaluationUserData
502 
503 ?>