ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilCtrl, $lng;
74
75 $this->questionOBJ = $questionOBJ;
76 $this->tableMode = $tableMode;
77 $this->hintOrderingClipboard = $hintOrderingClipboard;
78
79 $this->setPrefix('tsthints' . $tableMode);
80 $this->setId('tsthints' . $tableMode);
81
82 parent::__construct($parentGUI, $parentCmd);
83
84 $this->setTitle(sprintf($lng->txt('tst_question_hints_table_header'), $questionOBJ->getTitle()));
85 $this->setNoEntriesText($lng->txt('tst_question_hints_table_no_items'));
86
87 // we don't take care about offset/limit values, so this avoids segmentation in general
88 // --> required for ordering via clipboard feature
89 $this->setExternalSegmentation(true);
90
91 $tableData = $questionHintList->getTableData();
92
93 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
94 require_once 'Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php';
95
96 foreach ($tableData as $key => $data) {
97 $pageObjectGUI = new ilAssHintPageGUI($data['hint_id']);
98 $pageObjectGUI->setOutputMode("presentation");
99 $tableData[$key]['hint_text'] = $pageObjectGUI->presentation();
100 }
101 }
102
103 $this->setData($tableData);
104
105 if ($this->tableMode == self::TBL_MODE_ADMINISTRATION) {
106 $this->setRowTemplate('tpl.tst_question_hints_administration_table_row.html', 'Modules/TestQuestionPool');
107
108 $this->setSelectAllCheckbox('hint_ids[]');
109
110 $rowCount = count($tableData);
111 $this->initAdministrationColumns($rowCount);
112 $this->initAdministrationCommands($rowCount);
113 } else {
114 $this->setRowTemplate('tpl.tst_question_hints_testoutput_table_row.html', 'Modules/TestQuestionPool');
115
116 $this->initTestoutputColumns();
117 $this->initTestoutputCommands();
118 }
119 }
120
130 private function initAdministrationCommands($rowCount)
131 {
132 global $ilCtrl, $lng;
133
134 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
135
136 if ($this->hintOrderingClipboard->hasStored()) {
137 $this->addMultiCommand(
139 $lng->txt('tst_questions_hints_table_multicmd_paste_hint_before')
140 );
141
142 $this->addMultiCommand(
144 $lng->txt('tst_questions_hints_table_multicmd_paste_hint_after')
145 );
146 } elseif ($rowCount > 0) {
147 $this->addMultiCommand(
149 $lng->txt('tst_questions_hints_table_multicmd_delete_hint')
150 );
151
152 if ($rowCount > 1) {
153 $this->addMultiCommand(
155 $lng->txt('tst_questions_hints_table_multicmd_cut_hint')
156 );
157 }
158
159 $this->addCommandButton(
161 $lng->txt('tst_questions_hints_table_cmd_save_order')
162 );
163 }
164 }
165
174 private function initTestoutputCommands()
175 {
176 if ($this->parent_obj instanceof ilAssQuestionHintsGUI) {
177 return;
178 }
179
180 global $ilCtrl, $lng;
181
182 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
183
184 $this->addCommandButton(
186 $lng->txt('tst_question_hints_back_to_question')
187 );
188 }
189
198 private function initAdministrationColumns($rowCount)
199 {
200 global $lng;
201
202 $this->addColumn('', '', '30', true);
203
204 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_order'), 'hint_index', '60');
205 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_text'), 'hint_text');
206 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_points'), 'hint_points', '250');
207
208 $this->addColumn('', '', '100');
209
210 $this->setDefaultOrderField("hint_index");
211 $this->setDefaultOrderDirection("asc");
212
213 if ($rowCount < 1) {
214 $this->disable('header');
215 }
216 }
217
225 private function initTestoutputColumns()
226 {
227 global $lng;
228
229 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_index'), 'hint_index', '200');
230 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_text'), 'hint_text');
231 $this->addColumn($lng->txt('tst_question_hints_table_column_hint_points'), 'hint_points', '200');
232
233 $this->setDefaultOrderField("hint_index");
234 $this->setDefaultOrderDirection("asc");
235 }
236
245 public function numericOrdering($field)
246 {
247 switch ($field) {
248 case 'hint_index':
249 case 'hint_points':
250
251 return true;
252 }
253
254 return false;
255 }
256
265 public function fillRow($rowData)
266 {
267 global $ilCtrl, $lng;
268
269 if ($this->tableMode == self::TBL_MODE_ADMINISTRATION) {
271 $list->setListTitle($lng->txt('actions'));
272 $list->setId("advsl_hint_{$rowData['hint_id']}_actions");
273
274 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
275 $editPointsHref = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM);
276 $editPointsHref = ilUtil::appendUrlParameterString($editPointsHref, "hint_id={$rowData['hint_id']}", true);
277 $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint_points'), '', $editPointsHref);
278
279 $editPageHref = $ilCtrl->getLinkTargetByClass('ilasshintpagegui', 'edit');
280 $editPageHref = ilUtil::appendUrlParameterString($editPageHref, "hint_id={$rowData['hint_id']}", true);
281 $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint_page'), '', $editPageHref);
282 } else {
283 $editHref = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM);
284 $editHref = ilUtil::appendUrlParameterString($editHref, "hint_id={$rowData['hint_id']}", true);
285 $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint'), '', $editHref);
286 }
287
288 $deleteHref = $ilCtrl->getLinkTarget($this->parent_obj, ilAssQuestionHintsGUI::CMD_CONFIRM_DELETE);
289 $deleteHref = ilUtil::appendUrlParameterString($deleteHref, "hint_id={$rowData['hint_id']}", true);
290 $list->addItem($lng->txt('tst_question_hints_table_link_delete_hint'), '', $deleteHref);
291
292 $this->tpl->setVariable('ACTIONS', $list->getHTML());
293
294 $this->tpl->setVariable('HINT_ID', $rowData['hint_id']);
295
296 $hintIndex = $rowData['hint_index'] * self::INDEX_TO_POSITION_FACTOR;
297 } else {
298 $showHref = $this->parent_obj->getHintPresentationLinkTarget($rowData['hint_id']);
299
300 $this->tpl->setVariable('HINT_HREF', $showHref);
301
302 $hintIndex = ilAssQuestionHint::getHintIndexLabel($lng, $rowData['hint_index']);
303 }
304
305 $this->tpl->setVariable('HINT_INDEX', $hintIndex);
306 $txt = ilUtil::prepareTextareaOutput($rowData['hint_text'], true);
307 $this->tpl->setVariable('HINT_TEXT', $txt);
308 $this->tpl->setVariable('HINT_POINTS', $rowData['hint_points']);
309 }
310}
sprintf('%.4f', $callTime)
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.
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.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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,...
$key
Definition: croninfo.php:18
$txt
Definition: error.php:11
global $ilCtrl
Definition: ilias.php:18
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41