ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4include_once "./Services/Object/classes/class.ilObjectAccess.php";
5include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
6include_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 );
421
422 return $commands;
423 }
424
425 //
426 // object specific access related methods
427 //
428
432 function _lookupCreationComplete($a_obj_id)
433 {
434 global $ilDB;
435
436 $result = $ilDB->queryF("SELECT complete FROM tst_tests WHERE obj_fi=%s",
437 array('integer'),
438 array($a_obj_id)
439 );
440 if ($result->numRows() == 1)
441 {
442 $row = $ilDB->fetchAssoc($result);
443 }
444
445 return ($row['complete']) ? true : false;
446 }
447
453 private static $hasFinishedCache = array();
454
462 public static function hasFinished($a_user_id, $a_obj_id)
463 {
464 if( !isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"]) )
465 {
466 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
467 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
468 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
469
470 global $ilDB, $lng;
471
472 $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
473
474 $partData = new ilTestParticipantData($ilDB, $lng);
475 $partData->setUserIds(array($a_user_id));
476 $partData->load($testOBJ->getTestId());
477
478 $activeId = $partData->getActiveIdByUserId($a_user_id);
479
480 $testSessionFactory = new ilTestSessionFactory($testOBJ);
481 $testSession = $testSessionFactory->getSession($activeId);
482
483 $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
484 $testPassesSelector->setActiveId($activeId);
485 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
486
487 self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
488 }
489
490 return self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
491 }
492
500 function _getTestIDFromObjectID($object_id)
501 {
502 global $ilDB;
503 $test_id = FALSE;
504 $result = $ilDB->queryF("SELECT test_id FROM tst_tests WHERE obj_fi = %s",
505 array('integer'),
506 array($object_id)
507 );
508 if ($result->numRows())
509 {
510 $row = $ilDB->fetchAssoc($result);
511 $test_id = $row["test_id"];
512 }
513 return $test_id;
514 }
515
516 function &_getTestQuestions($active_id, $pass = NULL)
517 {
518 if (is_null($pass))
519 {
520 $pass = 0;
521 }
522 $questions = array();
523
524 global $ilDB;
525 $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
526 array('integer'),
527 array($active_id)
528 );
529 $test_id = "";
530 if ($result->numRows())
531 {
532 $row = $ilDB->fetchAssoc($result);
533 $test_id = $row["test_fi"];
534 }
535 else
536 {
537 return $questions;
538 }
539 $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",
540 array('integer'),
541 array($test_id)
542 );
543 if ($result->numRows())
544 {
545 // standard test
546 while ($row = $ilDB->fetchAssoc($result))
547 {
548 array_push($questions, $row);
549 }
550 }
551 else
552 {
553 // random test
554 $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",
555 array('integer','integer'),
556 array($active_id, $pass)
557 );
558 if ($result->numRows())
559 {
560 while ($row = $ilDB->fetchAssoc($result))
561 {
562 array_push($questions, $row);
563 }
564 }
565 }
566 return $questions;
567 }
568
575 function _isComplete($a_obj_id)
576 {
577 global $ilDB;
578
579 $query = "
580 SELECT tst_tests.complete
581 FROM object_data
582 INNER JOIN tst_tests
583 ON tst_tests.obj_fi = object_data.obj_id
584 WHERE object_data.obj_id = %s
585 ";
586
587 $res = $ilDB->queryF($query, array('integer'), array($a_obj_id));
588
589 while( $row = $ilDB->fetchAssoc($res) )
590 {
591 return (bool)$row['complete'];
592 }
593
594 return false;
595 }
596
604 function &_getTestData($test_id)
605 {
606 global $ilDB;
607 $result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s",
608 array('integer'),
609 array($test_id)
610 );
611 if (!$result->numRows())
612 {
613 return 0;
614 }
615 return $ilDB->fetchAssoc($result);
616 }
617
624 function _lookupObjIdForTestId($a_test_id)
625 {
626 global $ilDB;
627
628 $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
629 array('integer'),
630 array($a_test_id)
631 );
632
633 $row = $ilDB->fetchAssoc($result);
634 return $row["obj_fi"];
635 }
636
645 {
646 global $ilDB;
647
648 $query = "
649 SELECT DISTINCT t.obj_fi
650 FROM tst_tests t
651 INNER JOIN tst_rnd_quest_set_qpls r
652 ON t.test_id = r.test_fi
653 WHERE r.pool_fi = %s
654 ";
655
656 $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
657
658 $tests = array();
659 while ($row = $ilDB->fetchAssoc($result))
660 {
661 $tests[] = $row['obj_fi'];
662 }
663
664 return $tests;
665 }
666 // fim.
667
674 function _lookupOnlineTestAccess($a_test_id, $a_user_id)
675 {
676 global $ilDB, $lng;
677
678 $result = $ilDB->queryF("SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
679 array('integer'),
680 array($a_test_id)
681 );
682 if ($result->numRows())
683 {
684 $row = $ilDB->fetchAssoc($result);
685 if ($row["fixed_participants"])
686 {
687 $result = $ilDB->queryF("SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
688 array('integer','integer'),
689 array($row["test_id"], $a_user_id)
690 );
691 if ($result->numRows())
692 {
693 $row = $ilDB->fetchAssoc($result);
694 if (trim($row['clientip']) != "")
695 {
696 $row['clientip'] = preg_replace("/[^0-9.?*,:]+/","",$row['clientip']);
697 $row['clientip'] = str_replace(".","\\.",$row['clientip']);
698 $row['clientip'] = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $row['clientip']);
699 if (!preg_match("/^".$row['clientip']."$/", $_SERVER["REMOTE_ADDR"]))
700 {
701 return $lng->txt("tst_user_wrong_clientip");
702 }
703 else
704 {
705 return true;
706 }
707 }
708 else
709 {
710 return true;
711 }
712 }
713 else
714 {
715 return $lng->txt("tst_user_not_invited");
716 }
717 }
718 else
719 {
720 return true;
721 }
722 }
723 else
724 {
725 return true;
726 }
727 }
728
736 function _getParticipantData($active_id)
737 {
738 global $lng, $ilDB;
739
740 $result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
741 array("integer"),
742 array($active_id)
743 );
744 $row = $ilDB->fetchAssoc($result);
745 $user_id = $row["user_fi"];
746 $test_id = $row["test_fi"];
747 $importname = $row['importname'];
748
749 $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
750 array("integer"),
751 array($test_id)
752 );
753 $row = $ilDB->fetchAssoc($result);
754 $obj_id = $row["obj_fi"];
755
756 include_once "./Modules/Test/classes/class.ilObjTest.php";
757 $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
758
759 include_once './Services/User/classes/class.ilObjUser.php';
760 $uname = ilObjUser::_lookupName($user_id);
761
762 $name = "";
763 if (strlen($importname))
764 {
765 $name = $importname . ' (' . $lng->txt('imported') . ')';
766 }
767 else if (strlen($uname["firstname"].$uname["lastname"]) == 0)
768 {
769 $name = $lng->txt("deleted_user");
770 }
771 else
772 {
773 if ($user_id == ANONYMOUS_USER_ID)
774 {
775 $name = $lastname;
776 }
777 else
778 {
779 $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
780 }
781 if ($is_anonymous)
782 {
783 $name = $lng->txt("anonymous");
784 }
785 }
786 return $name;
787 }
788
795 function _getParticipantId($active_id)
796 {
797 global $lng, $ilDB;
798
799 $result = $ilDB->queryF("SELECT user_fi FROM tst_active WHERE active_id = %s",
800 array("integer"),
801 array($active_id)
802 );
803 $row = $ilDB->fetchAssoc($result);
804 return $row["user_fi"];
805 }
806
807
822 function &_getPassedUsers($a_obj_id)
823 {
824 global $ilDB;
825
826 $passed_users = array();
827 // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
828 $userresult = $ilDB->queryF("
829 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences
830 FROM tst_tests
831 INNER JOIN tst_active
832 ON tst_active.test_fi = tst_tests.test_id
833 LEFT JOIN tst_sequence
834 ON tst_sequence.active_fi = tst_active.active_id
835 WHERE tst_tests.obj_fi = %s
836 GROUP BY tst_active.active_id
837 ",
838 array('integer'), array($a_obj_id)
839 );
840 $all_participants = array();
841 $notAttempted = array();
842 while ($row = $ilDB->fetchAssoc($userresult))
843 {
844 if($row['sequences'] == 0)
845 {
846 $notAttempted[$row['active_id']] = $row['active_id'];
847 }
848
849 $all_participants[$row['active_id']] = $row['active_id'];
850 }
851
852 $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'));
853 $found_all = ($result->numRows() == count($all_participants)) ? true : false;
854 if (!$found_all)
855 {
856 // if the result cache entries do not exist, create them
857 $found_participants = array();
858 while ($data = $ilDB->fetchAssoc($result))
859 {
860 array_push($found_participants, $data['active_fi']);
861 }
862 foreach ($all_participants as $active_id)
863 {
864 if (!in_array($active_id, $found_participants))
865 {
866 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
868 }
869 }
870 $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'));
871 }
872 while ($data = $ilDB->fetchAssoc($result))
873 {
874 if( isset($notAttempted[$data['active_fi']]) )
875 {
876 $data['failed'] = 0;
877 $data['passed'] = 0;
878 }
879
880 $data['user_id'] = $data['user_fi'];
881 array_push($passed_users, $data);
882 }
883 return $passed_users;
884 }
885
889 function _checkGoto($a_target)
890 {
891 global $ilAccess;
892
893 $t_arr = explode("_", $a_target);
894
895 if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0)
896 {
897 return false;
898 }
899
900 if ($ilAccess->checkAccess("read", "", $t_arr[1]))
901 {
902 return true;
903 }
904 return false;
905 }
906
915 static function _isOffline($a_obj_id)
916 {
917// global $ilUser;
918// return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
919// (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
920 return !self::_isOnline($a_obj_id);
921 }
922
929 public static function _isOnline($a_obj_id)
930 {
931 global $ilDB;
932
933 $query = "
934 SELECT test_id
935 FROM tst_tests
936 WHERE obj_fi = %s
937 AND online_status = 1
938 ";
939
940 $result = $ilDB->queryF( $query, array('integer'), array($a_obj_id) );
941
942 return $result->numRows() == 1;
943 }
944}
945
946?>
$result
_getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
const IL_NO_OBJECT_ACCESS
_updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
Class ilObjTestAccess.
_lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass.
_lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
_getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
_getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static getConditionOperators()
Get possible conditions operators.
& _getTestQuestions($active_id, $pass=NULL)
_checkGoto($a_target)
check whether goto script will succeed
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
_getParticipantId($active_id)
Get user id for active id.
static _isOffline($a_obj_id)
returns the objects's OFFline status
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.
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.
_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...
_getCommands()
get commands
_lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
_getParticipantData($active_id)
Retrieves a participant name from active id.
static _isOnline($a_obj_id)
returns the objects's ONline status
_isComplete($a_obj_id)
Returns true, if a test is complete for use.
& _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
_getMaxPointsForTestPass($random, $user_id, $test_id, $pass)
Returns the maximum number of points available for a test pass.
& _getTestData($test_id)
Returns the database content of a test with a given id.
_lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupName($a_user_id)
lookup user name
Class ilObjectAccess.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Interface for condition handling.
global $lng
Definition: privfeed.php:40
global $ilDB
global $ilUser
Definition: imgupload.php:15