ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjTestListGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16include_once "Services/Object/classes/class.ilObjectListGUI.php";
17include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
18
20{
21 protected $command_link_params = array();
22
27 public function __construct($a_context = self::CONTEXT_REPOSITORY)
28 {
29 parent::__construct($a_context);
30 $this->info_screen_enabled = true;
31 }
32
36 public function init()
37 {
38 $this->static_link_enabled = true;
39 $this->delete_enabled = true;
40 $this->cut_enabled = true;
41 $this->copy_enabled = true;
42 $this->subscribe_enabled = true;
43 $this->link_enabled = true;
44 $this->type = "tst";
45 $this->gui_class_name = "ilobjtestgui";
46
47 // general commands array
48 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
49 $this->commands = ilObjTestAccess::_getCommands();
50 }
51
52
61 public function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
62 {
63 parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
64 }
65
66
74 public function getCommandFrame($a_cmd)
75 {
76 switch ($a_cmd) {
77 case "":
78 case "infoScreen":
79 case "eval_a":
80 case "eval_stat":
81 include_once "./Services/UICore/classes/class.ilFrameTargetInfo.php";
82 $frame = ilFrameTargetInfo::_getFrame("MainContent");
83 break;
84
85 default:
86 }
87
88 return $frame;
89 }
90
91
92
101 public function getProperties()
102 {
103 global $DIC;
104 $lng = $DIC['lng'];
105 $ilUser = $DIC['ilUser'];
106
107 $props = parent::getProperties();
108
109 // we cannot use ilObjTestAccess::_isOffline() because of text messages
110 $onlineaccess = ilObjTestAccess::_lookupOnlineTestAccess($this->obj_id, $ilUser->id);
111 if ($onlineaccess !== true) {
112 $props[] = array("alert" => true, "property" => $lng->txt("status"),
113 "value" => $onlineaccess);
114 }
115
116 return $props;
117 }
118
119
127 public function getCommandLink($a_cmd)
128 {
129 global $DIC;
130 $ilCtrl = $DIC['ilCtrl'];
131
132 $a_cmd = explode('::', $a_cmd);
133
134 if (count($a_cmd) == 2) {
135 $cmd_link = $ilCtrl->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjTestGUI', $a_cmd[0]), $a_cmd[1]);
136 } else {
137 $cmd_link = $ilCtrl->getLinkTargetByClass('ilObjTestGUI', $a_cmd[0]);
138 }
139
140 $params = array_merge(array('ref_id' => $this->ref_id), $this->command_link_params);
141
142 foreach ($params as $param => $value) {
143 $cmd_link = ilUtil::appendUrlParameterString($cmd_link, "$param=$value", true);
144 }
145
146 return $cmd_link;
147 }
148
149 public function getCommands()
150 {
151 $commands = parent::getCommands();
152
153 $commands = $this->handleUserResultsCommand($commands);
154
155 return $commands;
156 }
157
158 private function handleUserResultsCommand($commands)
159 {
160 global $DIC;
161 $ilUser = $DIC['ilUser'];
162
163 if (!$this->isObjectiveTest()) {
164 $commands = $this->removeUserResultsCommand($commands);
165 } else {
166 require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
167
168 if (!ilObjTestAccess::visibleUserResultExists($this->obj_id, $ilUser->getId())) {
169 $commands = $this->removeUserResultsCommand($commands);
170 }
171 }
172
173 return $commands;
174 }
175
176 private function isObjectiveTest()
177 {
178 require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
179 return ilLOSettings::isObjectiveTest($this->ref_id);
180 }
181
182 private function removeUserResultsCommand($commands)
183 {
184 foreach ($commands as $key => $command) {
185 if ($command['cmd'] == 'userResultsGateway') {
186 unset($commands[$key]);
187 break;
188 }
189 }
190
191 return $commands;
192 }
193
201 public function createDefaultCommand($a_command)
202 {
203 return $a_command;
204 }
205
206
214 public function addCommandLinkParameter($a_param)
215 {
216 $this->command_link_params = $a_param;
217 }
218
219 // begin-patch lok
220 protected function modifyTitleLink($a_default_link)
221 {
222 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
223 $id = ilLOSettings::isObjectiveTest($this->ref_id);
224
225 $cmd_link = $a_default_link;
226
227 if ($id) {
229 $ref_id = end($ref_ids);
230
231 $this->ctrl->setParameterByClass("ilrepositorygui", 'ref_id', $ref_id);
232 $this->ctrl->setParameterByClass("ilrepositorygui", 'tid', $this->ref_id);
233 $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", 'redirectLocToTest');
234 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
235 $this->ctrl->clearParametersByClass('ilrepositorygui');
236 }
237 return parent::modifyTitleLink($cmd_link);
238 }
239 // end-patch lok
240} // END class.ilObjTestListGUI
An exception for terminatinating execution or to throw for unit testing.
static _getFrame($a_class, $a_type='')
Get content frame name.
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
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)
Class ilObjTestListGUI.
addCommandLinkParameter($a_param)
add command link parameters
__construct($a_context=self::CONTEXT_REPOSITORY)
constructor
getCommandFrame($a_cmd)
Get command target frame.
getProperties()
Get item properties.
modifyTitleLink($a_default_link)
getCommandLink($a_cmd)
Get command link url.
initItem($a_ref_id, $a_obj_id, $a_title="", $a_description="")
inititialize new item
createDefaultCommand($a_command)
overwritten from base class for course objectives
getCommands()
get all current commands for a specific ref id (in the permission context of the current user)
Class ilObjectListGUI.
static _getAllReferences($a_id)
get all reference ids of object
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
$key
Definition: croninfo.php:18
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18