ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilTestQuestionsTableGUI.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 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
6
17{
18 protected $writeAccess = false;
19 protected $totalPoints = 0;
20 protected $totalWorkingTime = '00:00:00';
21 protected $checked_move = false;
22 protected $total = 0;
23 protected $position = 0;
24
28 protected $visibleOptionalColumns = array();
29
33 protected $optionalColumns = array();
34
42 public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false, $a_checked_move = false, $a_total = 0)
43 {
44 $this->setId('tst_qst_lst_'.$a_parent_obj->object->getRefId());
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 global $lng, $ilCtrl;
49
50 $this->lng = $lng;
51 $this->ctrl = $ilCtrl;
52 $this->total = $a_total;
53
54 $this->setWriteAccess($a_write_access);
55 $this->setCheckedMove($a_checked_move);
56
57 $this->setFormName('questionbrowser');
58 $this->setStyle('table', 'fullwidth');
59 $this->addColumn('','f','1%', true);
60 $this->addColumn('','f','1%');
61 $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
62 $this->optionalColumns = (array)$this->getSelectableColumns();
63 if(isset($this->visibleOptionalColumns['qid']))
64 {
65 $this->addColumn($this->optionalColumns['qid']['txt'],'qid', '');
66 }
67 $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
68 //$this->addColumn($this->lng->txt("tst_sequence"),'sequence', '');
69 if( $a_parent_obj->object->areObligationsEnabled() )
70 {
71 $this->addColumn($this->lng->txt("obligatory"),'obligatory', '');
72 }
73 if(isset($this->visibleOptionalColumns['description']))
74 {
75 $this->addColumn($this->optionalColumns['description']['txt'],'description', '');
76 }
77 $this->addColumn($this->lng->txt("tst_question_type"),'type', '');
78 $this->addColumn($this->lng->txt("points"),'', '');
79 if(isset($this->visibleOptionalColumns['author']))
80 {
81 $this->addColumn($this->optionalColumns['author']['txt'],'author', '');
82 }
83 if(isset($this->visibleOptionalColumns['working_time']))
84 {
85 $this->addColumn($this->optionalColumns['working_time']['txt'],'working_time', '');
86 }
87 $this->addColumn($this->lng->txt("qpl"),'qpl', '');
88
89 $this->setSelectAllCheckbox('q_id');
90
91 $this->setExternalSegmentation(true);
92
93 if ($this->getWriteAccess() && !$this->getTotal())
94 {
95 $this->addMultiCommand('removeQuestions', $this->lng->txt('remove_question'));
96 $this->addMultiCommand('moveQuestions', $this->lng->txt('move'));
97 if ($this->checked_move)
98 {
99 $this->addMultiCommand('insertQuestionsBefore', $this->lng->txt('insert_before'));
100 $this->addMultiCommand('insertQuestionsAfter', $this->lng->txt('insert_after'));
101 }
102 //$this->addMultiCommand('copyToQuestionpool', $this->lng->txt('copy_to_questionpool'));
103 $this->addMultiCommand('copyQuestion', $this->lng->txt('copy'));
104 $this->addMultiCommand('copyAndLinkToQuestionpool', $this->lng->txt('copy_and_link_to_questionpool'));
105
106 }
107
108
109 $this->setRowTemplate("tpl.il_as_tst_questions_row.html", "Modules/Test");
110
111 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
112
113 if( $a_parent_obj->object->areObligationsEnabled() )
114 {
115 $this->addCommandButton('saveOrderAndObligations', $this->lng->txt('saveOrderAndObligations'));
116 }
117 else
118 {
119 $this->addCommandButton('saveOrderAndObligations', $this->lng->txt('saveOrder'));
120 }
121
122 $this->disable('sort');
123 $this->enable('header');
124 $this->enable('select_all');
125 }
126
130 public function getSelectableColumns()
131 {
132 $cols = array(
133 'qid' => array('txt' => $this->lng->txt('question_id'), 'default' => true),
134 'description' => array('txt' => $this->lng->txt('description'), 'default' => false),
135 'author' => array('txt' => $this->lng->txt('author'), 'default' => false),
136 'working_time'=> array('txt' => $this->lng->txt('working_time'), 'default' => false)
137 );
138
139 return $cols;
140 }
141
142 function fillHeader()
143 {
144 foreach ($this->column as $key => $column)
145 {
146 if (strcmp($column['text'], $this->lng->txt("points")) == 0)
147 {
148 $this->column[$key]['text'] = $this->lng->txt("points") . "&nbsp;(" . $this->totalPoints . ")";
149 }
150 elseif (strcmp($column['text'], $this->lng->txt("working_time")) == 0)
151 {
152 $this->column[$key]['text'] = $this->lng->txt("working_time") . "&nbsp;(" . $this->totalWorkingTime . ")";
153 }
154 }
155 parent::fillHeader();
156 }
157
165 public function fillRow($data)
166 {
167 global $ilUser,$ilAccess;
168
169 $q_id = $data["question_id"];
170
171 $this->tpl->setVariable("QUESTION_ID", $q_id);
172 if(isset($this->visibleOptionalColumns['qid']))
173 {
174 $this->tpl->setVariable("QUESTION_ID_PRESENTATION", $q_id);
175 }
176 if ($this->getWriteAccess() && !$this->getTotal() && $data["obj_fi"] > 0)
177 {
178 if (!$data['complete']) {
179 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("icon_alert.svg"));
180 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
181 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
182 }
183
184
185 $qpl_ref_id = current(ilObject::_getAllReferences($data["obj_fi"]));
186 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
187
188 // obligatory checkbox (when obligation is possible)
189 if( $data["obligationPossible"] )
190 {
191 $CHECKED = $data["obligatory"] ? "checked=\"checked\" " : "";
192 $OBLIGATORY = "<input type=\"checkbox\" name=\"obligatory[$q_id]\" value=\"1\" $CHECKED/>";
193 }
194 else
195 {
196 $OBLIGATORY = "";
197 }
198 }
199 else
200 {
201 global $lng;
202
203 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
204
205 // obligatory icon
206 if( $data["obligatory"] )
207 {
208 require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
209 $OBLIGATORY = ilGlyphGUI::get(ilGlyphGUI::EXCLAMATION, $lng->txt('question_obligatory'));
210 }
211 else $OBLIGATORY = '';
212 }
213
214 if( $this->parent_obj->object->areObligationsEnabled() )
215 {
216 $this->tpl->setVariable("QUESTION_OBLIGATORY", $OBLIGATORY);
217 }
218
219 $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
220
221 if ($this->getWriteAccess() && !$this->getTotal())
222 {
223 if ($data["sequence"] != 1)
224 {
225 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&up=".$data["question_id"]."\">" . ilGlyphGUI::get(ilGlyphGUI::UP, $this->lng->txt('up')) . "</a>");
226 }
227 if ($data["sequence"] != count($this->getData()))
228 {
229 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&down=".$data["question_id"]."\">" . ilGlyphGUI::get(ilGlyphGUI::DOWN, $this->lng->txt('down')) . "</a>");
230 }
231 }
232
233 if(isset($this->visibleOptionalColumns['description']))
234 {
235 if($data["description"])
236 {
237 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"] ? $data["description"] : '&nbsp;');
238 }
239 else
240 {
241 $this->tpl->touchBlock('question_comment_block');
242 }
243 }
244 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
245 $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
246 $this->tpl->setVariable("QUESTION_POINTS", $data["points"]);
247 $this->totalPoints += $data["points"];
248 $this->totalWorkingTime = assQuestion::sumTimesInISO8601FormatH_i_s_Extended($this->totalWorkingTime,$data['working_time']);
249 if(isset($this->visibleOptionalColumns['author']))
250 {
251 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
252 }
253 if(isset($this->visibleOptionalColumns['working_time']))
254 {
255 $this->tpl->setVariable("QUESTION_WORKING_TIME", $data["working_time"]);
256 }
257 if (ilObject::_lookupType($data["orig_obj_fi"]) == 'qpl') {
258 $this->tpl->setVariable("QUESTION_POOL", ilObject::_lookupTitle($data["orig_obj_fi"]));
259 }
260 else {
261 $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt('tst_question_not_from_pool_info'));
262 }
263
264
265 $this->position += 10;
266 $field = "<input type=\"text\" name=\"order[q_".$data["question_id"].
267 "]\" value=\"".$this->position."\" maxlength=\"3\" size=\"3\" />";
268 $this->tpl->setVariable("QUESTION_POSITION", $field);
269 }
270
271 public function setWriteAccess($value)
272 {
273 $this->writeAccess = $value;
274 }
275
276 public function getWriteAccess()
277 {
278 return $this->writeAccess;
279 }
280
281 public function setCheckedMove($value)
282 {
283 $this->checked_move = $value;
284 }
285
286 public function getCheckedMove()
287 {
288 return $this->checked_move;
289 }
290
291 public function setTotal($value)
292 {
293 $this->total = $value;
294 }
295
296 public function getTotal()
297 {
298 return $this->total;
299 }
300}
301?>
$column
Definition: 39dropdown.php:62
An exception for terminatinating execution or to throw for unit testing.
static sumTimesInISO8601FormatH_i_s_Extended($time1, $time2)
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static get($a_glyph, $a_text="")
Get glyph html.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
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
__construct($a_parent_obj, $a_parent_cmd, $a_write_access=false, $a_checked_move=false, $a_total=0)
Constructor.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18