ILIAS  release_7 Revision v7.30-3-g800a261c036
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
11
12include_once "./Services/Object/classes/class.ilObjectAccess.php";
13include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
14include_once './Services/Conditions/interfaces/interface.ilConditionHandling.php';
15
29{
30 public function canBeDelivered(ilWACPath $ilWACPath)
31 {
32 global $DIC;
33 $readable = new Readable($DIC);
34
35 $can_it = $this->findMatch($ilWACPath->getPath(), [
36 new AccessFileUploadAnswer($DIC, $readable),
37 new AccessQuestionImage($readable),
38 new AccessFileUploadPreview($DIC->database(), $DIC->access()),
39 ]);
40
41 return !$can_it->isOk() || $can_it->value();
42 }
43
44 private function findMatch(string $path, array $array): Result
45 {
46 return array_reduce($array, static function (Result $result, SimpleAccess $access) use ($path): Result {
47 return $result->except(static function () use ($access, $path): Result {
48 return $access->isPermitted($path);
49 });
50 }, new Error('Not a known path.'));
51 }
52
68 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
69 {
70 global $DIC;
71 $ilUser = $DIC['ilUser'];
72 $lng = $DIC['lng'];
73 $rbacsystem = $DIC['rbacsystem'];
74 $ilAccess = $DIC['ilAccess'];
75
76 if ($a_user_id == "") {
77 $a_user_id = $ilUser->getId();
78 }
79
80 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
81
82
83 switch ($a_permission) {
84 case "visible":
85 case "read":
87 !$is_admin) {
88 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
89 return false;
90 }
91 break;
92 }
93
94 switch ($a_cmd) {
95 case "eval_a":
96 case "eval_stat":
98 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
99 return false;
100 }
101 break;
102
103 }
104
105 return true;
106 }
107
115 public static function _isPassed($user_id, $a_obj_id)
116 {
117 global $DIC;
118 $ilDB = $DIC['ilDB'];
119 $result = $ilDB->queryF(
120 "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",
121 array('integer','integer'),
122 array($user_id, $a_obj_id)
123 );
124 if (!$result->numRows()) {
125 $result = $ilDB->queryF(
126 "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",
127 array('integer','integer'),
128 array($user_id, $a_obj_id)
129 );
130 $row = $ilDB->fetchAssoc($result);
131 if ($row['active_id'] > 0) {
132 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
133 assQuestion::_updateTestResultCache($row['active_id']);
134 } else {
135 return false;
136 }
137 }
138 $result = $ilDB->queryF(
139 "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",
140 array('integer','integer'),
141 array($user_id, $a_obj_id)
142 );
143 if (!$result->numRows()) {
144 $result = $ilDB->queryF(
145 "SELECT tst_pass_result.*, tst_tests.pass_scoring, 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",
146 array('integer','integer'),
147 array($user_id, $a_obj_id)
148 );
149
150 if (!$result->numRows()) {
151 return false;
152 }
153
154 $points = array();
155 while ($row = $ilDB->fetchAssoc($result)) {
156 array_push($points, $row);
157 }
158 $reached = 0;
159 $max = 0;
160 if ($points[0]["pass_scoring"] == 0) {
161 $reached = $points[count($points) - 1]["points"];
162 $max = $points[count($points) - 1]["maxpoints"];
163 if (!$max) {
164 $active_id = $points[count($points) - 1]["active_fi"];
165 $pass = $points[count($points) - 1]["pass"];
166 if (strlen($active_id) && strlen($pass)) {
167 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
168 $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
169 $max = $res['maxpoints'];
170 $reached = $res['points'];
171 }
172 }
173 } else {
174 foreach ($points as $row) {
175 if ($row["points"] > $reached) {
176 $reached = $row["points"];
177 $max = $row["maxpoints"];
178 if (!$max) {
179 $active_id = $row["active_fi"];
180 $pass = $row["pass"];
181 if (strlen($active_id) && strlen($pass)) {
182 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
183 $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
184 $max = $res['maxpoints'];
185 $reached = $res['points'];
186 }
187 }
188 }
189 }
190 }
191 include_once "./Modules/Test/classes/class.assMarkSchema.php";
192 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
193 $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
194 return ($mark["passed"]) ? true : false;
195 } else {
196 $row = $ilDB->fetchAssoc($result);
197 return ($row['passed']) ? true : false;
198 }
199 }
200
208 public static function isFailed($user_id, $a_obj_id)
209 {
210 global $DIC;
211 $ilDB = $DIC['ilDB'];
212
213 $ret = self::updateTestResultCache($user_id, $a_obj_id);
214
215 if (!$ret) {
216 return false;
217 }
218
219 $result = $ilDB->queryF(
220 "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",
221 array('integer','integer'),
222 array($user_id, $a_obj_id)
223 );
224
225 if (!$result->numRows()) {
226 $result = $ilDB->queryF(
227 "SELECT tst_pass_result.*, tst_tests.pass_scoring 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",
228 array('integer','integer'),
229 array($user_id, $a_obj_id)
230 );
231
232 while ($row = $ilDB->fetchAssoc($result)) {
233 array_push($points, $row);
234 }
235 $reached = 0;
236 $max = 0;
237 if ($points[0]["pass_scoring"] == 0) {
238 $reached = $points[count($points) - 1]["points"];
239 $max = $points[count($points) - 1]["maxpoints"];
240 if (!$max) {
241 $active_id = $points[count($points) - 1]["active_fi"];
242 $pass = $points[count($points) - 1]["pass"];
243 if (strlen($active_id) && strlen($pass)) {
244 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
245 $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
246 $max = $res['maxpoints'];
247 $reached = $res['points'];
248 }
249 }
250 } else {
251 foreach ($points as $row) {
252 if ($row["points"] > $reached) {
253 $reached = $row["points"];
254 $max = $row["maxpoints"];
255 if (!$max) {
256 $active_id = $row["active_fi"];
257 $pass = $row["pass"];
258 if (strlen($active_id) && strlen($pass)) {
259 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
260 $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
261 $max = $res['maxpoints'];
262 $reached = $res['points'];
263 }
264 }
265 }
266 }
267 }
268 include_once "./Modules/Test/classes/class.assMarkSchema.php";
269 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
270 $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
271 return ($mark["failed"]) ? true : false;
272 } else {
273 $row = $ilDB->fetchAssoc($result);
274 return ($row['failed']) ? true : false;
275 }
276 }
277
283 protected static function updateTestResultCache($a_user_id, $a_obj_id)
284 {
285 global $DIC;
286 $ilDB = $DIC['ilDB'];
287
288 $result = $ilDB->queryF(
289 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
290 "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
291 "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
292 array('integer','integer'),
293 array($a_user_id, $a_obj_id)
294 );
295 if (!$result->numRows()) {
296 $result = $ilDB->queryF(
297 "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",
298 array('integer','integer'),
299 array($a_user_id, $a_obj_id)
300 );
301 $row = $ilDB->fetchAssoc($result);
302 if ($row['active_id'] > 0) {
303 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
304 assQuestion::_updateTestResultCache($row['active_id']);
305 return true;
306 } else {
307 return false;
308 }
309 } else {
310 return true;
311 }
312 }
313
314
318 public static function getConditionOperators()
319 {
320 include_once './Services/Conditions/classes/class.ilConditionHandler.php';
321 return array(
326 );
327 }
328
329
335 public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
336 {
337 include_once './Services/Conditions/classes/class.ilConditionHandler.php';
338
339 switch ($a_operator) {
341 return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
342 break;
343
345 return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
346
348 return ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
349
351 return !ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
352
353 default:
354 return true;
355 }
356 return true;
357 }
358
371 public static function _getCommands()
372 {
373 global $DIC;
374 $DIC->language()->loadLanguageModule('assessment');
375
376 $commands = array(
377 array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
378 array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "lang_var" => "settings"),
379 array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
380 "default" => true),
381 //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
382 array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
383 array("permission" => "read", "cmd" => "userResultsGateway", "lang_var" => "tst_user_results"),
384 array("permission" => "write", "cmd" => "testResultsGateway", "lang_var" => "results"),
385 array("permission" => "eval_a", "cmd" => "testResultsGateway", "lang_var" => "results")
386 );
387
388 return $commands;
389 }
390
391 //
392 // object specific access related methods
393 //
394
398 public static function _lookupCreationComplete($a_obj_id)
399 {
400 global $DIC;
401 $ilDB = $DIC['ilDB'];
402
403 $result = $ilDB->queryF(
404 "SELECT complete FROM tst_tests WHERE obj_fi=%s",
405 array('integer'),
406 array($a_obj_id)
407 );
408 if ($result->numRows() == 1) {
409 $row = $ilDB->fetchAssoc($result);
410 }
411
412 return ($row['complete']) ? true : false;
413 }
414
420 private static $hasFinishedCache = array();
421
429 public static function hasFinished($a_user_id, $a_obj_id)
430 {
431 if (!isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"])) {
432 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
433 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
434 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
435
436 global $DIC;
437 $ilDB = $DIC['ilDB'];
438 $lng = $DIC['lng'];
439
440 $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
441
442 $partData = new ilTestParticipantData($ilDB, $lng);
443 $partData->setUserIdsFilter(array($a_user_id));
444 $partData->load($testOBJ->getTestId());
445
446 $activeId = $partData->getActiveIdByUserId($a_user_id);
447
448 $testSessionFactory = new ilTestSessionFactory($testOBJ);
449 $testSession = $testSessionFactory->getSession($activeId);
450
451 $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
452 $testPassesSelector->setActiveId($activeId);
453 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
454
455 self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
456 }
457
458 return (bool) self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
459 }
460
468 public static function _getTestIDFromObjectID($object_id)
469 {
470 global $DIC;
471 $ilDB = $DIC['ilDB'];
472 $test_id = false;
473 $result = $ilDB->queryF(
474 "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
475 array('integer'),
476 array($object_id)
477 );
478 if ($result->numRows()) {
479 $row = $ilDB->fetchAssoc($result);
480 $test_id = $row["test_id"];
481 }
482 return $test_id;
483 }
484
491 public static function _lookupObjIdForTestId($a_test_id)
492 {
493 global $DIC;
494 $ilDB = $DIC['ilDB'];
495
496 $result = $ilDB->queryF(
497 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
498 array('integer'),
499 array($a_test_id)
500 );
501
502 $row = $ilDB->fetchAssoc($result);
503 return $row["obj_fi"];
504 }
505
513 public static function _getRandomTestsForQuestionPool($qpl_id)
514 {
515 global $DIC;
516 $ilDB = $DIC['ilDB'];
517
518 $query = "
519 SELECT DISTINCT t.obj_fi
520 FROM tst_tests t
521 INNER JOIN tst_rnd_quest_set_qpls r
522 ON t.test_id = r.test_fi
523 WHERE r.pool_fi = %s
524 ";
525
526 $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
527
528 $tests = array();
529 while ($row = $ilDB->fetchAssoc($result)) {
530 $tests[] = $row['obj_fi'];
531 }
532
533 return $tests;
534 }
535 // fim.
536
543 public static function _lookupOnlineTestAccess($a_test_id, $a_user_id)
544 {
545 global $DIC;
546 $ilDB = $DIC['ilDB'];
547 $lng = $DIC['lng'];
548
549 $result = $ilDB->queryF(
550 "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
551 array('integer'),
552 array($a_test_id)
553 );
554 if ($result->numRows()) {
555 $row = $ilDB->fetchAssoc($result);
556 if ($row["fixed_participants"]) {
557 $result = $ilDB->queryF(
558 "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
559 array('integer','integer'),
560 array($row["test_id"], $a_user_id)
561 );
562 if ($result->numRows()) {
563 $row = $ilDB->fetchAssoc($result);
564 if (trim($row['clientip']) != "") {
565 $row['clientip'] = preg_replace("/[^0-9.?*,:]+/", "", $row['clientip']);
566 $row['clientip'] = str_replace(".", "\\.", $row['clientip']);
567 $row['clientip'] = str_replace(array("?","*",","), array("[0-9]","[0-9]*","|"), $row['clientip']);
568 if (!preg_match("/^" . $row['clientip'] . "$/", $_SERVER["REMOTE_ADDR"])) {
569 $lng->loadLanguageModule('assessment');
570 return $lng->txt("user_wrong_clientip");
571 } else {
572 return true;
573 }
574 } else {
575 return true;
576 }
577 } else {
578 return $lng->txt("tst_user_not_invited");
579 }
580 } else {
581 return true;
582 }
583 } else {
584 return true;
585 }
586 }
587
595 public static function _getParticipantData($active_id)
596 {
597 global $DIC;
598 $lng = $DIC['lng'];
599 $ilDB = $DIC['ilDB'];
600
601 $result = $ilDB->queryF(
602 "SELECT * FROM tst_active WHERE active_id = %s",
603 array("integer"),
604 array($active_id)
605 );
606 $row = $ilDB->fetchAssoc($result);
607 $user_id = $row["user_fi"];
608 $test_id = $row["test_fi"];
609 $importname = $row['importname'];
610
611 $result = $ilDB->queryF(
612 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
613 array("integer"),
614 array($test_id)
615 );
616 $row = $ilDB->fetchAssoc($result);
617 $obj_id = $row["obj_fi"];
618
619 include_once "./Modules/Test/classes/class.ilObjTest.php";
620 $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
621
622 include_once './Services/User/classes/class.ilObjUser.php';
623 $uname = ilObjUser::_lookupName($user_id);
624
625 $name = "";
626 if (strlen($importname)) {
627 $name = $importname . ' (' . $lng->txt('imported') . ')';
628 } elseif (strlen($uname["firstname"] . $uname["lastname"]) == 0) {
629 $name = $lng->txt("deleted_user");
630 } else {
631 if ($user_id == ANONYMOUS_USER_ID) {
632 $name = $lastname;
633 } else {
634 $name = trim($uname["lastname"] . ", " . $uname["firstname"]);
635 }
636 if ($is_anonymous) {
637 $name = $lng->txt("anonymous");
638 }
639 }
640 return $name;
641 }
642
649 public static function _getParticipantId($active_id)
650 {
651 global $DIC;
652 $lng = $DIC['lng'];
653 $ilDB = $DIC['ilDB'];
654
655 $result = $ilDB->queryF(
656 "SELECT user_fi FROM tst_active WHERE active_id = %s",
657 array("integer"),
658 array($active_id)
659 );
660 $row = $ilDB->fetchAssoc($result);
661 return $row["user_fi"];
662 }
663
664
679 public static function _getPassedUsers($a_obj_id)
680 {
681 global $DIC;
682 $ilDB = $DIC['ilDB'];
683
684 $passed_users = array();
685 // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
686 $userresult = $ilDB->queryF(
687 "
688 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass,
689 CASE WHEN
690 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
691 THEN '1'
692 ELSE '0'
693 END is_last_pass
694 FROM tst_tests
695 INNER JOIN tst_active
696 ON tst_active.test_fi = tst_tests.test_id
697 LEFT JOIN tst_sequence
698 ON tst_sequence.active_fi = tst_active.active_id
699 WHERE tst_tests.obj_fi = %s
700 GROUP BY tst_active.active_id
701 ",
702 array('integer'),
703 array($a_obj_id)
704 );
705 $all_participants = array();
706 $notAttempted = array();
707 $lastPassUsers = array();
708 while ($row = $ilDB->fetchAssoc($userresult)) {
709 if ($row['sequences'] == 0) {
710 $notAttempted[$row['active_id']] = $row['active_id'];
711 }
712 if ($row['is_last_pass']) {
713 $lastPassUsers[$row['active_id']] = $row['active_id'];
714 }
715
716 $all_participants[$row['active_id']] = $row['active_id'];
717 }
718
719 $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'));
720 $found_all = ($result->numRows() == count($all_participants)) ? true : false;
721 if (!$found_all) {
722 // if the result cache entries do not exist, create them
723 $found_participants = array();
724 while ($data = $ilDB->fetchAssoc($result)) {
725 array_push($found_participants, $data['active_fi']);
726 }
727 foreach ($all_participants as $active_id) {
728 if (!in_array($active_id, $found_participants)) {
729 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
731 }
732 }
733 $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'));
734 }
735 while ($data = $ilDB->fetchAssoc($result)) {
736 if (isset($notAttempted[$data['active_fi']])) {
737 $data['failed'] = 0;
738 $data['passed'] = 0;
739 $data['not_attempted'] = 1;
740 }
741
742 if ($data['failed'] && !isset($lastPassUsers[$data['active_fi']])) {
743 $data['passed'] = 0;
744 $data['failed'] = 0;
745 $data['in_progress'] = 1;
746 }
747
748 $data['user_id'] = $data['user_fi'];
749 array_push($passed_users, $data);
750 }
751 return $passed_users;
752 }
753
757 public static function _checkGoto($a_target)
758 {
759 global $DIC;
760 $ilAccess = $DIC['ilAccess'];
761
762 $t_arr = explode("_", $a_target);
763
764 if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0) {
765 return false;
766 }
767
768 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
769 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
770 return true;
771 }
772 return false;
773 }
774
783 public static function _isOffline($a_obj_id)
784 {
785 // global $DIC;
786 // $ilUser = $DIC['ilUser'];
787 // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
788 // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
789 return ilObject::lookupOfflineStatus($a_obj_id);
790 }
791
792
793 public static function visibleUserResultExists($testObjId, $userId)
794 {
795 $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
796
797 if (!($testOBJ instanceof ilObjTest)) {
798 return false;
799 }
800
801 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
802 $testSessionFactory = new ilTestSessionFactory($testOBJ);
803 $testSession = $testSessionFactory->getSessionByUserId($userId);
804
805 return $testOBJ->canShowTestResults($testSession);
806 }
807
815 public static function hasVisibleCertificate($testObjId, $userId)
816 {
817 $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
818
819 if (!($testOBJ instanceof ilObjTest) || !$userId) {
820 return false;
821 }
822
823 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
824 $testSessionFactory = new ilTestSessionFactory($testOBJ);
825 $testSession = $testSessionFactory->getSessionByUserId($userId);
826
827 if (!$testSession->getActiveId()) {
828 return false;
829 }
830
831 return $testOBJ->canShowCertificate($testSession, $testSession->getUserId(), $testSession->getActiveId());
832 }
833}
$result
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
An exception for terminatinating execution or to throw for unit testing.
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Error.php:14
const IL_NO_OBJECT_ACCESS
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
Class ilObjTestAccess.
canBeDelivered(ilWACPath $ilWACPath)
bool
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass.
findMatch(string $path, array $array)
static getConditionOperators()
Get possible conditions operators.
static hasVisibleCertificate($testObjId, $userId)
@ideaof Andre Michels amichels@databay.de
static _getParticipantData($active_id)
Retrieves a participant name from active id.
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
static _getParticipantId($active_id)
Get user id for active id.
static _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
static _isOffline($a_obj_id)
returns the objects's OFFline status
static _getCommands()
get commands
static _checkGoto($a_target)
check whether goto script will succeed
static updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
static _lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
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 visibleUserResultExists($testObjId, $userId)
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...
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
static _getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static _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.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
Class ilWACPath.
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:12
Interface for condition handling.
if($format !==null) $name
Definition: metadata.php:230
$ret
Definition: parser.php:6
$query
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$lng
foreach($_POST as $key=> $value) $res
global $ilDB
$data
Definition: storeScorm.php:23