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