ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
28 {
29 $this->ilObjectListGUI();
30 $this->info_screen_enabled = true;
31 }
32
36 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->payment_enabled = true;
45 $this->type = "tst";
46 $this->gui_class_name = "ilobjtestgui";
47
48 // general commands array
49 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
50 $this->commands = ilObjTestAccess::_getCommands();
51 }
52
53
62 function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
63 {
64 parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
65 }
66
67
75 function getCommandFrame($a_cmd)
76 {
77 switch($a_cmd)
78 {
79 case "":
80 case "infoScreen":
81 case "eval_a":
82 case "eval_stat":
83 include_once "./Services/UICore/classes/class.ilFrameTargetInfo.php";
84 $frame = ilFrameTargetInfo::_getFrame("MainContent");
85 break;
86
87 default:
88 }
89
90 return $frame;
91 }
92
93
94
103 function getProperties()
104 {
105 global $lng, $ilUser;
106
107 $props = array();
108 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
109
110 if (!ilObjTestAccess::_isOnline($this->obj_id))
111 {
112 $props[] = array("alert" => true, "property" => $lng->txt("status"),
113 "value" => $lng->txt("offline"));
114 }
115
116
117 // we cannot use ilObjTestAccess::_isOffline() because of text messages
118 $onlineaccess = ilObjTestAccess::_lookupOnlineTestAccess($this->obj_id, $ilUser->id);
119 if ($onlineaccess !== true)
120 {
121 $props[] = array("alert" => true, "property" => $lng->txt("status"),
122 "value" => $onlineaccess);
123 }
124
125 return $props;
126 }
127
128
136 function getCommandLink($a_cmd)
137 {
138 global $ilCtrl;
139
140 $a_cmd = explode('::', $a_cmd);
141
142 if( count($a_cmd) == 2 )
143 {
144 $cmd_link = $ilCtrl->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjTestGUI', $a_cmd[0]), $a_cmd[1]);
145 }
146 else
147 {
148 $cmd_link = $ilCtrl->getLinkTargetByClass('ilObjTestGUI', $a_cmd[0]);
149 }
150
151 $params = array_merge(array('ref_id' => $this->ref_id), $this->command_link_params);
152
153 foreach($params as $param => $value)
154 {
155 $cmd_link = ilUtil::appendUrlParameterString($cmd_link, "$param=$value", true);
156 }
157
158 return $cmd_link;
159 }
160
161 public function getCommands()
162 {
163 $commands = parent::getCommands();
164
165 $commands = $this->handleUserResultsCommand($commands);
166
167 return $commands;
168 }
169
170 private function handleUserResultsCommand($commands)
171 {
172 global $ilUser;
173
174 if( !$this->isObjectiveTest() )
175 {
176 $commands = $this->removeUserResultsCommand($commands);
177 }
178 else
179 {
180 require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
181
182 if( !ilObjTestAccess::visibleUserResultExists($this->obj_id, $ilUser->getId()) )
183 {
184 $commands = $this->removeUserResultsCommand($commands);
185 }
186 }
187
188 return $commands;
189 }
190
191 private function isObjectiveTest()
192 {
193 require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
194 return ilLOSettings::isObjectiveTest($this->ref_id);
195 }
196
197 private function removeUserResultsCommand($commands)
198 {
199 foreach($commands as $key => $command)
200 {
201 if($command['cmd'] == 'userResultsGateway')
202 {
203 unset($commands[$key]);
204 break;
205 }
206 }
207
208 return $commands;
209 }
210
218 public function createDefaultCommand($a_command)
219 {
220 return $a_command;
221 }
222
223
231 public function addCommandLinkParameter($a_param)
232 {
233 $this->command_link_params = $a_param;
234 }
235
236 // begin-patch lok
237 protected function modifyTitleLink($a_default_link)
238 {
239 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
240 $id = ilLOSettings::isObjectiveTest($this->ref_id);
241
242 $cmd_link = $a_default_link;
243
244 if($id)
245 {
246 $ref_ids = ilObject::_getAllReferences($id);
247 $ref_id = end($ref_ids);
248
249 $this->ctrl->setParameterByClass("ilrepositorygui", 'ref_id', $ref_id);
250 $this->ctrl->setParameterByClass("ilrepositorygui", 'tid', $this->ref_id);
251 $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", 'redirectLocToTest');
252 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
253 $this->ctrl->clearParametersByClass('ilrepositorygui');
254 }
255 return parent::modifyTitleLink($cmd_link);
256 }
257 // end-patch lok
258
259} // END class.ilObjTestListGUI
260?>
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.
_lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static visibleUserResultExists($testObjId, $userId)
_getCommands()
get commands
static _isOnline($a_obj_id)
returns the objects's ONline status
Class ilObjTestListGUI.
addCommandLinkParameter($a_param)
add command link parameters
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.
ilObjectListGUI()
constructor
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
$params
Definition: example_049.php:96
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15