ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilQuestionBrowserTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Services/Table/classes/class.ilTable2GUI.php');
5require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
6
18{
19 protected $editable = true;
20 protected $writeAccess = false;
21 protected $totalPoints = 0;
22 protected $totalWorkingTime = '00:00:00';
23 protected $confirmdelete;
24
25 protected $taxIds = array();
26
34 public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false, $confirmdelete = false, $taxIds = array())
35 {
36 $this->setId("qpl_qst_brows_" . $a_parent_obj->object->getRefId());
37 parent::__construct($a_parent_obj, $a_parent_cmd);
38
39 global $lng, $ilCtrl;
40
41 $this->lng = $lng;
42 $this->ctrl = $ilCtrl;
43
44 $this->confirmdelete = $confirmdelete;
45 $this->setWriteAccess($a_write_access);
46 $this->taxIds = $taxIds;
47
48 $qplSetting = new ilSetting("qpl");
49
50 $this->setFormName('questionbrowser');
51 $this->setStyle('table', 'fullwidth');
52 if (!$confirmdelete)
53 {
54 $this->addColumn('','','1%');
55 $this->addColumn($this->lng->txt("title"),'title', '');
56 $this->addColumn('','', '');
57 $this->addColumn('','', '');
58 foreach ($this->getSelectedColumns() as $c)
59 {
60 if (strcmp($c, 'description') == 0) $this->addColumn($this->lng->txt("description"),'description', '');
61 if (strcmp($c, 'type') == 0) $this->addColumn($this->lng->txt("question_type"),'ttype', '');
62 // According to mantis #12713
63 if (strcmp($c, 'points') == 0) $this->addColumn($this->lng->txt("points"),'points', '', false, 'ilCenterForced');
64 if (strcmp($c, 'statistics') == 0) $this->addColumn($this->lng->txt('statistics'),'', '');
65 if (strcmp($c, 'author') == 0) $this->addColumn($this->lng->txt("author"),'author', '');
66 if (strcmp($c, 'created') == 0) $this->addColumn($this->lng->txt("create_date"),'created', '');
67 if (strcmp($c, 'tstamp') == 0) $this->addColumn($this->lng->txt("last_update"),'tstamp', '');
68 if (strcmp($c, 'working_time') == 0) $this->addColumn($this->lng->txt("working_time"),'working_time', '');
69 }
70 $this->setSelectAllCheckbox('q_id');
71 }
72 else
73 {
74 $this->addColumn($this->lng->txt("title"),'title', '');
75 $this->addColumn('','f','1%');
76 foreach ($this->getSelectedColumns() as $c)
77 {
78 if (strcmp($c, 'description') == 0) $this->addColumn($this->lng->txt("description"),'description', '');
79 if (strcmp($c, 'type') == 0) $this->addColumn($this->lng->txt("question_type"),'ttype', '');
80 }
81 }
82
83 if ($this->getWriteAccess())
84 {
86 {
87 $this->addCommandButton('confirmDeleteQuestions', $this->lng->txt('confirm'));
88 $this->addCommandButton('cancelDeleteQuestions', $this->lng->txt('cancel'));
89 }
90 else
91 {
92 $this->addMultiCommand('copy', $this->lng->txt('copy'));
93 $this->addMultiCommand('move', $this->lng->txt('move'));
94 $this->addMultiCommand('exportQuestion', $this->lng->txt('export'));
95 $this->addMultiCommand('deleteQuestions', $this->lng->txt('delete'));
96
97 $this->addCommandButton('importQuestions', $this->lng->txt('import'));
98
99 if (array_key_exists("qpl_clipboard", $_SESSION) && count($_SESSION['qpl_clipboard']))
100 {
101 $this->addCommandButton('paste', $this->lng->txt('paste'));
102 }
103 }
104 }
105
106 $this->setRowTemplate("tpl.il_as_qpl_questionbrowser_row.html", "Modules/TestQuestionPool");
107
108 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
109 $this->setDefaultOrderField("title");
110 $this->setDefaultOrderDirection("asc");
111
112 $this->setShowRowsSelector(true);
113
114 if ($confirmdelete)
115 {
116 $this->disable('sort');
117 $this->disable('select_all');
118 }
119 else
120 {
121 $this->enable('sort');
122 $this->enable('header');
123 $this->enable('select_all');
124 $this->setFilterCommand('filterQuestionBrowser');
125 $this->setResetCommand('resetQuestionBrowser');
126 $this->initFilter();
127 }
128
129 }
130
132 {
133 global $lng;
134 $cols["description"] = array(
135 "txt" => $lng->txt("description"),
136 "default" => true
137 );
138 $cols["type"] = array(
139 "txt" => $lng->txt("question_type"),
140 "default" => true
141 );
142 if (!$this->confirmdelete)
143 {
144 $cols["points"] = array(
145 "txt" => $lng->txt("points"),
146 "default" => true
147 );
148 $cols["statistics"] = array(
149 "txt" => $lng->txt("statistics"),
150 "default" => true
151 );
152 $cols["author"] = array(
153 "txt" => $lng->txt("author"),
154 "default" => true
155 );
156 $cols["created"] = array(
157 "txt" => $lng->txt("create_date"),
158 "default" => true
159 );
160 $cols["tstamp"] = array(
161 "txt" => $lng->txt("last_update"),
162 "default" => true
163 );
164 $cols["working_time"] = array(
165 "txt" => $lng->txt("working_time"),
166 "default" => true
167 );
168 }
169 return $cols;
170 }
171
175 function initFilter()
176 {
177 global $lng, $rbacreview, $ilUser;
178
179 // title
180 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
181 $ti = new ilTextInputGUI($lng->txt("title"), "title");
182 $ti->setMaxLength(64);
183 $ti->setValidationRegexp('/^[^%]+$/is');
184 $ti->setSize(20);
185 $this->addFilterItem($ti);
186 $ti->readFromSession();
187 $this->filter["title"] = $ti->getValue();
188
189 // description
190 $ti = new ilTextInputGUI($lng->txt("description"), "description");
191 $ti->setMaxLength(64);
192 $ti->setSize(20);
193 $ti->setValidationRegexp('/^[^%]+$/is');
194 $this->addFilterItem($ti);
195 $ti->readFromSession();
196 $this->filter["description"] = $ti->getValue();
197
198 if (!$this->confirmdelete)
199 {
200 // author
201 $ti = new ilTextInputGUI($lng->txt("author"), "author");
202 $ti->setMaxLength(64);
203 $ti->setSize(20);
204 $ti->setValidationRegexp('/^[^%]+$/is');
205 $this->addFilterItem($ti);
206 $ti->readFromSession();
207 $this->filter["author"] = $ti->getValue();
208 }
209 // questiontype
210 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
211 include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
213 $options = array();
214 $options[""] = $lng->txt('filter_all_question_types');
215 foreach ($types as $translation => $row)
216 {
217 $options[$row['type_tag']] = $translation;
218 }
219
220 $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
221 $si->setOptions($options);
222 $this->addFilterItem($si);
223 $si->readFromSession();
224 $this->filter["type"] = $si->getValue();
225
226 if( $this->parent_obj->object->getShowTaxonomies() )
227 {
228 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
229
230 foreach($this->taxIds as $taxId)
231 {
232 if( $taxId == $this->parent_obj->object->getNavTaxonomyId() )
233 {
234 continue;
235 }
236
237 $postvar = "tax_$taxId";
238
239 $inp = new ilTaxSelectInputGUI($taxId, $postvar, true);
240 $this->addFilterItem($inp);
241 $inp->readFromSession();
242 $this->filter[$postvar] = $inp->getValue();
243 }
244 }
245
246 }
247
248 function fillHeader()
249 {
250 foreach ($this->column as $key => $column)
251 {
252 if (strcmp($column['text'], $this->lng->txt("points")) == 0)
253 {
254 $this->column[$key]['text'] = $this->lng->txt("points") . "&nbsp;(" . $this->totalPoints . ")";
255 }
256 elseif (strcmp($column['text'], $this->lng->txt("working_time")) == 0)
257 {
258 $this->column[$key]['text'] = $this->lng->txt("working_time") . "&nbsp;(" . $this->totalWorkingTime . ")";
259 }
260 }
261 parent::fillHeader();
262 }
263
271 public function fillRow($data)
272 {
273 global $ilUser,$ilAccess;
274 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
275 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
276 $class = strtolower(assQuestionGUI::_getGUIClassNameForId($data["question_id"]));
277 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $data["question_id"]);
278 $this->ctrl->setParameterByClass("ilAssQuestionPreviewGUI", "q_id", $data["question_id"]);
279 $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
280 $points = 0;
281
282 if (!$this->confirmdelete)
283 {
284 $this->tpl->setCurrentBlock('checkbox');
285 $this->tpl->setVariable('CB_QUESTION_ID', $data["question_id"]);
286 $this->tpl->parseCurrentBlock();
287
288 if ($this->getEditable())
289 {
290 //$href = $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit");
291 $href = $this->ctrl->getLinkTargetByClass($data['type_tag'].'GUI', 'editQuestion');
292
293 $this->tpl->setCurrentBlock("edit_link");
294 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
295 $this->tpl->setVariable("LINK_EDIT", $href);
296 $this->tpl->parseCurrentBlock();
297 }
298 if ($data["complete"] == 0)
299 {
300 $this->tpl->setCurrentBlock("qpl_warning");
301 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("icon_alert.svg"));
302 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
303 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
304 $this->tpl->parseCurrentBlock();
305 }
306 else
307 {
308 $points = $data["points"];
309 $this->totalWorkingTime = assQuestion::sumTimesInISO8601FormatH_i_s_Extended($this->totalWorkingTime,$data['working_time']);
310 }
311 $this->totalPoints += $points;
312
313 foreach ($this->getSelectedColumns() as $c)
314 {
315 if (strcmp($c, 'points') == 0)
316 {
317 $this->tpl->setCurrentBlock('points');
318 $this->tpl->setVariable("QUESTION_POINTS", $points);
319 $this->tpl->parseCurrentBlock();
320 }
321 if (strcmp($c, 'statistics') == 0)
322 {
323 $this->tpl->setCurrentBlock('statistics');
324 $this->tpl->setVariable("LINK_ASSESSMENT", $this->ctrl->getLinkTargetByClass($class, "assessment"));
325 $this->tpl->setVariable("TXT_ASSESSMENT", $this->lng->txt("statistics"));
326 include_once "./Services/Utilities/classes/class.ilUtil.php";
327 $this->tpl->setVariable("IMG_ASSESSMENT", ilUtil::getImagePath("assessment.gif", "Modules/TestQuestionPool"));
328 $this->tpl->parseCurrentBlock();
329 }
330 if (strcmp($c, 'author') == 0)
331 {
332 $this->tpl->setCurrentBlock('author');
333 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
334 $this->tpl->parseCurrentBlock();
335 }
336 if(strcmp($c, 'created') == 0)
337 {
338 $this->tpl->setCurrentBlock('created');
339 $this->tpl->setVariable('QUESTION_CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
340 $this->tpl->parseCurrentBlock();
341 }
342 if(strcmp($c, 'tstamp') == 0)
343 {
344 $this->tpl->setCurrentBlock('updated');
345 $this->tpl->setVariable('QUESTION_UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['tstamp'], IL_CAL_UNIX)));
346 $this->tpl->parseCurrentBlock();
347 }
348 if(strcmp($c, 'working_time') == 0)
349 {
350 $this->tpl->setCurrentBlock('working_time');
351 $this->tpl->setVariable('WORKING_TIME', $data["working_time"]);
352 $this->tpl->parseCurrentBlock();
353 }
354 }
355
356 $this->tpl->setCurrentBlock('preview');
357 $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
358 $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW));
359 $this->tpl->parseCurrentBlock();
360 }
361 else
362 {
363 $this->tpl->setCurrentBlock('hidden');
364 $this->tpl->setVariable('HIDDEN_QUESTION_ID', $data["question_id"]);
365 $this->tpl->parseCurrentBlock();
366 }
367
368 foreach ($this->getSelectedColumns() as $c)
369 {
370 if (strcmp($c, 'description') == 0)
371 {
372 $this->tpl->setCurrentBlock('description');
373 $this->tpl->setVariable("QUESTION_COMMENT", (strlen($data["description"])) ? $data["description"] : "&nbsp;");
374 $this->tpl->parseCurrentBlock();
375 }
376 if (strcmp($c, 'type') == 0)
377 {
378 $this->tpl->setCurrentBlock('type');
379 $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
380 $this->tpl->parseCurrentBlock();
381 }
382 }
383 $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
384 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
385 }
386
387 public function setEditable($value)
388 {
389 $this->editable = $value;
390 }
391
392 public function getEditable()
393 {
394 return $this->editable;
395 }
396
397 public function setWriteAccess($value)
398 {
399 $this->writeAccess = $value;
400 }
401
402 public function getWriteAccess()
403 {
404 return $this->writeAccess;
405 }
406
411 public function numericOrdering($column)
412 {
413 if(in_array($column, array('points', 'created', 'tstamp')))
414 {
415 return true;
416 }
417
418 return false;
419 }
420}
const IL_CAL_UNIX
static sumTimesInISO8601FormatH_i_s_Extended($time1, $time2)
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
& _getQuestionTypes($all_tags=FALSE, $fixOrder=false)
getSelectableColumns()
Get selectable columns.
__construct($a_parent_obj, $a_parent_cmd, $a_write_access=false, $confirmdelete=false, $taxIds=array())
Constructor.
This class represents a selection list property in a property form.
ILIAS Setting Class.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setFormName($a_formname)
Set Form name.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
Select taxonomy nodes input GUI.
This class represents a text property in a property form.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15