ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $pass = null;
28 
29  private $is_pdf_generation_request = false;
30 
31  public function __construct(ilCtrl $ctrl, $parent, $cmd)
32  {
33  $this->ctrl = $ctrl;
34 
35  $this->setId('tst_pass_details_overview');
36  $this->setPrefix('tst_pass_details_overview');
37 
38  $this->setDefaultOrderField('nr');
39  $this->setDefaultOrderDirection('ASC');
40 
41  parent::__construct($parent, $cmd);
42 
43  $this->setFormName('tst_pass_details_overview');
44  $this->setFormAction($this->ctrl->getFormAction($parent, $cmd));
45 
46  // Don't set any limit because of print/pdf views.
47  $this->setLimit(PHP_INT_MAX);
48  $this->setExternalSegmentation(true);
49 
50  $this->disable('linkbar');
51  $this->disable('hits');
52  $this->disable('sort');
53 
54  //$this->disable('numinfo');
55  //$this->disable('numinfo_header');
56  // KEEP THIS ENABLED, SINCE NO TABLE FILTER ARE PROVIDED OTHERWISE
57 
58 
59  $this->setTitle($this->lng->txt('tst_pass_details_overview_table_title'));
60 
61  $this->setRowTemplate('tpl.il_as_tst_pass_details_overview_qst_row.html', 'Modules/Test');
62  }
63 
67  public function initColumns()
68  {
69  $this->setTitle(sprintf(
70  $this->lng->txt('tst_pass_details_overview_table_title'), $this->getPass() + 1
71  ));
72 
73  $this->addColumn($this->lng->txt("tst_question_no"), '', '');
74  $this->addColumn($this->lng->txt("question_id"), '', '');
75  $this->addColumn($this->lng->txt("tst_question_title"), '', '');
76  $this->addColumn($this->lng->txt("tst_maximum_points"), '', '');
77  $this->addColumn($this->lng->txt("tst_reached_points"), '', '');
78 
79  if( $this->getShowHintCount() )
80  {
81  $this->addColumn($this->lng->txt("tst_question_hints_requested_hint_count_header"), '', '');
82  }
83 
84  $this->addColumn($this->lng->txt("tst_percent_solved"), '', '');
85 
86  if( $this->getShowSuggestedSolution() )
87  {
88  $this->addColumn($this->lng->txt("solution_hint"), '', '');
89  }
90 
91  if( $this->areActionListsRequired() )
92  {
93  $this->addColumn('', '', '1');
94  }
95 
96  return $this;
97  }
98 
102  public function initFilter()
103  {
104  if( count($this->parent_obj->object->getResultFilterTaxIds()) )
105  {
106  require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
107 
108  foreach($this->parent_obj->object->getResultFilterTaxIds() as $taxId)
109  {
110  $postvar = "tax_$taxId";
111 
112  $inp = new ilTaxSelectInputGUI($taxId, $postvar, true);
113  $this->addFilterItem($inp);
114  $inp->readFromSession();
115  $this->filter[$postvar] = $inp->getValue();
116  }
117  }
118 
119  return $this;
120  }
121 
125  public function isPdfGenerationRequest()
126  {
128  }
129 
133  public function setIsPdfGenerationRequest($is_print_request)
134  {
135  $this->is_pdf_generation_request = $is_print_request;
136  }
137 
138  public function fillRow(array $row)
139  {
140  $this->ctrl->setParameter($this->parent_obj, 'evaluation', $row['qid']);
141 
142  if( $this->isQuestionTitleLinkPossible() )
143  {
144  $questionTitleLink = $this->getQuestionTitleLink($row['qid']);
145 
146  if( strlen($questionTitleLink) )
147  {
148  $this->tpl->setVariable('URL_QUESTION_TITLE', $questionTitleLink);
149 
150  $this->tpl->setCurrentBlock('title_link_end_tag');
151  $this->tpl->touchBlock('title_link_end_tag');
152  $this->tpl->parseCurrentBlock();
153  }
154  }
155 
156  if( $this->getShowHintCount() )
157  {
158  $this->tpl->setVariable('VALUE_HINT_COUNT', (int)$row['requested_hints']);
159  }
160 
161  if( $this->getShowSuggestedSolution() )
162  {
163  $this->tpl->setVariable('SOLUTION_HINT', $row['solution']);
164  }
165 
166  if( $this->areActionListsRequired() )
167  {
168  $this->tpl->setVariable('ACTIONS_MENU', $this->getActionList($row['qid']));
169  }
170 
171  $this->tpl->setVariable('VALUE_QUESTION_TITLE', $row['title']);
172  $this->tpl->setVariable('VALUE_QUESTION_ID', $row['qid']);
173  $this->tpl->setVariable('VALUE_QUESTION_COUNTER', $row['nr']);
174  $this->tpl->setVariable('VALUE_MAX_POINTS', $row['max']);
175  $this->tpl->setVariable('VALUE_REACHED_POINTS', $row['reached']);
176  $this->tpl->setVariable('VALUE_PERCENT_SOLVED', $row['percent']);
177 
178  $this->tpl->setVariable('ROW_ID', $this->getRowId($row['qid']));
179  }
180 
181  private function getRowId($questionId)
182  {
183  return "pass_details_tbl_row_act_{$this->getActiveId()}_qst_{$questionId}";
184  }
185 
186  private function getQuestionTitleLink($questionId)
187  {
188  if( $this->getAnswerListAnchorEnabled() )
189  {
190  return $this->getAnswerListAnchor($questionId);
191  }
192 
193  if( strlen($this->getSingleAnswerScreenCmd()) )
194  {
195  return $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd());
196  }
197 
198  return '';
199  }
200 
201  private function isQuestionTitleLinkPossible()
202  {
203  if( $this->getAnswerListAnchorEnabled() )
204  {
205  return true;
206  }
207 
208  if( strlen($this->getSingleAnswerScreenCmd()) )
209  {
210  return true;
211  }
212 
213  return false;
214  }
215 
216  private function areActionListsRequired()
217  {
218  if( $this->isPdfGenerationRequest() )
219  {
220  return false;
221  }
222 
223  if( !$this->getAnswerListAnchorEnabled() )
224  {
225  return false;
226  }
227 
228  if( !strlen($this->getSingleAnswerScreenCmd()) )
229  {
230  return false;
231  }
232 
233  return true;
234  }
235 
236  private function getActionList($questionId)
237  {
238  $aslGUI = new ilAdvancedSelectionListGUI();
239  $aslGUI->setListTitle($this->lng->txt('tst_answer_details'));
240  $aslGUI->setId("act{$this->getActiveId()}_qst{$questionId}");
241 
242  if( $this->getAnswerListAnchorEnabled() )
243  {
244  $aslGUI->addItem(
245  $this->lng->txt('tst_list_answer_details'), 'tst_pass_details', $this->getAnswerListAnchor($questionId)
246  );
247  }
248 
249  if( strlen($this->getSingleAnswerScreenCmd()) )
250  {
251  $aslGUI->addItem(
252  $this->lng->txt('tst_single_answer_details'), 'tst_pass_details',
253  $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd())
254  );
255  }
256 
257  return $aslGUI->getHTML();
258  }
259 
261  {
262  $this->singleAnswerScreenCmd = $singleAnswerScreenCmd;
263  }
264 
265  public function getSingleAnswerScreenCmd()
266  {
268  }
269 
271  {
272  $this->answerListAnchorEnabled = $answerListAnchorEnabled;
273  }
274 
275  public function getAnswerListAnchorEnabled()
276  {
278  }
279 
280  private function getAnswerListAnchor($questionId)
281  {
282  return "#detailed_answer_block_act_{$this->getActiveId()}_qst_{$questionId}";
283  }
284 
286  {
287  // Has to be called before column initialization
288  $this->showHintCount = $showHintCount;
289  }
290 
291  public function getShowHintCount()
292  {
293  return $this->showHintCount;
294  }
295 
297  {
298  $this->showSuggestedSolution = $showSuggestedSolution;
299  }
300 
301  public function getShowSuggestedSolution()
302  {
304  }
305 
306  public function setActiveId($activeId)
307  {
308  $this->activeId = $activeId;
309  }
310 
311  public function getActiveId()
312  {
313  return $this->activeId;
314  }
315 
316  public function setPass($pass)
317  {
318  $this->pass = $pass;
319  }
320 
321  public function getPass()
322  {
323  return $this->pass;
324  }
325 }