ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjTestAccess.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Services/Object/classes/class.ilObjectAccess.php";
5 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
6 include_once './Services/AccessControl/interfaces/interface.ilConditionHandling.php';
7 
21 {
37  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
38  {
39  global $ilUser, $lng, $rbacsystem, $ilAccess;
40 
41  if ($a_user_id == "")
42  {
43  $a_user_id = $ilUser->getId();
44  }
45 
46  $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
47 
48  // check "global" online switch
49  if(!self::_isOnline($a_obj_id) && !$is_admin)
50  {
51  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
52  return false;
53  }
54 
55  switch ($a_permission)
56  {
57  case "visible":
58  case "read":
60  !$is_admin)
61  {
62  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
63  return false;
64  }
65  break;
66  }
67 
68  switch ($a_cmd)
69  {
70  case "eval_a":
71  case "eval_stat":
73  {
74  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
75  return false;
76  }
77  break;
78 
79  }
80 
81  return true;
82  }
83 
92  function _getMaxPointsForTestPass($random, $user_id, $test_id, $pass)
93  {
94  global $ilDB;
95  $max = 0;
96  if ($random)
97  {
98  $result = $ilDB->queryF("SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_rnd_qst, qpl_questions, tst_active WHERE tst_active.active_id = tst_test_rnd_qst.active_fi AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_active.test_fi = %s AND tst_test_rnd_qst.pass = %s AND tst_active.user_fi = %s",
99  array('integer','integer','integer'),
100  array($test_id, $pass, $user_id)
101  );
102  if ($result->numRows())
103  {
104  $row = $ilDB->fetchAssoc($result);
105  $max = $row["maxpoints"];
106  }
107  }
108  else
109  {
110  $result = $ilDB->queryF("SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_question, qpl_questions WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s",
111  array('integer'),
112  array($test_id)
113  );
114  if ($result->numRows())
115  {
116  $row = $ilDB->fetchAssoc($result);
117  $max = $row["maxpoints"];
118  }
119  }
120  return $max;
121  }
122 
130  public static function _isPassed($user_id, $a_obj_id)
131  {
132  global $ilDB;
133  $result = $ilDB->queryF("SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
134  array('integer','integer'),
135  array($user_id, $a_obj_id)
136  );
137  if (!$result->numRows())
138  {
139  $result = $ilDB->queryF("SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
140  array('integer','integer'),
141  array($user_id, $a_obj_id)
142  );
143  $row = $ilDB->fetchAssoc($result);
144  if ($row['active_id'] > 0)
145  {
146  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
148  }
149  else
150  {
151  return false;
152  }
153  }
154  $result = $ilDB->queryF("SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
155  array('integer','integer'),
156  array($user_id, $a_obj_id)
157  );
158  if (!$result->numRows())
159  {
160  $result = $ilDB->queryF("SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
161  array('integer','integer'),
162  array($user_id, $a_obj_id)
163  );
164  $points = array();
165  while ($row = $ilDB->fetchAssoc($result))
166  {
167  array_push($points, $row);
168  }
169  $reached = 0;
170  $max = 0;
171  if ($points[0]["pass_scoring"] == 0)
172  {
173  $reached = $points[count($points)-1]["points"];
174  $max = $points[count($points)-1]["maxpoints"];
175  if (!$max)
176  {
177  $active_id = $points[count($points)-1]["active_fi"];
178  $pass = $points[count($points)-1]["pass"];
179  if (strlen($active_id) && strlen($pass))
180  {
181  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
182  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
183  $max = $res['maxpoints'];
184  $reached = $res['points'];
185  }
186  }
187  }
188  else
189  {
190  foreach ($points as $row)
191  {
192  if ($row["points"] > $reached)
193  {
194  $reached = $row["points"];
195  $max = $row["maxpoints"];
196  if (!$max)
197  {
198  $active_id = $row["active_fi"];
199  $pass = $row["pass"];
200  if (strlen($active_id) && strlen($pass))
201  {
202  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
203  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
204  $max = $res['maxpoints'];
205  $reached = $res['points'];
206  }
207  }
208  }
209  }
210  }
211  include_once "./Modules/Test/classes/class.assMarkSchema.php";
212  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
213  $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
214  return ($mark["passed"]) ? TRUE : FALSE;
215  }
216  else
217  {
218  $row = $ilDB->fetchAssoc($result);
219  return ($row['passed']) ? true : false;
220  }
221  }
222 
230  public static function isFailed($user_id, $a_obj_id)
231  {
232  global $ilDB;
233 
234  $ret = self::updateTestResultCache($user_id, $a_obj_id);
235 
236  if(!$ret)
237  {
238  return false;
239  }
240 
241  $result = $ilDB->queryF("SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
242  array('integer','integer'),
243  array($user_id, $a_obj_id)
244  );
245 
246  if (!$result->numRows())
247  {
248  $result = $ilDB->queryF("SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
249  array('integer','integer'),
250  array($user_id, $a_obj_id)
251  );
252 
253  while ($row = $ilDB->fetchAssoc($result))
254  {
255  array_push($points, $row);
256  }
257  $reached = 0;
258  $max = 0;
259  if ($points[0]["pass_scoring"] == 0)
260  {
261  $reached = $points[count($points)-1]["points"];
262  $max = $points[count($points)-1]["maxpoints"];
263  if (!$max)
264  {
265  $active_id = $points[count($points)-1]["active_fi"];
266  $pass = $points[count($points)-1]["pass"];
267  if (strlen($active_id) && strlen($pass))
268  {
269  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
270  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
271  $max = $res['maxpoints'];
272  $reached = $res['points'];
273  }
274  }
275  }
276  else
277  {
278  foreach ($points as $row)
279  {
280  if ($row["points"] > $reached)
281  {
282  $reached = $row["points"];
283  $max = $row["maxpoints"];
284  if (!$max)
285  {
286  $active_id = $row["active_fi"];
287  $pass = $row["pass"];
288  if (strlen($active_id) && strlen($pass))
289  {
290  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
291  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
292  $max = $res['maxpoints'];
293  $reached = $res['points'];
294  }
295  }
296  }
297  }
298  }
299  include_once "./Modules/Test/classes/class.assMarkSchema.php";
300  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
301  $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
302  return ($mark["failed"]) ? TRUE : FALSE;
303  }
304  else
305  {
306  $row = $ilDB->fetchAssoc($result);
307  return ($row['failed']) ? TRUE : FALSE;
308  }
309  }
310 
316  protected function updateTestResultCache($a_user_id, $a_obj_id)
317  {
318  global $ilDB;
319 
320  $result = $ilDB->queryF(
321  "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests ".
322  "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s ".
323  "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
324  array('integer','integer'),
325  array($a_user_id, $a_obj_id)
326  );
327  if (!$result->numRows())
328  {
329  $result = $ilDB->queryF("SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
330  array('integer','integer'),
331  array($a_user_id, $a_obj_id)
332  );
333  $row = $ilDB->fetchAssoc($result);
334  if ($row['active_id'] > 0)
335  {
336  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
338  return true;
339  }
340  else
341  {
342  return false;
343  }
344 
345  }
346  else
347  {
348  return true;
349  }
350  }
351 
352 
356  public static function getConditionOperators()
357  {
358  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
359  return array(
364  );
365  }
366 
367 
373  public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
374  {
375  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
376 
377  switch($a_operator)
378  {
380  return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
381  break;
382 
384  return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
385 
387  return ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
388 
390  return !ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
391 
392  default:
393  return true;
394  }
395  return true;
396  }
397 
410  function _getCommands()
411  {
412  $commands = array
413  (
414  array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
415  array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "lang_var" => "settings"),
416  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
417  "default" => true),
418  //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
419  array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
420  array("permission" => "read", "cmd" => "userResultsGateway", "lang_var" => "tst_test_results")
421  );
422 
423  return $commands;
424  }
425 
426  //
427  // object specific access related methods
428  //
429 
433  function _lookupCreationComplete($a_obj_id)
434  {
435  global $ilDB;
436 
437  $result = $ilDB->queryF("SELECT complete FROM tst_tests WHERE obj_fi=%s",
438  array('integer'),
439  array($a_obj_id)
440  );
441  if ($result->numRows() == 1)
442  {
443  $row = $ilDB->fetchAssoc($result);
444  }
445 
446  return ($row['complete']) ? true : false;
447  }
448 
454  private static $hasFinishedCache = array();
455 
463  public static function hasFinished($a_user_id, $a_obj_id)
464  {
465  if( !isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"]) )
466  {
467  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
468  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
469  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
470 
471  global $ilDB, $lng;
472 
473  $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
474 
475  $partData = new ilTestParticipantData($ilDB, $lng);
476  $partData->setUserIds(array($a_user_id));
477  $partData->load($testOBJ->getTestId());
478 
479  $activeId = $partData->getActiveIdByUserId($a_user_id);
480 
481  $testSessionFactory = new ilTestSessionFactory($testOBJ);
482  $testSession = $testSessionFactory->getSession($activeId);
483 
484  $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
485  $testPassesSelector->setActiveId($activeId);
486  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
487 
488  self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
489  }
490 
491  return self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
492  }
493 
501  function _getTestIDFromObjectID($object_id)
502  {
503  global $ilDB;
504  $test_id = FALSE;
505  $result = $ilDB->queryF("SELECT test_id FROM tst_tests WHERE obj_fi = %s",
506  array('integer'),
507  array($object_id)
508  );
509  if ($result->numRows())
510  {
511  $row = $ilDB->fetchAssoc($result);
512  $test_id = $row["test_id"];
513  }
514  return $test_id;
515  }
516 
517  function &_getTestQuestions($active_id, $pass = NULL)
518  {
519  if (is_null($pass))
520  {
521  $pass = 0;
522  }
523  $questions = array();
524 
525  global $ilDB;
526  $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
527  array('integer'),
528  array($active_id)
529  );
530  $test_id = "";
531  if ($result->numRows())
532  {
533  $row = $ilDB->fetchAssoc($result);
534  $test_id = $row["test_fi"];
535  }
536  else
537  {
538  return $questions;
539  }
540  $result = $ilDB->queryF("SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s ORDER BY tst_test_question.sequence",
541  array('integer'),
542  array($test_id)
543  );
544  if ($result->numRows())
545  {
546  // standard test
547  while ($row = $ilDB->fetchAssoc($result))
548  {
549  array_push($questions, $row);
550  }
551  }
552  else
553  {
554  // random test
555  $result = $ilDB->queryF("SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_rnd_qst WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s ORDER BY tst_test_rnd_qst.sequence",
556  array('integer','integer'),
557  array($active_id, $pass)
558  );
559  if ($result->numRows())
560  {
561  while ($row = $ilDB->fetchAssoc($result))
562  {
563  array_push($questions, $row);
564  }
565  }
566  }
567  return $questions;
568  }
569 
576  function _isComplete($a_obj_id)
577  {
578  global $ilDB;
579 
580  $query = "
581  SELECT tst_tests.complete
582  FROM object_data
583  INNER JOIN tst_tests
584  ON tst_tests.obj_fi = object_data.obj_id
585  WHERE object_data.obj_id = %s
586  ";
587 
588  $res = $ilDB->queryF($query, array('integer'), array($a_obj_id));
589 
590  while( $row = $ilDB->fetchAssoc($res) )
591  {
592  return (bool)$row['complete'];
593  }
594 
595  return false;
596  }
597 
605  function &_getTestData($test_id)
606  {
607  global $ilDB;
608  $result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s",
609  array('integer'),
610  array($test_id)
611  );
612  if (!$result->numRows())
613  {
614  return 0;
615  }
616  return $ilDB->fetchAssoc($result);
617  }
618 
625  function _lookupObjIdForTestId($a_test_id)
626  {
627  global $ilDB;
628 
629  $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
630  array('integer'),
631  array($a_test_id)
632  );
633 
634  $row = $ilDB->fetchAssoc($result);
635  return $row["obj_fi"];
636  }
637 
646  {
647  global $ilDB;
648 
649  $query = "
650  SELECT DISTINCT t.obj_fi
651  FROM tst_tests t
652  INNER JOIN tst_rnd_quest_set_qpls r
653  ON t.test_id = r.test_fi
654  WHERE r.pool_fi = %s
655  ";
656 
657  $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
658 
659  $tests = array();
660  while ($row = $ilDB->fetchAssoc($result))
661  {
662  $tests[] = $row['obj_fi'];
663  }
664 
665  return $tests;
666  }
667  // fim.
668 
675  function _lookupOnlineTestAccess($a_test_id, $a_user_id)
676  {
677  global $ilDB, $lng;
678 
679  $result = $ilDB->queryF("SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
680  array('integer'),
681  array($a_test_id)
682  );
683  if ($result->numRows())
684  {
685  $row = $ilDB->fetchAssoc($result);
686  if ($row["fixed_participants"])
687  {
688  $result = $ilDB->queryF("SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
689  array('integer','integer'),
690  array($row["test_id"], $a_user_id)
691  );
692  if ($result->numRows())
693  {
694  $row = $ilDB->fetchAssoc($result);
695  if (trim($row['clientip']) != "")
696  {
697  $row['clientip'] = preg_replace("/[^0-9.?*,:]+/","",$row['clientip']);
698  $row['clientip'] = str_replace(".","\\.",$row['clientip']);
699  $row['clientip'] = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $row['clientip']);
700  if (!preg_match("/^".$row['clientip']."$/", $_SERVER["REMOTE_ADDR"]))
701  {
702  return $lng->txt("tst_user_wrong_clientip");
703  }
704  else
705  {
706  return true;
707  }
708  }
709  else
710  {
711  return true;
712  }
713  }
714  else
715  {
716  return $lng->txt("tst_user_not_invited");
717  }
718  }
719  else
720  {
721  return true;
722  }
723  }
724  else
725  {
726  return true;
727  }
728  }
729 
737  function _getParticipantData($active_id)
738  {
739  global $lng, $ilDB;
740 
741  $result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
742  array("integer"),
743  array($active_id)
744  );
745  $row = $ilDB->fetchAssoc($result);
746  $user_id = $row["user_fi"];
747  $test_id = $row["test_fi"];
748  $importname = $row['importname'];
749 
750  $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
751  array("integer"),
752  array($test_id)
753  );
754  $row = $ilDB->fetchAssoc($result);
755  $obj_id = $row["obj_fi"];
756 
757  include_once "./Modules/Test/classes/class.ilObjTest.php";
758  $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
759 
760  include_once './Services/User/classes/class.ilObjUser.php';
761  $uname = ilObjUser::_lookupName($user_id);
762 
763  $name = "";
764  if (strlen($importname))
765  {
766  $name = $importname . ' (' . $lng->txt('imported') . ')';
767  }
768  else if (strlen($uname["firstname"].$uname["lastname"]) == 0)
769  {
770  $name = $lng->txt("deleted_user");
771  }
772  else
773  {
774  if ($user_id == ANONYMOUS_USER_ID)
775  {
776  $name = $lastname;
777  }
778  else
779  {
780  $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
781  }
782  if ($is_anonymous)
783  {
784  $name = $lng->txt("anonymous");
785  }
786  }
787  return $name;
788  }
789 
796  function _getParticipantId($active_id)
797  {
798  global $lng, $ilDB;
799 
800  $result = $ilDB->queryF("SELECT user_fi FROM tst_active WHERE active_id = %s",
801  array("integer"),
802  array($active_id)
803  );
804  $row = $ilDB->fetchAssoc($result);
805  return $row["user_fi"];
806  }
807 
808 
823  function &_getPassedUsers($a_obj_id)
824  {
825  global $ilDB;
826 
827  $passed_users = array();
828  // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
829  $userresult = $ilDB->queryF("
830  SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences
831  FROM tst_tests
832  INNER JOIN tst_active
833  ON tst_active.test_fi = tst_tests.test_id
834  LEFT JOIN tst_sequence
835  ON tst_sequence.active_fi = tst_active.active_id
836  WHERE tst_tests.obj_fi = %s
837  GROUP BY tst_active.active_id
838  ",
839  array('integer'), array($a_obj_id)
840  );
841  $all_participants = array();
842  $notAttempted = array();
843  while ($row = $ilDB->fetchAssoc($userresult))
844  {
845  if($row['sequences'] == 0)
846  {
847  $notAttempted[$row['active_id']] = $row['active_id'];
848  }
849 
850  $all_participants[$row['active_id']] = $row['active_id'];
851  }
852 
853  $result = $ilDB->query("SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " . $ilDB->in('active_fi', $all_participants, false, 'integer'));
854  $found_all = ($result->numRows() == count($all_participants)) ? true : false;
855  if (!$found_all)
856  {
857  // if the result cache entries do not exist, create them
858  $found_participants = array();
859  while ($data = $ilDB->fetchAssoc($result))
860  {
861  array_push($found_participants, $data['active_fi']);
862  }
863  foreach ($all_participants as $active_id)
864  {
865  if (!in_array($active_id, $found_participants))
866  {
867  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
869  }
870  }
871  $result = $ilDB->query("SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " . $ilDB->in('active_fi', $all_participants, false, 'integer'));
872  }
873  while ($data = $ilDB->fetchAssoc($result))
874  {
875  if( isset($notAttempted[$data['active_fi']]) )
876  {
877  $data['failed'] = 0;
878  $data['passed'] = 0;
879  }
880 
881  $data['user_id'] = $data['user_fi'];
882  array_push($passed_users, $data);
883  }
884  return $passed_users;
885  }
886 
890  function _checkGoto($a_target)
891  {
892  global $ilAccess;
893 
894  $t_arr = explode("_", $a_target);
895 
896  if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0)
897  {
898  return false;
899  }
900 
901  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
902  {
903  return true;
904  }
905  return false;
906  }
907 
916  static function _isOffline($a_obj_id)
917  {
918 // global $ilUser;
919 // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
920 // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
921  return !self::_isOnline($a_obj_id);
922  }
923 
930  public static function _isOnline($a_obj_id)
931  {
932  global $ilDB;
933 
934  $query = "
935  SELECT test_id
936  FROM tst_tests
937  WHERE obj_fi = %s
938  AND online_status = 1
939  ";
940 
941  $result = $ilDB->queryF( $query, array('integer'), array($a_obj_id) );
942 
943  return $result->numRows() == 1;
944  }
945 
946  public static function visibleUserResultExists($testObjId, $userId)
947  {
948  $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
949 
950  if( !($testOBJ instanceof ilObjTest) )
951  {
952  return false;
953  }
954 
955  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
956  $testSessionFactory = new ilTestSessionFactory($testOBJ);
957  $testSession = $testSessionFactory->getSessionByUserId($userId);
958 
959  return $testOBJ->canShowTestResults($testSession);
960  }
961 }
static _lookupName($a_user_id)
lookup user name
_checkGoto($a_target)
check whether goto script will succeed
_getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
_lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$result
const IL_NO_OBJECT_ACCESS
& _getTestData($test_id)
Returns the database content of a test with a given id.
_isComplete($a_obj_id)
Returns true, if a test is complete for use.
Interface for condition handling.
static _isOffline($a_obj_id)
returns the objects&#39;s OFFline status
updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
static _isOnline($a_obj_id)
returns the objects&#39;s ONline status
_lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
static _isPassed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id passed the test with the object id $a_obj_id...
_lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
_lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
_getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
$data
static visibleUserResultExists($testObjId, $userId)
_getMaxPointsForTestPass($random, $user_id, $test_id, $pass)
Returns the maximum number of points available for a test pass.
& _getTestQuestions($active_id, $pass=NULL)
_getParticipantId($active_id)
Get user id for active id.
_getCommands()
get commands
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static isFailed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id failed the test with the object id $a_obj_id...
_getParticipantData($active_id)
Retrieves a participant name from active id.
_getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
Class ilObjTestAccess.
static getConditionOperators()
Get possible conditions operators.
global $ilUser
Definition: imgupload.php:15
Class ilObjectAccess.
global $lng
Definition: privfeed.php:40
global $ilDB
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass...
_updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
& _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.