ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 require_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 $is_pdf_generation_request = false;
28 
30 
32 
33  private $passColumnEnabled = false;
34 
35  private $tableIdsByParentClasses = array(
36  'ilTestEvaluationGUI' => 1,
37  'ilTestServiceGUI' => 2
38  );
39 
44 
45  public function __construct(ilCtrl $ctrl, $parent, $cmd)
46  {
47  $tableId = 0;
48  if (isset($this->tableIdsByParentClasses[get_class($parent)])) {
49  $tableId = $this->tableIdsByParentClasses[get_class($parent)];
50  }
51 
52  $this->ctrl = $ctrl;
53 
54  $this->setId('tst_pdo_' . $tableId);
55  $this->setPrefix('tst_pdo_' . $tableId);
56 
57  $this->setDefaultOrderField('nr');
58  $this->setDefaultOrderDirection('ASC');
59 
60  parent::__construct($parent, $cmd);
61 
62  $this->setFormName('tst_pass_details_overview');
63  $this->setFormAction($this->ctrl->getFormAction($parent, $cmd));
64 
65  // Don't set any limit because of print/pdf views.
66  $this->setLimit(PHP_INT_MAX);
67  $this->setExternalSegmentation(true);
68 
69  $this->disable('linkbar');
70  $this->disable('hits');
71  $this->disable('sort');
72 
73  //$this->disable('numinfo');
74  //$this->disable('numinfo_header');
75  // KEEP THIS ENABLED, SINCE NO TABLE FILTER ARE PROVIDED OTHERWISE
76 
77  $this->setRowTemplate('tpl.il_as_tst_pass_details_overview_qst_row.html', 'Modules/Test');
78  }
79 
83  public function initColumns()
84  {
85  if ($this->isPassColumnEnabled()) {
87  $passHeaderLabel = $this->lng->txt("tst_attempt");
88  } else {
89  $passHeaderLabel = $this->lng->txt("pass");
90  }
91 
92  $this->addColumn($passHeaderLabel, 'pass', '');
93  } else {
94  $this->addColumn($this->lng->txt("tst_question_no"), '', '');
95  }
96 
97  $this->addColumn($this->lng->txt("question_id"), '', '');
98  $this->addColumn($this->lng->txt("tst_question_title"), '', '');
99 
101  $this->addColumn($this->lng->txt('tst_res_lo_objectives_header'), '', '');
102  }
103 
104  $this->addColumn($this->lng->txt("tst_maximum_points"), '', '');
105  $this->addColumn($this->lng->txt("tst_reached_points"), '', '');
106 
107  if ($this->getShowHintCount()) {
108  $this->addColumn($this->lng->txt("tst_question_hints_requested_hint_count_header"), '', '');
109  }
110 
111  $this->addColumn($this->lng->txt("tst_percent_solved"), '', '');
112 
113  if ($this->getShowSuggestedSolution()) {
114  $this->addColumn($this->lng->txt("solution_hint"), '', '');
115  }
116 
117  if ($this->areActionListsRequired()) {
118  $this->addColumn('', '', '1');
119  }
120 
121  return $this;
122  }
123 
127  public function initFilter()
128  {
129  if (count($this->parent_obj->object->getResultFilterTaxIds())) {
130  require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
131 
132  foreach ($this->parent_obj->object->getResultFilterTaxIds() as $taxId) {
133  $postvar = "tax_$taxId";
134 
135  $inp = new ilTaxSelectInputGUI($taxId, $postvar, true);
136  $this->addFilterItem($inp);
137  $inp->readFromSession();
138  $this->filter[$postvar] = $inp->getValue();
139  }
140  }
141 
142  return $this;
143  }
144 
148  public function isPdfGenerationRequest()
149  {
151  }
152 
156  public function setIsPdfGenerationRequest($is_print_request)
157  {
158  $this->is_pdf_generation_request = $is_print_request;
159  }
160 
164  public function fillRow($row)
165  {
166  $this->ctrl->setParameter($this->parent_obj, 'evaluation', $row['qid']);
167 
168  if (isset($row['pass'])) {
169  $this->ctrl->setParameter($this->parent_obj, 'pass', $row['pass']);
170  }
171 
172  if ($this->isQuestionTitleLinkPossible()) {
173  $questionTitleLink = $this->getQuestionTitleLink($row['qid']);
174 
175  if (strlen($questionTitleLink)) {
176  $this->tpl->setVariable('URL_QUESTION_TITLE', $questionTitleLink);
177 
178  $this->tpl->setCurrentBlock('title_link_end_tag');
179  $this->tpl->touchBlock('title_link_end_tag');
180  $this->tpl->parseCurrentBlock();
181  }
182  }
183 
185  $objectives = $this->questionRelatedObjectivesList->getQuestionRelatedObjectiveTitles($row['qid']);
186  $this->tpl->setVariable('VALUE_LO_OBJECTIVES', strlen($objectives) ? $objectives : '&nbsp;');
187  }
188 
189  if ($this->getShowHintCount()) {
190  $this->tpl->setVariable('VALUE_HINT_COUNT', (int) $row['requested_hints']);
191  }
192 
193  if ($this->getShowSuggestedSolution()) {
194  $this->tpl->setVariable('SOLUTION_HINT', $row['solution']);
195  }
196 
197  if ($this->areActionListsRequired()) {
198  $this->tpl->setVariable('ACTIONS_MENU', $this->getActionList($row['qid']));
199  }
200 
201  $this->tpl->setVariable('VALUE_QUESTION_TITLE', $row['title']);
202  $this->tpl->setVariable('VALUE_QUESTION_ID', $row['qid']);
203 
204  if ($this->isPassColumnEnabled()) {
205  $this->tpl->setVariable('VALUE_QUESTION_PASS', $row['pass'] + 1);
206  } else {
207  $this->tpl->setVariable('VALUE_QUESTION_COUNTER', $row['nr']);
208  }
209 
210  $this->tpl->setVariable('VALUE_MAX_POINTS', $row['max']);
211  $this->tpl->setVariable('VALUE_REACHED_POINTS', $row['reached']);
212  $this->tpl->setVariable('VALUE_PERCENT_SOLVED', $row['percent']);
213 
214  $this->tpl->setVariable('ROW_ID', $this->getRowId($row['qid']));
215  }
216 
217  private function getRowId($questionId)
218  {
219  return "pass_details_tbl_row_act_{$this->getActiveId()}_qst_{$questionId}";
220  }
221 
222  private function getQuestionTitleLink($questionId)
223  {
224  if ($this->getAnswerListAnchorEnabled()) {
225  return $this->getAnswerListAnchor($questionId);
226  }
227 
228  if (strlen($this->getSingleAnswerScreenCmd())) {
229  return $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd());
230  }
231 
232  return '';
233  }
234 
235  private function isQuestionTitleLinkPossible()
236  {
237  if ($this->getAnswerListAnchorEnabled()) {
238  return true;
239  }
240 
241  if (strlen($this->getSingleAnswerScreenCmd())) {
242  return true;
243  }
244 
245  return false;
246  }
247 
248  private function areActionListsRequired()
249  {
250  if ($this->isPdfGenerationRequest()) {
251  return false;
252  }
253 
254  if (!$this->getAnswerListAnchorEnabled()) {
255  return false;
256  }
257 
258  if (!strlen($this->getSingleAnswerScreenCmd())) {
259  return false;
260  }
261 
262  return true;
263  }
264 
265  private function getActionList($questionId)
266  {
267  $aslGUI = new ilAdvancedSelectionListGUI();
268  $aslGUI->setListTitle($this->lng->txt('tst_answer_details'));
269  $aslGUI->setId("act{$this->getActiveId()}_qst{$questionId}");
270 
271  if ($this->getAnswerListAnchorEnabled()) {
272  $aslGUI->addItem(
273  $this->lng->txt('tst_list_answer_details'),
274  'tst_pass_details',
275  $this->getAnswerListAnchor($questionId)
276  );
277  }
278 
279  if (strlen($this->getSingleAnswerScreenCmd())) {
280  $aslGUI->addItem(
281  $this->lng->txt('tst_single_answer_details'),
282  'tst_pass_details',
283  $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd())
284  );
285  }
286 
287  return $aslGUI->getHTML();
288  }
289 
291  {
292  $this->singleAnswerScreenCmd = $singleAnswerScreenCmd;
293  }
294 
295  public function getSingleAnswerScreenCmd()
296  {
298  }
299 
301  {
302  $this->answerListAnchorEnabled = $answerListAnchorEnabled;
303  }
304 
305  public function getAnswerListAnchorEnabled()
306  {
308  }
309 
310  private function getAnswerListAnchor($questionId)
311  {
312  return "#detailed_answer_block_act_{$this->getActiveId()}_qst_{$questionId}";
313  }
314 
316  {
317  // Has to be called before column initialization
318  $this->showHintCount = $showHintCount;
319  }
320 
321  public function getShowHintCount()
322  {
323  return $this->showHintCount;
324  }
325 
327  {
328  $this->showSuggestedSolution = $showSuggestedSolution;
329  }
330 
331  public function getShowSuggestedSolution()
332  {
334  }
335 
336  public function setActiveId($activeId)
337  {
338  $this->activeId = $activeId;
339  }
340 
341  public function getActiveId()
342  {
343  return $this->activeId;
344  }
345 
350  {
352  }
353 
358  {
359  $this->objectiveOrientedPresentationEnabled = $objectiveOrientedPresentationEnabled;
360  }
361 
366  {
368  }
369 
374  {
375  $this->multipleObjectivesInvolved = $multipleObjectivesInvolved;
376  }
377 
382  {
384  }
385 
390  {
391  $this->questionRelatedObjectivesList = $questionRelatedObjectivesList;
392  }
393 
397  public function isPassColumnEnabled()
398  {
400  }
401 
406  {
407  $this->passColumnEnabled = $passColumnEnabled;
408  }
409 }
This class provides processing control methods.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Select taxonomy nodes input GUI.
setQuestionRelatedObjectivesList($questionRelatedObjectivesList)
setObjectiveOrientedPresentationEnabled($objectiveOrientedPresentationEnabled)
setExternalSegmentation($a_val)
Set external segmentation.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Class ilTable2GUI.
setPrefix($a_prefix)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$row
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
setFormName($a_formname="")
Set Form name.
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.
setLimit($a_limit=0, $a_default_limit=0)