ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestPassOverviewTableGUI.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 
11 {
15  protected $resultPresentationEnabled = false;
16 
20  protected $pdfPresentationEnabled = false;
21 
26 
30  protected $activeId = null;
31 
35  protected $passDetailsCommand = '';
36 
40  protected $passDeletionCommand = '';
41 
47  public function __construct($parent, $cmd)
48  {
49  $this->setId('tst_pass_overview_' . $parent->object->getId());
50  $this->setDefaultOrderField('pass');
51  $this->setDefaultOrderDirection('ASC');
52 
53  parent::__construct($parent, $cmd);
54 
55  // Don't set any limit because of print/pdf views. Furthermore, this view is part of different summary views, and no cmd ist passed to he calling method.
56  $this->setLimit(PHP_INT_MAX);
57  $this->disable('sort');
58 
59  $this->setRowTemplate('tpl.il_as_tst_pass_overview_row.html', 'Modules/Test');
60  }
61 
62  public function init()
63  {
64  global $DIC;
65  $ilCtrl = $DIC['ilCtrl'];
66 
67  $ilCtrl->setParameter($this->parent_obj, 'active_id', $this->getActiveId());
68 
69  $this->initColumns();
70 
71  if ($this->isPdfPresentationEnabled()) {
72  $this->disable('linkbar');
73  $this->disable('numinfo');
74  $this->disable('numinfo_header');
75  $this->disable('hits');
76  }
77  }
78 
83  public function numericOrdering($field)
84  {
85  switch ($field) {
86  case 'pass':
87  case 'date':
88  case 'percentage':
89  return true;
90  }
91 
92  return false;
93  }
94 
98  public function fillRow($row)
99  {
100  if (array_key_exists('percentage', $row)) {
101  $row['percentage'] = sprintf('%.2f', $row['percentage']) . '%';
102  }
103 
104  // fill columns
105 
107  if ($this->isResultPresentationEnabled()) {
108  $this->tpl->setVariable('VAL_SCORED', $row['scored'] ? '&otimes;' : '');
109  }
110 
111  $this->tpl->setVariable('VAL_PASS', $this->getPassNumberPresentation($row['pass']));
112  }
113 
114  $this->tpl->setVariable('VAL_DATE', $this->formatDate($row['date']));
115 
117  $this->tpl->setVariable('VAL_LO_OBJECTIVES', $row['objectives']);
118 
119  $this->tpl->setVariable('VAL_LO_TRY', sprintf(
120  $this->lng->txt('tst_res_lo_try_n'),
121  $this->getPassNumberPresentation($row['pass'])
122  ));
123  }
124 
125  if ($this->isResultPresentationEnabled()) {
126  $this->tpl->setVariable('VAL_ANSWERED', $this->buildWorkedThroughQuestionsString(
127  $row['num_workedthrough_questions'],
128  $row['num_questions_total']
129  ));
130 
131  if ($this->getParentObject()->object->isOfferingQuestionHintsEnabled()) {
132  $this->tpl->setVariable('VAL_HINTS', $row['hints']);
133  }
134 
135  $this->tpl->setVariable('VAL_REACHED', $this->buildReachedPointsString(
136  $row['reached_points'],
137  $row['max_points']
138  ));
139 
140  $this->tpl->setVariable('VAL_PERCENTAGE', $row['percentage']);
141  }
142 
143  if (!$this->isPdfPresentationEnabled()) {
144  $actions = $this->getRequiredActions($row['scored']);
145  $this->tpl->setVariable('VAL_ACTIONS', $this->buildActionsHtml($actions, $row['pass']));
146  }
147  }
148 
149  protected function initColumns()
150  {
152  $this->addColumn($this->lng->txt('scored_pass'), '', '150');
153  }
154 
156  $this->addColumn($this->lng->txt('pass'), '', '1%');
157  }
158 
159  $this->addColumn($this->lng->txt('date'));
160 
162  $this->addColumn($this->lng->txt('tst_res_lo_objectives_header'), '');
163  $this->addColumn($this->lng->txt('tst_res_lo_try_header'), '');
164  }
165 
166  if ($this->isResultPresentationEnabled()) {
167  $this->addColumn($this->lng->txt('tst_answered_questions'));
168  if ($this->getParentObject()->object->isOfferingQuestionHintsEnabled()) {
169  $this->addColumn($this->lng->txt('tst_question_hints_requested_hint_count_header'));
170  }
171  $this->addColumn($this->lng->txt('tst_reached_points'));
172  $this->addColumn($this->lng->txt('tst_percent_solved'));
173  }
174 
175  // actions
176  if (!$this->isPdfPresentationEnabled()) {
177  $this->addColumn('', '', '10%');
178  }
179  }
180 
184  public function isResultPresentationEnabled()
185  {
187  }
188 
193  {
194  $this->resultPresentationEnabled = $resultPresentationEnabled;
195  }
196 
200  public function isPdfPresentationEnabled()
201  {
203  }
204 
209  {
210  $this->pdfPresentationEnabled = $pdfPresentationEnabled;
211  }
212 
217  {
219  }
220 
225  {
226  $this->objectiveOrientedPresentationEnabled = $objectiveOrientedPresentationEnabled;
227  }
228 
232  public function getActiveId()
233  {
234  return $this->activeId;
235  }
236 
240  public function setActiveId($activeId)
241  {
242  $this->activeId = $activeId;
243  }
244 
248  public function getPassDetailsCommand()
249  {
251  }
252 
257  {
258  $this->passDetailsCommand = $passDetailsCommand;
259  }
260 
264  public function getPassDeletionCommand()
265  {
267  }
268 
273  {
274  $this->passDeletionCommand = $passDeletionCommand;
275  }
276 
281  private function formatDate($date)
282  {
287  return $date;
288  }
289 
290  private function buildWorkedThroughQuestionsString($numQuestionsWorkedThrough, $numQuestionsTotal)
291  {
292  return "{$numQuestionsWorkedThrough} {$this->lng->txt('of')} {$numQuestionsTotal}";
293  }
294 
295  private function buildReachedPointsString($reachedPoints, $maxPoints)
296  {
297  return "{$reachedPoints} {$this->lng->txt('of')} {$maxPoints}";
298  }
299 
300  private function getRequiredActions($isScoredPass)
301  {
302  $actions = array();
303 
304  if ($this->getPassDetailsCommand()) {
305  $actions[$this->getPassDetailsCommand()] = $this->lng->txt('tst_pass_details');
306  }
307 
308  if (!$isScoredPass && $this->getPassDeletionCommand()) {
309  $actions[$this->getPassDeletionCommand()] = $this->lng->txt('delete');
310  }
311 
312  return $actions;
313  }
314 
315  private function buildActionsHtml($actions, $pass)
316  {
317  global $DIC;
318  $ilCtrl = $DIC['ilCtrl'];
319 
320  if (!count($actions)) {
321  return '';
322  }
323 
324  $ilCtrl->setParameter($this->parent_obj, 'pass', $pass);
325 
326  if (count($actions) > 1) {
327  $aslgui = new ilAdvancedSelectionListGUI();
328  $aslgui->setListTitle($this->lng->txt('actions'));
329  $aslgui->setId($pass);
330 
331  foreach ($actions as $cmd => $label) {
332  $aslgui->addItem($label, $cmd, $ilCtrl->getLinkTarget($this->parent_obj, $cmd));
333  }
334 
335  $html = $aslgui->getHTML();
336  } else {
337  $cmd = key($actions);
338  $label = current($actions);
339 
340  $href = $ilCtrl->getLinkTarget($this->parent_obj, $cmd);
341  $html = '<a href="' . $href . '">' . $label . '</a>';
342  }
343 
344  $ilCtrl->setParameter($this->parent_obj, 'pass', '');
345 
346  return $html;
347  }
348 
353  protected function getPassNumberPresentation($pass)
354  {
355  return $pass + 1;
356  }
357 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setPdfPresentationEnabled($pdfPresentationEnabled)
global $DIC
Definition: saml.php:7
static setUseRelativeDates($a_status)
set use relative dates
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
setId($a_val)
Set id.
buildReachedPointsString($reachedPoints, $maxPoints)
static useRelativeDates()
check if relative dates are used
setResultPresentationEnabled($resultPresentationEnabled)
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setObjectiveOrientedPresentationEnabled($objectiveOrientedPresentationEnabled)
Class ilTable2GUI.
Date and time handling
Class ilTestPassOverviewTableGUI.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$row
User interface class for advanced drop-down selection lists.
disable($a_module_name)
diesables particular modules of table
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.
buildWorkedThroughQuestionsString($numQuestionsWorkedThrough, $numQuestionsTotal)
$html
Definition: example_001.php:87
setLimit($a_limit=0, $a_default_limit=0)