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