ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
16 include_once "Services/Object/classes/class.ilObjectListGUI.php";
17 include_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 $lng, $ilUser;
104 
105  $props = array();
106  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
107 
108  if (!ilObjTestAccess::_isOnline($this->obj_id)) {
109  $props[] = array("alert" => true, "property" => $lng->txt("status"),
110  "value" => $lng->txt("offline"));
111  }
112 
113 
114  // we cannot use ilObjTestAccess::_isOffline() because of text messages
115  $onlineaccess = ilObjTestAccess::_lookupOnlineTestAccess($this->obj_id, $ilUser->id);
116  if ($onlineaccess !== true) {
117  $props[] = array("alert" => true, "property" => $lng->txt("status"),
118  "value" => $onlineaccess);
119  }
120 
121  return $props;
122  }
123 
124 
132  public function getCommandLink($a_cmd)
133  {
134  global $ilCtrl;
135 
136  $a_cmd = explode('::', $a_cmd);
137 
138  if (count($a_cmd) == 2) {
139  $cmd_link = $ilCtrl->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjTestGUI', $a_cmd[0]), $a_cmd[1]);
140  } else {
141  $cmd_link = $ilCtrl->getLinkTargetByClass('ilObjTestGUI', $a_cmd[0]);
142  }
143 
144  $params = array_merge(array('ref_id' => $this->ref_id), $this->command_link_params);
145 
146  foreach ($params as $param => $value) {
147  $cmd_link = ilUtil::appendUrlParameterString($cmd_link, "$param=$value", true);
148  }
149 
150  return $cmd_link;
151  }
152 
153  public function getCommands()
154  {
155  $commands = parent::getCommands();
156 
157  $commands = $this->handleUserResultsCommand($commands);
158 
159  return $commands;
160  }
161 
162  private function handleUserResultsCommand($commands)
163  {
164  global $ilUser;
165 
166  if (!$this->isObjectiveTest()) {
167  $commands = $this->removeUserResultsCommand($commands);
168  } else {
169  require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
170 
171  if (!ilObjTestAccess::visibleUserResultExists($this->obj_id, $ilUser->getId())) {
172  $commands = $this->removeUserResultsCommand($commands);
173  }
174  }
175 
176  return $commands;
177  }
178 
179  private function isObjectiveTest()
180  {
181  require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
182  return ilLOSettings::isObjectiveTest($this->ref_id);
183  }
184 
185  private function removeUserResultsCommand($commands)
186  {
187  foreach ($commands as $key => $command) {
188  if ($command['cmd'] == 'userResultsGateway') {
189  unset($commands[$key]);
190  break;
191  }
192  }
193 
194  return $commands;
195  }
196 
204  public function createDefaultCommand($a_command)
205  {
206  return $a_command;
207  }
208 
209 
217  public function addCommandLinkParameter($a_param)
218  {
219  $this->command_link_params = $a_param;
220  }
221 
222  // begin-patch lok
223  protected function modifyTitleLink($a_default_link)
224  {
225  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
226  $id = ilLOSettings::isObjectiveTest($this->ref_id);
227 
228  $cmd_link = $a_default_link;
229 
230  if ($id) {
231  $ref_ids = ilObject::_getAllReferences($id);
232  $ref_id = end($ref_ids);
233 
234  $this->ctrl->setParameterByClass("ilrepositorygui", 'ref_id', $ref_id);
235  $this->ctrl->setParameterByClass("ilrepositorygui", 'tid', $this->ref_id);
236  $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", 'redirectLocToTest');
237  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
238  $this->ctrl->clearParametersByClass('ilrepositorygui');
239  }
240  return parent::modifyTitleLink($cmd_link);
241  }
242  // end-patch lok
243 } // END class.ilObjTestListGUI
$params
Definition: disable.php:11
modifyTitleLink($a_default_link)
getCommandFrame($a_cmd)
Get command target frame.
if(!array_key_exists('StateId', $_REQUEST)) $id
getCommandLink($a_cmd)
Get command link url.
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
static _isOnline($a_obj_id)
returns the objects&#39;s ONline status
initItem($a_ref_id, $a_obj_id, $a_title="", $a_description="")
inititialize new item
static _getAllReferences($a_id)
get all reference ids of object
getProperties()
Get item properties.
__construct($a_context=self::CONTEXT_REPOSITORY)
constructor
global $ilCtrl
Definition: ilias.php:18
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static visibleUserResultExists($testObjId, $userId)
Class ilObjTestListGUI.
Class ilObjectListGUI.
$ilUser
Definition: imgupload.php:18
addCommandLinkParameter($a_param)
add command link parameters
Create styles array
The data for the language used.
static _getFrame($a_class, $a_type='')
Get content frame name.
static _getCommands()
get commands
createDefaultCommand($a_command)
overwritten from base class for course objectives
$key
Definition: croninfo.php:18