ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTestPassDetailsOverviewTableGUI.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';
6
16{
17 private $singleAnswerScreenCmd = null;
18
19 private $answerListAnchorEnabled = false;
20
21 private $showHintCount = false;
22
23 private $showSuggestedSolution = false;
24
25 private $activeId = null;
26
27 private $pass = null;
28
30
31 private $tableIdsByParentClasses = array(
32 'ilTestEvaluationGUI' => 1,
33 'ilTestServiceGUI' => 2
34 );
35
36 public function __construct(ilCtrl $ctrl, $parent, $cmd)
37 {
38 $tableId = 0;
39 if( isset($this->tableIdsByParentClasses[get_class($parent)]) )
40 {
41 $tableId = $this->tableIdsByParentClasses[get_class($parent)];
42 }
43
44 $this->ctrl = $ctrl;
45
46 $this->setId('tst_pdo_'.$tableId);
47 $this->setPrefix('tst_pdo_'.$tableId);
48
49 $this->setDefaultOrderField('nr');
50 $this->setDefaultOrderDirection('ASC');
51
52 parent::__construct($parent, $cmd);
53
54 $this->setFormName('tst_pass_details_overview');
55 $this->setFormAction($this->ctrl->getFormAction($parent, $cmd));
56
57 // Don't set any limit because of print/pdf views.
58 $this->setLimit(PHP_INT_MAX);
59 $this->setExternalSegmentation(true);
60
61 $this->disable('linkbar');
62 $this->disable('hits');
63 $this->disable('sort');
64
65 //$this->disable('numinfo');
66 //$this->disable('numinfo_header');
67 // KEEP THIS ENABLED, SINCE NO TABLE FILTER ARE PROVIDED OTHERWISE
68
69
70 $this->setTitle($this->lng->txt('tst_pass_details_overview_table_title'));
71
72 $this->setRowTemplate('tpl.il_as_tst_pass_details_overview_qst_row.html', 'Modules/Test');
73 }
74
78 public function initColumns()
79 {
80 $this->setTitle(sprintf(
81 $this->lng->txt('tst_pass_details_overview_table_title'), $this->getPass() + 1
82 ));
83
84 $this->addColumn($this->lng->txt("tst_question_no"), '', '');
85 $this->addColumn($this->lng->txt("question_id"), '', '');
86 $this->addColumn($this->lng->txt("tst_question_title"), '', '');
87 $this->addColumn($this->lng->txt("tst_maximum_points"), '', '');
88 $this->addColumn($this->lng->txt("tst_reached_points"), '', '');
89
90 if( $this->getShowHintCount() )
91 {
92 $this->addColumn($this->lng->txt("tst_question_hints_requested_hint_count_header"), '', '');
93 }
94
95 $this->addColumn($this->lng->txt("tst_percent_solved"), '', '');
96
97 if( $this->getShowSuggestedSolution() )
98 {
99 $this->addColumn($this->lng->txt("solution_hint"), '', '');
100 }
101
102 if( $this->areActionListsRequired() )
103 {
104 $this->addColumn('', '', '1');
105 }
106
107 return $this;
108 }
109
113 public function initFilter()
114 {
115 if( count($this->parent_obj->object->getResultFilterTaxIds()) )
116 {
117 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
118
119 foreach($this->parent_obj->object->getResultFilterTaxIds() as $taxId)
120 {
121 $postvar = "tax_$taxId";
122
123 $inp = new ilTaxSelectInputGUI($taxId, $postvar, true);
124 $this->addFilterItem($inp);
125 $inp->readFromSession();
126 $this->filter[$postvar] = $inp->getValue();
127 }
128 }
129
130 return $this;
131 }
132
136 public function isPdfGenerationRequest()
137 {
139 }
140
144 public function setIsPdfGenerationRequest($is_print_request)
145 {
146 $this->is_pdf_generation_request = $is_print_request;
147 }
148
149 public function fillRow(array $row)
150 {
151 $this->ctrl->setParameter($this->parent_obj, 'evaluation', $row['qid']);
152
153 if( $this->isQuestionTitleLinkPossible() )
154 {
155 $questionTitleLink = $this->getQuestionTitleLink($row['qid']);
156
157 if( strlen($questionTitleLink) )
158 {
159 $this->tpl->setVariable('URL_QUESTION_TITLE', $questionTitleLink);
160
161 $this->tpl->setCurrentBlock('title_link_end_tag');
162 $this->tpl->touchBlock('title_link_end_tag');
163 $this->tpl->parseCurrentBlock();
164 }
165 }
166
167 if( $this->getShowHintCount() )
168 {
169 $this->tpl->setVariable('VALUE_HINT_COUNT', (int)$row['requested_hints']);
170 }
171
172 if( $this->getShowSuggestedSolution() )
173 {
174 $this->tpl->setVariable('SOLUTION_HINT', $row['solution']);
175 }
176
177 if( $this->areActionListsRequired() )
178 {
179 $this->tpl->setVariable('ACTIONS_MENU', $this->getActionList($row['qid']));
180 }
181
182 $this->tpl->setVariable('VALUE_QUESTION_TITLE', $row['title']);
183 $this->tpl->setVariable('VALUE_QUESTION_ID', $row['qid']);
184 $this->tpl->setVariable('VALUE_QUESTION_COUNTER', $row['nr']);
185 $this->tpl->setVariable('VALUE_MAX_POINTS', $row['max']);
186 $this->tpl->setVariable('VALUE_REACHED_POINTS', $row['reached']);
187 $this->tpl->setVariable('VALUE_PERCENT_SOLVED', $row['percent']);
188
189 $this->tpl->setVariable('ROW_ID', $this->getRowId($row['qid']));
190 }
191
192 private function getRowId($questionId)
193 {
194 return "pass_details_tbl_row_act_{$this->getActiveId()}_qst_{$questionId}";
195 }
196
197 private function getQuestionTitleLink($questionId)
198 {
199 if( $this->getAnswerListAnchorEnabled() )
200 {
201 return $this->getAnswerListAnchor($questionId);
202 }
203
204 if( strlen($this->getSingleAnswerScreenCmd()) )
205 {
206 return $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd());
207 }
208
209 return '';
210 }
211
213 {
214 if( $this->getAnswerListAnchorEnabled() )
215 {
216 return true;
217 }
218
219 if( strlen($this->getSingleAnswerScreenCmd()) )
220 {
221 return true;
222 }
223
224 return false;
225 }
226
227 private function areActionListsRequired()
228 {
229 if( $this->isPdfGenerationRequest() )
230 {
231 return false;
232 }
233
234 if( !$this->getAnswerListAnchorEnabled() )
235 {
236 return false;
237 }
238
239 if( !strlen($this->getSingleAnswerScreenCmd()) )
240 {
241 return false;
242 }
243
244 return true;
245 }
246
247 private function getActionList($questionId)
248 {
249 $aslGUI = new ilAdvancedSelectionListGUI();
250 $aslGUI->setListTitle($this->lng->txt('tst_answer_details'));
251 $aslGUI->setId("act{$this->getActiveId()}_qst{$questionId}");
252
253 if( $this->getAnswerListAnchorEnabled() )
254 {
255 $aslGUI->addItem(
256 $this->lng->txt('tst_list_answer_details'), 'tst_pass_details', $this->getAnswerListAnchor($questionId)
257 );
258 }
259
260 if( strlen($this->getSingleAnswerScreenCmd()) )
261 {
262 $aslGUI->addItem(
263 $this->lng->txt('tst_single_answer_details'), 'tst_pass_details',
264 $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd())
265 );
266 }
267
268 return $aslGUI->getHTML();
269 }
270
272 {
273 $this->singleAnswerScreenCmd = $singleAnswerScreenCmd;
274 }
275
276 public function getSingleAnswerScreenCmd()
277 {
279 }
280
282 {
283 $this->answerListAnchorEnabled = $answerListAnchorEnabled;
284 }
285
287 {
289 }
290
291 private function getAnswerListAnchor($questionId)
292 {
293 return "#detailed_answer_block_act_{$this->getActiveId()}_qst_{$questionId}";
294 }
295
297 {
298 // Has to be called before column initialization
299 $this->showHintCount = $showHintCount;
300 }
301
302 public function getShowHintCount()
303 {
305 }
306
308 {
309 $this->showSuggestedSolution = $showSuggestedSolution;
310 }
311
312 public function getShowSuggestedSolution()
313 {
315 }
316
317 public function setActiveId($activeId)
318 {
319 $this->activeId = $activeId;
320 }
321
322 public function getActiveId()
323 {
324 return $this->activeId;
325 }
326
327 public function setPass($pass)
328 {
329 $this->pass = $pass;
330 }
331
332 public function getPass()
333 {
334 return $this->pass;
335 }
336}
User interface class for advanced drop-down selection lists.
This class provides processing control methods.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
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.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormName($a_formname)
Set Form name.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
disable($a_module_name)
diesables particular modules of table
setLimit($a_limit=0, $a_default_limit=0)
set max.
Select taxonomy nodes input GUI.
$cmd
Definition: sahs_server.php:35