ILIAS  release_8 Revision v8.24
class.ilObjTestListGUI.php
Go to the documentation of this file.
1<?php
2
29include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
30
32{
33 protected $command_link_params = array();
34
39 public function __construct($a_context = self::CONTEXT_REPOSITORY)
40 {
41 parent::__construct($a_context);
42 $this->info_screen_enabled = true;
43 }
44
48 public function init(): void
49 {
50 $this->static_link_enabled = true;
51 $this->delete_enabled = true;
52 $this->cut_enabled = true;
53 $this->copy_enabled = true;
54 $this->subscribe_enabled = true;
55 $this->link_enabled = true;
56 $this->type = "tst";
57 $this->gui_class_name = "ilobjtestgui";
58
59 // general commands array
60 $this->commands = ilObjTestAccess::_getCommands();
61 }
62
63
64
72 public function getCommandFrame(string $cmd): string
73 {
74 $frame = '';
75 switch ($cmd) {
76 case "":
77 case "infoScreen":
78 case "eval_a":
79 case "eval_stat":
80 $frame = ilFrameTargetInfo::_getFrame("MainContent");
81 break;
82
83 default:
84 }
85
86 return $frame;
87 }
88
89
90
99 public function getProperties(): array
100 {
101 global $DIC;
102 $lng = $DIC['lng'];
103 $ilUser = $DIC['ilUser'];
104
105 $props = parent::getProperties();
106
107 // we cannot use ilObjTestAccess::_isOffline() because of text messages
108 $onlineaccess = ilObjTestAccess::_lookupOnlineTestAccess($this->obj_id, $ilUser->getId());
109 if ($onlineaccess !== true) {
110 $props[] = array("alert" => true, "property" => $lng->txt("status"),
111 "value" => $onlineaccess);
112 }
113
114 return $props;
115 }
116
117
121 public function getCommandLink(string $cmd): string
122 {
123 global $DIC;
124 $ilCtrl = $DIC['ilCtrl'];
125
126 $cmd = explode('::', $cmd);
127
128 if (count($cmd) == 2) {
129 $cmd_link = $ilCtrl->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjTestGUI', $cmd[0]), $cmd[1]);
130 } else {
131 $cmd_link = $ilCtrl->getLinkTargetByClass('ilObjTestGUI', $cmd[0]);
132 }
133
134 $params = array_merge(array('ref_id' => $this->ref_id), $this->command_link_params);
135
136 foreach ($params as $param => $value) {
137 $cmd_link = ilUtil::appendUrlParameterString($cmd_link, "$param=$value", true);
138 }
139
140 return $cmd_link;
141 }
142
143 public function getCommands(): array
144 {
145 $commands = parent::getCommands();
146
148
149 return $commands;
150 }
151
153 {
154 global $DIC;
155 $ilUser = $DIC['ilUser'];
156
157 if (!ilLOSettings::isObjectiveTest($this->ref_id)) {
159 } else {
160 if (!ilObjTestAccess::visibleUserResultExists($this->obj_id, $ilUser->getId())) {
162 }
163 }
164
165 return $commands;
166 }
167
169 {
170 foreach ($commands as $key => $command) {
171 if ($command['cmd'] == 'userResultsGateway') {
172 unset($commands[$key]);
173 break;
174 }
175 }
176
177 return $commands;
178 }
179
187 public function createDefaultCommand(array $command): array
188 {
189 return $command;
190 }
191
192
199 public function addCommandLinkParameter($a_param)
200 {
201 $this->command_link_params = $a_param;
202 }
203
204 // begin-patch lok
205 protected function modifyTitleLink(string $default_link): string
206 {
207 if (!ilLOSettings::isObjectiveTest($this->ref_id)) {
208 return parent::modifyTitleLink($default_link);
209 }
210
211 $path = $this->tree->getPathFull($this->ref_id);
212
213 while ($parent = array_pop($path)) {
214 if ($parent['type'] === 'crs') {
215 $parent_crs_ref_id = $parent['ref_id'];
216 break;
217 }
218 }
219
220 $this->ctrl->setParameterByClass("ilrepositorygui", 'ref_id', $parent_crs_ref_id);
221 $this->ctrl->setParameterByClass("ilrepositorygui", 'tid', $this->ref_id);
222 $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", 'redirectLocToTest');
223 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
224 $this->ctrl->clearParametersByClass('ilrepositorygui');
225
226 return parent::modifyTitleLink($cmd_link);
227 }
228
229 // end-patch lok
230} // END class.ilObjTestListGUI
static _getFrame(string $a_class)
static isObjectiveTest(int $a_trst_ref_id)
Check if test ref_id is used in an objective course.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static _getCommands()
get commands
static visibleUserResultExists($testObjId, $userId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandLinkParameter($a_param)
add command link parameters
__construct($a_context=self::CONTEXT_REPOSITORY)
constructor
getProperties()
Get item properties.
getCommandLink(string $cmd)
Get command link url.
getCommandFrame(string $cmd)
Get command target frame.
createDefaultCommand(array $command)
overwritten from base class for course objectives
modifyTitleLink(string $default_link)
getCommands()
get all current commands for a specific ref id (in the permission context of the current user)
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
$param
Definition: xapitoken.php:46