ILIAS  release_8 Revision v8.24
class.ilObjQuestionPoolAccess.php
Go to the documentation of this file.
1<?php
2
19include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
20
31{
44 public static function _getCommands(): array
45 {
46 $commands = array(
47 array("permission" => "write", "cmd" => "questions", "lang_var" => "tst_edit_questions"),
48 array("permission" => "write", "cmd" => "ilObjQuestionPoolSettingsGeneralGUI::showForm", "lang_var" => "settings"),
49 #array("permission" => "write", "cmd" => "questions", "lang_var" => "edit",
50 # "default" => false),
51 array("permission" => "read", "cmd" => "questions", "lang_var" => "edit",
52 "default" => true)
53 );
54
55 return $commands;
56 }
57
58 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
59 {
60 global $DIC;
61 $ilUser = $DIC['ilUser'];
62 $lng = $DIC['lng'];
63 $rbacsystem = $DIC['rbacsystem'];
64 $ilAccess = $DIC['ilAccess'];
65
66 if (is_null($user_id)) {
67 $user_id = $ilUser->getId();
68 }
69
70 if ($rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
71 return true;
72 }
73
74 switch ($permission) {
75 case 'visible':
76 case 'read':
77 if (!self::isOnline($obj_id)) {
78 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_pool_offline"));
79 return false;
80 }
81 break;
82 }
83
84 return true;
85 }
86
93 public static function isOnline($a_obj_id): bool
94 {
95 global $DIC;
96 $ilDB = $DIC['ilDB'];
97
98 $query = "
99 SELECT COUNT(id_questionpool) cnt
100 FROM qpl_questionpool
101 WHERE obj_fi = %s
102 AND isonline = 1
103 ";
104
105 $res = $ilDB->queryF($query, array('integer'), array($a_obj_id));
106 $row = $ilDB->fetchAssoc($res);
107
108 return $row['cnt'] > 0;
109 }
110}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
static isOnline($a_obj_id)
returns the objects's ONline status
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
$res
Definition: ltiservices.php:69
$query
$lng