ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilQuestionPoolPrintViewTableGUI.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 include_once('./Services/Table/classes/class.ilTable2GUI.php');
5 
15 {
16  protected $outputmode;
17 
18  protected $totalPoints;
19 
27  public function __construct($a_parent_obj, $a_parent_cmd, $outputmode = '')
28  {
29  $this->setId("qpl_print");
30  parent::__construct($a_parent_obj, $a_parent_cmd);
31 
32  global $DIC;
33  $lng = $DIC['lng'];
34  $ilCtrl = $DIC['ilCtrl'];
35 
36  $this->lng = $lng;
37  $this->ctrl = $ilCtrl;
38  $this->outputmode = $outputmode;
39 
40  $this->setFormName('printviewform');
41  $this->setStyle('table', 'fullwidth');
42 
43  $this->addCommandButton('print', $this->lng->txt('print'), "javascript:window.print();return false;");
44 
45  $this->setRowTemplate("tpl.il_as_qpl_printview_row.html", "Modules/TestQuestionPool");
46 
47  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
48  $this->setDefaultOrderField("title");
49  $this->setDefaultOrderDirection("asc");
50  $this->setLimit(999);
51 
52  $this->enable('sort');
53  $this->enable('header');
54  // $this->disable('numinfo');
55  $this->disable('select_all');
56  }
57 
58  public function initColumns()
59  {
60  $this->addColumn($this->lng->txt("title"), 'title', '');
61 
62  foreach ($this->getSelectedColumns() as $c) {
63  if (strcmp($c, 'description') == 0) {
64  $this->addColumn($this->lng->txt("description"), 'description', '');
65  }
66  if (strcmp($c, 'author') == 0) {
67  $this->addColumn($this->lng->txt("author"), 'author', '');
68  }
69  if (strcmp($c, 'ttype') == 0) {
70  $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
71  }
72  if (strcmp($c, 'points') == 0) {
73  $this->addColumn($this->getPointsColumnHeader(), 'points', '');
74  }
75  if (strcmp($c, 'created') == 0) {
76  $this->addColumn($this->lng->txt("create_date"), 'created', '');
77  }
78  if (strcmp($c, 'updated') == 0) {
79  $this->addColumn($this->lng->txt("last_update"), 'updated', '');
80  }
81  }
82  }
83 
84  private function getPointsColumnHeader()
85  {
86  return $this->lng->txt("points") . ' (' . $this->getTotalPoints() . ')';
87  }
88 
89  public function getSelectableColumns()
90  {
91  global $DIC;
92  $lng = $DIC['lng'];
93  $cols["description"] = array(
94  "txt" => $lng->txt("description"),
95  "default" => true
96  );
97  $cols["author"] = array(
98  "txt" => $lng->txt("author"),
99  "default" => true
100  );
101  $cols["ttype"] = array(
102  "txt" => $lng->txt("question_type"),
103  "default" => true
104  );
105  $cols["points"] = array(
106  "txt" => $lng->txt("points"),
107  "default" => true
108  );
109  $cols["created"] = array(
110  "txt" => $lng->txt("create_date"),
111  "default" => true
112  );
113  $cols["updated"] = array(
114  "txt" => $lng->txt("last_update"),
115  "default" => true
116  );
117  return $cols;
118  }
119 
127  public function fillRow($data)
128  {
130  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title']));
131  foreach ($this->getSelectedColumns() as $c) {
132  if (strcmp($c, 'description') == 0) {
133  $this->tpl->setCurrentBlock('description');
134  $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
135  $this->tpl->parseCurrentBlock();
136  }
137  if (strcmp($c, 'author') == 0) {
138  $this->tpl->setCurrentBlock('author');
139  $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author']));
140  $this->tpl->parseCurrentBlock();
141  }
142  if (strcmp($c, 'ttype') == 0) {
143  $this->tpl->setCurrentBlock('ttype');
144  $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype']));
145  $this->tpl->parseCurrentBlock();
146  }
147  if (strcmp($c, 'points') == 0) {
148  $this->tpl->setCurrentBlock('points');
149  $this->tpl->setVariable("POINTS", ilUtil::prepareFormOutput($data['points']));
150  $this->tpl->parseCurrentBlock();
151  }
152  if (strcmp($c, 'created') == 0) {
153  $this->tpl->setCurrentBlock('created');
154  $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
155  $this->tpl->parseCurrentBlock();
156  }
157  if (strcmp($c, 'updated') == 0) {
158  $this->tpl->setCurrentBlock('updated');
159  $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX)));
160  $this->tpl->parseCurrentBlock();
161  }
162  }
163  if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0)) {
164  $this->tpl->setCurrentBlock("overview_row_detail");
165  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
166  $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]);
167  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
168  if (strcmp($this->outputmode, "detailed") == 0) {
169  $solutionoutput = $question_gui->getSolutionOutput($active_id = "", $pass = null, $graphicalOutput = false, $result_output = false, $show_question_only = false, $show_feedback = false, $show_correct_solution = true, $show_manual_scoring = false);
170  if (strlen($solutionoutput) == 0) {
171  $solutionoutput = $question_gui->getPreview();
172  }
173  $this->tpl->setVariable("DETAILS", $solutionoutput);
174  $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
175  } else {
176  $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
177  $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
178  }
179  $this->tpl->parseCurrentBlock();
180  }
182  }
183 
188  public function numericOrdering($column)
189  {
190  if (in_array($column, array('points', 'created', 'updated'))) {
191  return true;
192  }
193 
194  return false;
195  }
196 
197  public function getTotalPoints()
198  {
199  return $this->totalPoints;
200  }
201 
202  public function setTotalPoints($totalPoints)
203  {
204  $this->totalPoints = $totalPoints;
205  }
206 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
__construct($a_parent_obj, $a_parent_cmd, $outputmode='')
Constructor.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setStyle($a_element, $a_style)
global $DIC
Definition: saml.php:7
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
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.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Class ilTable2GUI.
enable($a_module_name)
enables particular modules of table
Date and time handling
getSelectedColumns()
Get selected columns.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
$cols
Definition: xhr_table.php:11
setLimit($a_limit=0, $a_default_limit=0)