ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilQuestionPoolPrintViewTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 
35 {
36  protected $outputmode;
37 
45  public function __construct($a_parent_obj, $a_parent_cmd, $outputmode = '')
46  {
47  $this->setId("qpl_print");
48  parent::__construct($a_parent_obj, $a_parent_cmd);
49 
50  global $lng, $ilCtrl;
51 
52  $this->lng = $lng;
53  $this->ctrl = $ilCtrl;
54  $this->outputmode = $outputmode;
55 
56  $this->setFormName('printviewform');
57  $this->setStyle('table', 'fullwidth');
58  $this->addColumn($this->lng->txt("title"),'title', '');
59  foreach ($this->getSelectedColumns() as $c)
60  {
61  if (strcmp($c, 'description') == 0) $this->addColumn($this->lng->txt("description"),'description', '');
62  if (strcmp($c, 'author') == 0) $this->addColumn($this->lng->txt("author"),'author', '');
63  if (strcmp($c, 'ttype') == 0) $this->addColumn($this->lng->txt("question_type"),'ttype', '');
64  if (strcmp($c, 'created') == 0) $this->addColumn($this->lng->txt("create_date"),'created', '');
65  if (strcmp($c, 'updated') == 0) $this->addColumn($this->lng->txt("last_update"),'updated', '');
66  }
67 
68  $this->addCommandButton('print', $this->lng->txt('print'), "javascript:window.print();return false;");
69 
70  $this->setRowTemplate("tpl.il_as_qpl_printview_row.html", "Modules/TestQuestionPool");
71 
72  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
73  $this->setDefaultOrderField("title");
74  $this->setDefaultOrderDirection("asc");
75  $this->setLimit(999);
76 
77  $this->enable('sort');
78  $this->enable('header');
79 // $this->disable('numinfo');
80  $this->disable('select_all');
81  }
82 
84  {
85  global $lng;
86  $cols["description"] = array(
87  "txt" => $lng->txt("description"),
88  "default" => true
89  );
90  $cols["author"] = array(
91  "txt" => $lng->txt("author"),
92  "default" => true
93  );
94  $cols["ttype"] = array(
95  "txt" => $lng->txt("question_type"),
96  "default" => true
97  );
98  $cols["created"] = array(
99  "txt" => $lng->txt("create_date"),
100  "default" => true
101  );
102  $cols["updated"] = array(
103  "txt" => $lng->txt("last_update"),
104  "default" => true
105  );
106  return $cols;
107  }
108 
116  public function fillRow($data)
117  {
119  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title']));
120  foreach ($this->getSelectedColumns() as $c)
121  {
122  if (strcmp($c, 'description') == 0)
123  {
124  $this->tpl->setCurrentBlock('description');
125  $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
126  $this->tpl->parseCurrentBlock();
127  }
128  if (strcmp($c, 'author') == 0)
129  {
130  $this->tpl->setCurrentBlock('author');
131  $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author']));
132  $this->tpl->parseCurrentBlock();
133  }
134  if (strcmp($c, 'ttype') == 0)
135  {
136  $this->tpl->setCurrentBlock('ttype');
137  $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype']));
138  $this->tpl->parseCurrentBlock();
139  }
140  if(strcmp($c, 'created') == 0)
141  {
142  $this->tpl->setCurrentBlock('created');
143  $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
144  $this->tpl->parseCurrentBlock();
145  }
146  if(strcmp($c, 'updated') == 0)
147  {
148  $this->tpl->setCurrentBlock('updated');
149  $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX)));
150  $this->tpl->parseCurrentBlock();
151  }
152  }
153  if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0))
154  {
155  $this->tpl->setCurrentBlock("overview_row_detail");
156  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
157  $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]);
158  if (strcmp($this->outputmode, "detailed") == 0)
159  {
160  $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);
161  if (strlen($solutionoutput) == 0) $solutionoutput = $question_gui->getPreview();
162  $this->tpl->setVariable("DETAILS", $solutionoutput);
163  }
164  else
165  {
166  $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
167  }
168  $this->tpl->parseCurrentBlock();
169  }
171  }
172 
177  public function numericOrdering($column)
178  {
179  if(in_array($column, array('created', 'updated')))
180  {
181  return true;
182  }
183 
184  return false;
185  }
186 }