ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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  {
62  if (strcmp($c, 'description') == 0) $this->addColumn($this->lng->txt("description"),'description', '');
63  if (strcmp($c, 'author') == 0) $this->addColumn($this->lng->txt("author"),'author', '');
64  if (strcmp($c, 'ttype') == 0) $this->addColumn($this->lng->txt("question_type"),'ttype', '');
65  if (strcmp($c, 'points') == 0) $this->addColumn($this->getPointsColumnHeader(),'points', '');
66  if (strcmp($c, 'created') == 0) $this->addColumn($this->lng->txt("create_date"),'created', '');
67  if (strcmp($c, 'updated') == 0) $this->addColumn($this->lng->txt("last_update"),'updated', '');
68  }
69  }
70 
71  private function getPointsColumnHeader()
72  {
73  return $this->lng->txt("points") . ' ('.$this->getTotalPoints().')';
74  }
75 
77  {
78  global $lng;
79  $cols["description"] = array(
80  "txt" => $lng->txt("description"),
81  "default" => true
82  );
83  $cols["author"] = array(
84  "txt" => $lng->txt("author"),
85  "default" => true
86  );
87  $cols["ttype"] = array(
88  "txt" => $lng->txt("question_type"),
89  "default" => true
90  );
91  $cols["points"] = array(
92  "txt" => $lng->txt("points"),
93  "default" => true
94  );
95  $cols["created"] = array(
96  "txt" => $lng->txt("create_date"),
97  "default" => true
98  );
99  $cols["updated"] = array(
100  "txt" => $lng->txt("last_update"),
101  "default" => true
102  );
103  return $cols;
104  }
105 
113  public function fillRow($data)
114  {
116  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title']));
117  foreach ($this->getSelectedColumns() as $c)
118  {
119  if (strcmp($c, 'description') == 0)
120  {
121  $this->tpl->setCurrentBlock('description');
122  $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
123  $this->tpl->parseCurrentBlock();
124  }
125  if (strcmp($c, 'author') == 0)
126  {
127  $this->tpl->setCurrentBlock('author');
128  $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author']));
129  $this->tpl->parseCurrentBlock();
130  }
131  if (strcmp($c, 'ttype') == 0)
132  {
133  $this->tpl->setCurrentBlock('ttype');
134  $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype']));
135  $this->tpl->parseCurrentBlock();
136  }
137  if (strcmp($c, 'points') == 0)
138  {
139  $this->tpl->setCurrentBlock('points');
140  $this->tpl->setVariable("POINTS", ilUtil::prepareFormOutput($data['points']));
141  $this->tpl->parseCurrentBlock();
142  }
143  if(strcmp($c, 'created') == 0)
144  {
145  $this->tpl->setCurrentBlock('created');
146  $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
147  $this->tpl->parseCurrentBlock();
148  }
149  if(strcmp($c, 'updated') == 0)
150  {
151  $this->tpl->setCurrentBlock('updated');
152  $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX)));
153  $this->tpl->parseCurrentBlock();
154  }
155  }
156  if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0))
157  {
158  $this->tpl->setCurrentBlock("overview_row_detail");
159  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
160  $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]);
161  if (strcmp($this->outputmode, "detailed") == 0)
162  {
163  $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);
164  if (strlen($solutionoutput) == 0) $solutionoutput = $question_gui->getPreview();
165  $this->tpl->setVariable("DETAILS", $solutionoutput);
166  $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
167  }
168  else
169  {
170  $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
171  $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
172  }
173  $this->tpl->parseCurrentBlock();
174  }
176  }
177 
182  public function numericOrdering($column)
183  {
184  if(in_array($column, array('created', 'updated')))
185  {
186  return true;
187  }
188 
189  return false;
190  }
191 
192  public function getTotalPoints()
193  {
194  return $this->totalPoints;
195  }
196 
197  public function setTotalPoints($totalPoints)
198  {
199  $this->totalPoints = $totalPoints;
200  }
201 }
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.
setFormName($a_formname)
Set Form name.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setStyle($a_element, $a_style)
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.
setLimit($a_limit=0, $a_default_limit=0)
set max.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
enable($a_module_name)
enables particular modules of table
static formatDate(ilDateTime $date)
Format a date public.
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
global $lng
Definition: privfeed.php:40