ILIAS  release_7 Revision v7.30-3-g800a261c036
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
53
61 public function getCommandFrame($a_cmd)
62 {
63 switch ($a_cmd) {
64 case "":
65 case "infoScreen":
66 case "eval_a":
67 case "eval_stat":
68 include_once "./Services/UICore/classes/class.ilFrameTargetInfo.php";
69 $frame = ilFrameTargetInfo::_getFrame("MainContent");
70 break;
71
72 default:
73 }
74
75 return $frame;
76 }
77
78
79
88 public function getProperties()
89 {
90 global $DIC;
91 $lng = $DIC['lng'];
92 $ilUser = $DIC['ilUser'];
93
94 $props = parent::getProperties();
95
96 // we cannot use ilObjTestAccess::_isOffline() because of text messages
97 $onlineaccess = ilObjTestAccess::_lookupOnlineTestAccess($this->obj_id, $ilUser->id);
98 if ($onlineaccess !== true) {
99 $props[] = array("alert" => true, "property" => $lng->txt("status"),
100 "value" => $onlineaccess);
101 }
102
103 return $props;
104 }
105
106
114 public function getCommandLink($a_cmd)
115 {
116 global $DIC;
117 $ilCtrl = $DIC['ilCtrl'];
118
119 $a_cmd = explode('::', $a_cmd);
120
121 if (count($a_cmd) == 2) {
122 $cmd_link = $ilCtrl->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjTestGUI', $a_cmd[0]), $a_cmd[1]);
123 } else {
124 $cmd_link = $ilCtrl->getLinkTargetByClass('ilObjTestGUI', $a_cmd[0]);
125 }
126
127 $params = array_merge(array('ref_id' => $this->ref_id), $this->command_link_params);
128
129 foreach ($params as $param => $value) {
130 $cmd_link = ilUtil::appendUrlParameterString($cmd_link, "$param=$value", true);
131 }
132
133 return $cmd_link;
134 }
135
136 public function getCommands()
137 {
138 $commands = parent::getCommands();
139
140 $commands = $this->handleUserResultsCommand($commands);
141
142 return $commands;
143 }
144
145 private function handleUserResultsCommand($commands)
146 {
147 global $DIC;
148 $ilUser = $DIC['ilUser'];
149
150 if (!$this->isObjectiveTest()) {
151 $commands = $this->removeUserResultsCommand($commands);
152 } else {
153 require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
154
155 if (!ilObjTestAccess::visibleUserResultExists($this->obj_id, $ilUser->getId())) {
156 $commands = $this->removeUserResultsCommand($commands);
157 }
158 }
159
160 return $commands;
161 }
162
163 private function isObjectiveTest()
164 {
165 require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
166 return ilLOSettings::isObjectiveTest($this->ref_id);
167 }
168
169 private function removeUserResultsCommand($commands)
170 {
171 foreach ($commands as $key => $command) {
172 if ($command['cmd'] == 'userResultsGateway') {
173 unset($commands[$key]);
174 break;
175 }
176 }
177
178 return $commands;
179 }
180
188 public function createDefaultCommand($a_command)
189 {
190 return $a_command;
191 }
192
193
201 public function addCommandLinkParameter($a_param)
202 {
203 $this->command_link_params = $a_param;
204 }
205
206 // begin-patch lok
207 protected function modifyTitleLink($a_default_link)
208 {
209 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
210 $id = ilLOSettings::isObjectiveTest($this->ref_id);
211
212 $cmd_link = $a_default_link;
213
214 if ($id) {
215 $ref_ids = ilObject::_getAllReferences($id);
216 $ref_id = end($ref_ids);
217
218 $this->ctrl->setParameterByClass("ilrepositorygui", 'ref_id', $ref_id);
219 $this->ctrl->setParameterByClass("ilrepositorygui", 'tid', $this->ref_id);
220 $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", 'redirectLocToTest');
221 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
222 $this->ctrl->clearParametersByClass('ilrepositorygui');
223 }
224 return parent::modifyTitleLink($cmd_link);
225 }
226 // end-patch lok
227} // 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.
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
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$param
Definition: xapitoken.php:29