ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilAssQuestionHintsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Table/classes/class.ilTable2GUI.php';
5require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
6require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
7
17{
23
29
36 private $questionOBJ = null;
37
44 private $tableMode = null;
45
52 private $hintOrderingClipboard = null;
53
65 public function __construct(
67 ilAssQuestionHintList $questionHintList,
69 $parentCmd,
70 $tableMode = self::TBL_MODE_TESTOUTPUT,
72 ) {
73 global $DIC;
74 $ilCtrl = $DIC['ilCtrl'];
75 $lng = $DIC['lng'];
76
77 $this->questionOBJ = $questionOBJ;
78 $this->tableMode = $tableMode;
79 $this->hintOrderingClipboard = $hintOrderingClipboard;
80
81 $this->setPrefix('tsthints' . $tableMode);
82 $this->setId('tsthints' . $tableMode);
83
84 parent::__construct($parentGUI, $parentCmd);
85
86 $this->setTitle(sprintf($lng->txt('tst_question_hints_table_header'), $questionOBJ->getTitle()));
87 $this->setNoEntriesText($lng->txt('tst_question_hints_table_no_items'));
88
89 // we don't take care about offset/limit values, so this avoids segmentation in general
90 // --> required for ordering via clipboard feature
91 $this->setExternalSegmentation(true);
92
93 $tableData = $questionHintList->getTableData();
94
95 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
96 require_once 'Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php';
97
98 foreach ($tableData as $key => $data) {
99 $pageObjectGUI = new ilAssHintPageGUI($data['hint_id']);
100 $pageObjectGUI->setOutputMode("presentation");
101 $tableData[$key]['hint_text'] = $pageObjectGUI->presentation();
102 }
103 }
104
105 $this->setData($tableData);
106
107 if ($this->tableMode == self::TBL_MODE_ADMINISTRATION) {
108 $this->setRowTemplate('tpl.tst_question_hints_administration_table_row.html', 'Modules/TestQuestionPool');
109
110 $this->setSelectAllCheckbox('hint_ids[]');
111
112 $rowCount = count($tableData);
113 $this->initAdministrationColumns($rowCount);
114 $this->initAdministrationCommands($rowCount);
115 } else {
116 $this->setRowTemplate('tpl.tst_question_hints_testoutput_table_row.html', 'Modules/TestQuestionPool');
117
118 $this->initTestoutputColumns();
119 $this->initTestoutputCommands();
120 }
121 }
122
132 private function initAdministrationCommands($rowCount)
133 {
134 global $DIC;
135 $ilCtrl = $DIC['ilCtrl'];
136 $lng = $DIC['lng'];
137
138 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
139
140 if ($this->hintOrderingClipboard->hasStored()) {
141 $this->addMultiCommand(
143 $lng->txt('tst_questions_hints_table_multicmd_paste_hint_before')
144 );
145
146 $this->addMultiCommand(
148 $lng->txt('tst_questions_hints_table_multicmd_paste_hint_after')
149 );
150 } elseif ($rowCount > 0) {
151 $this->addMultiCommand(
153 $lng->txt('tst_questions_hints_table_multicmd_delete_hint')
154 );
155
156 if ($rowCount > 1) {
157 $this->addMultiCommand(
159 $lng->txt('tst_questions_hints_table_multicmd_cut_hint')
160 );
161 }
162
163 $this->addCommandButton(
165 $lng->txt('tst_questions_hints_table_cmd_save_order')
166 );
167 }
168 }
169
178 private function initTestoutputCommands()
179 {
180 if ($this->parent_obj instanceof ilAssQuestionHintsGUI) {
181 return;
182 }
183
184 global $DIC;
185 $ilCtrl = $DIC['ilCtrl'];
186 $lng = $DIC['lng'];
187
188 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
189
190 $this->addCommandButton(
192 $lng->txt('tst_question_hints_back_to_question')
193 );
194 }
195
204 private function initAdministrationColumns($rowCount)
205 {
206 global $DIC;
207 $lng = $DIC['lng'];
208
209 $this->addColumn('', '', '30', true);
210
211 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_order'), 'hint_index', '60');
212 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_text'), 'hint_text');
213 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_points'), 'hint_points', '250');
214
215 $this->addColumn('', '', '100');
216
217 $this->setDefaultOrderField("hint_index");
218 $this->setDefaultOrderDirection("asc");
219
220 if ($rowCount < 1) {
221 $this->disable('header');
222 }
223 }
224
232 private function initTestoutputColumns()
233 {
234 global $DIC;
235 $lng = $DIC['lng'];
236
237 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_index'), 'hint_index', '200');
238 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_text'), 'hint_text');
239 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_points'), 'hint_points', '200');
240
241 $this->setDefaultOrderField("hint_index");
242 $this->setDefaultOrderDirection("asc");
243 }
244
253 public function numericOrdering($field)
254 {
255 switch ($field) {
256 case 'hint_index':
257 case 'hint_points':
258
259 return true;
260 }
261
262 return false;
263 }
264
273 public function fillRow($rowData)
274 {
275 global $DIC;
276 $ilCtrl = $DIC['ilCtrl'];
277 $lng = $DIC['lng'];
278
279 if ($this->tableMode == self::TBL_MODE_ADMINISTRATION) {
280 $list = new ilAdvancedSelectionListGUI();
281 $list->setListTitle($lng->txt('actions'));
282 $list->setId("advsl_hint_{$rowData['hint_id']}_actions");
283
284 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
285 $editPointsHref = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM);
286 $editPointsHref = ilUtil::appendUrlParameterString($editPointsHref, "hint_id={$rowData['hint_id']}", true);
287 $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint_points'), '', $editPointsHref);
288
289 $editPageHref = $ilCtrl->getLinkTargetByClass('ilasshintpagegui', 'edit');
290 $editPageHref = ilUtil::appendUrlParameterString($editPageHref, "hint_id={$rowData['hint_id']}", true);
291 $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint_page'), '', $editPageHref);
292 } else {
293 $editHref = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM);
294 $editHref = ilUtil::appendUrlParameterString($editHref, "hint_id={$rowData['hint_id']}", true);
295 $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint'), '', $editHref);
296 }
297
298 $deleteHref = $ilCtrl->getLinkTarget($this->parent_obj, ilAssQuestionHintsGUI::CMD_CONFIRM_DELETE);
299 $deleteHref = ilUtil::appendUrlParameterString($deleteHref, "hint_id={$rowData['hint_id']}", true);
300 $list->addItem($lng->txt('tst_question_hints_table_link_delete_hint'), '', $deleteHref);
301
302 $this->tpl->setVariable('ACTIONS', $list->getHTML());
303
304 $this->tpl->setVariable('HINT_ID', $rowData['hint_id']);
305
306 $hintIndex = $rowData['hint_index'] * self::INDEX_TO_POSITION_FACTOR;
307 } else {
308 $showHref = $this->parent_obj->getHintPresentationLinkTarget($rowData['hint_id']);
309
310 $this->tpl->setVariable('HINT_HREF', $showHref);
311
312 $hintIndex = ilAssQuestionHint::getHintIndexLabel($lng, $rowData['hint_index']);
313 }
314
315 $this->tpl->setVariable('HINT_INDEX', $hintIndex);
316 $txt = ilUtil::prepareTextareaOutput($rowData['hint_text'], true);
317 $this->tpl->setVariable('HINT_TEXT', $txt);
318 $this->tpl->setVariable('HINT_POINTS', $rowData['hint_points']);
319 }
320}
An exception for terminatinating execution or to throw for unit testing.
Abstract basic class which is to be extended by the concrete assessment question type classes.
User interface class for advanced drop-down selection lists.
Assessment hint page GUI class.
const CMD_SHOW_FORM
command constants
getTableData()
returns an array with data of the hints in this list that is adopted to be used as table gui data
static getHintIndexLabel(ilLanguage $lng, $hintIndex)
initAdministrationColumns($rowCount)
inits the required columns for administration table mode
const TBL_MODE_TESTOUTPUT
the available table modes controlling the tables behaviour
fillRow($rowData)
renders a table row by filling wor data to table row template
const INDEX_TO_POSITION_FACTOR
the factor the ordering position value is multiplicated with (so the user gets non decimal gaps for r...
initTestoutputColumns()
inits the required columns for testoutput table mode
__construct(assQuestion $questionOBJ, ilAssQuestionHintList $questionHintList, ilAssQuestionHintAbstractGUI $parentGUI, $parentCmd, $tableMode=self::TBL_MODE_TESTOUTPUT, ilAssQuestionHintsOrderingClipboard $hintOrderingClipboard=null)
Constructor.
numericOrdering($field)
returns the fact wether the passed field is to be ordered numerically or not
initTestoutputCommands()
inits the required command buttons / multi selection commands for testoutput table mode
initAdministrationCommands($rowCount)
inits the required command buttons / multi selection commands for administration table mode
Class ilTable2GUI.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setNoEntriesText($a_text)
Set text for an empty table.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
$txt
Definition: error.php:13
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46