ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng, $ilCtrl;
33 
34  $this->lng = $lng;
35  $this->ctrl = $ilCtrl;
36  $this->outputmode = $outputmode;
37 
38  $this->setFormName('printviewform');
39  $this->setStyle('table', 'fullwidth');
40 
41  $this->addCommandButton('print', $this->lng->txt('print'), "javascript:window.print();return false;");
42 
43  $this->setRowTemplate("tpl.il_as_qpl_printview_row.html", "Modules/TestQuestionPool");
44 
45  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
46  $this->setDefaultOrderField("title");
47  $this->setDefaultOrderDirection("asc");
48  $this->setLimit(999);
49 
50  $this->enable('sort');
51  $this->enable('header');
52  // $this->disable('numinfo');
53  $this->disable('select_all');
54  }
55 
56  public function initColumns()
57  {
58  $this->addColumn($this->lng->txt("title"), 'title', '');
59 
60  foreach ($this->getSelectedColumns() as $c) {
61  if (strcmp($c, 'description') == 0) {
62  $this->addColumn($this->lng->txt("description"), 'description', '');
63  }
64  if (strcmp($c, 'author') == 0) {
65  $this->addColumn($this->lng->txt("author"), 'author', '');
66  }
67  if (strcmp($c, 'ttype') == 0) {
68  $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
69  }
70  if (strcmp($c, 'points') == 0) {
71  $this->addColumn($this->getPointsColumnHeader(), 'points', '');
72  }
73  if (strcmp($c, 'created') == 0) {
74  $this->addColumn($this->lng->txt("create_date"), 'created', '');
75  }
76  if (strcmp($c, 'updated') == 0) {
77  $this->addColumn($this->lng->txt("last_update"), 'updated', '');
78  }
79  }
80  }
81 
82  private function getPointsColumnHeader()
83  {
84  return $this->lng->txt("points") . ' (' . $this->getTotalPoints() . ')';
85  }
86 
87  public function getSelectableColumns()
88  {
89  global $lng;
90  $cols["description"] = array(
91  "txt" => $lng->txt("description"),
92  "default" => true
93  );
94  $cols["author"] = array(
95  "txt" => $lng->txt("author"),
96  "default" => true
97  );
98  $cols["ttype"] = array(
99  "txt" => $lng->txt("question_type"),
100  "default" => true
101  );
102  $cols["points"] = array(
103  "txt" => $lng->txt("points"),
104  "default" => true
105  );
106  $cols["created"] = array(
107  "txt" => $lng->txt("create_date"),
108  "default" => true
109  );
110  $cols["updated"] = array(
111  "txt" => $lng->txt("last_update"),
112  "default" => true
113  );
114  return $cols;
115  }
116 
124  public function fillRow($data)
125  {
127  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title']));
128  foreach ($this->getSelectedColumns() as $c) {
129  if (strcmp($c, 'description') == 0) {
130  $this->tpl->setCurrentBlock('description');
131  $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
132  $this->tpl->parseCurrentBlock();
133  }
134  if (strcmp($c, 'author') == 0) {
135  $this->tpl->setCurrentBlock('author');
136  $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author']));
137  $this->tpl->parseCurrentBlock();
138  }
139  if (strcmp($c, 'ttype') == 0) {
140  $this->tpl->setCurrentBlock('ttype');
141  $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype']));
142  $this->tpl->parseCurrentBlock();
143  }
144  if (strcmp($c, 'points') == 0) {
145  $this->tpl->setCurrentBlock('points');
146  $this->tpl->setVariable("POINTS", ilUtil::prepareFormOutput($data['points']));
147  $this->tpl->parseCurrentBlock();
148  }
149  if (strcmp($c, 'created') == 0) {
150  $this->tpl->setCurrentBlock('created');
151  $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
152  $this->tpl->parseCurrentBlock();
153  }
154  if (strcmp($c, 'updated') == 0) {
155  $this->tpl->setCurrentBlock('updated');
156  $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX)));
157  $this->tpl->parseCurrentBlock();
158  }
159  }
160  if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0)) {
161  $this->tpl->setCurrentBlock("overview_row_detail");
162  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
163  $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]);
164  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
165  if (strcmp($this->outputmode, "detailed") == 0) {
166  $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);
167  if (strlen($solutionoutput) == 0) {
168  $solutionoutput = $question_gui->getPreview();
169  }
170  $this->tpl->setVariable("DETAILS", $solutionoutput);
171  $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
172  } else {
173  $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
174  $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
175  }
176  $this->tpl->parseCurrentBlock();
177  }
179  }
180 
185  public function numericOrdering($column)
186  {
187  if (in_array($column, array('points', 'created', 'updated'))) {
188  return true;
189  }
190 
191  return false;
192  }
193 
194  public function getTotalPoints()
195  {
196  return $this->totalPoints;
197  }
198 
199  public function setTotalPoints($totalPoints)
200  {
201  $this->totalPoints = $totalPoints;
202  }
203 }
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)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
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
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Class ilTable2GUI.
$column
Definition: 39dropdown.php:62
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.
Create styles array
The data for the language used.
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)