ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
10 {
14  const CONTEXT_SHORT = 1;
15 
19  const CONTEXT_LONG = 2;
20 
24  protected $pdf_view = false;
25 
31  public function __construct($parent, $cmd, $context = self::CONTEXT_SHORT, $pdf_view = false)
32  {
33  $this->pdf_view = $pdf_view;
34 
35  $this->setId('tst_pass_overview_' . $context . '_' . $parent->object->getId());
36  $this->setDefaultOrderField('pass');
37  $this->setDefaultOrderDirection('ASC');
38 
40 
41  // 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.
42  $this->setLimit(PHP_INT_MAX);
43  if($this->pdf_view)
44  {
45  $this->disable('linkbar');
46  $this->disable('numinfo');
47  $this->disable('numinfo_header');
48  $this->disable('hits');
49  }
50  $this->disable('sort');
51 
52  $this->initColumns();
53  $this->setRowTemplate('tpl.il_as_tst_pass_overview_row.html', 'Modules/Test');
54  }
55 
60  public function numericOrdering($field)
61  {
62  switch($field)
63  {
64  case 'pass':
65  case 'date':
66  case 'percentage':
67  return true;
68  }
69 
70  return false;
71  }
72 
76  public function fillRow(array $row)
77  {
80  $row['date'] = ilDatePresentation::formatDate(new ilDateTime($row['date'], IL_CAL_UNIX));
82 
83  if(array_key_exists('percentage', $row))
84  {
85  $row['percentage'] = sprintf('%.2f', $row['percentage']) . '%';
86  }
87 
88  if($this->pdf_view && array_key_exists('pass_details', $row))
89  {
90  unset($row['pass_details']);
91  }
92 
93  parent::fillRow($row);
94  }
95 
99  protected function initColumns()
100  {
101  if(self::CONTEXT_LONG == $this->getContext())
102  {
103  $this->addColumn($this->lng->txt('scored_pass'), '', '150');
104  }
105  $this->addColumn($this->lng->txt('pass'), '', '1%');
106  $this->addColumn($this->lng->txt('date'));
107  if(self::CONTEXT_LONG == $this->getContext())
108  {
109  $this->addColumn($this->lng->txt('tst_answered_questions'));
110  if($this->getParentObject()->object->isOfferingQuestionHintsEnabled())
111  {
112  $this->addColumn($this->lng->txt('tst_question_hints_requested_hint_count_header'));
113  }
114  $this->addColumn($this->lng->txt('tst_reached_points'));
115  $this->addColumn($this->lng->txt('tst_percent_solved'));
116  }
117  // pass details menu
118  if(!$this->pdf_view)
119  {
120  $this->addColumn('', '', '1%');
121  }
122  }
123 }