ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4include_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 $ilCtrl->setParameterByClass('ilObjQuestionPoolGUI', 'output', $outputmode);
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
51 $this->enable('sort');
52 $this->enable('header');
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 $DIC;
90 $lng = $DIC['lng'];
91 $cols["description"] = array(
92 "txt" => $lng->txt("description"),
93 "default" => true
94 );
95 $cols["author"] = array(
96 "txt" => $lng->txt("author"),
97 "default" => true
98 );
99 $cols["ttype"] = array(
100 "txt" => $lng->txt("question_type"),
101 "default" => true
102 );
103 $cols["points"] = array(
104 "txt" => $lng->txt("points"),
105 "default" => true
106 );
107 $cols["created"] = array(
108 "txt" => $lng->txt("create_date"),
109 "default" => true
110 );
111 $cols["updated"] = array(
112 "txt" => $lng->txt("last_update"),
113 "default" => true
114 );
115 return $cols;
116 }
117
125 public function fillRow($data)
126 {
128 $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title']));
129 foreach ($this->getSelectedColumns() as $c) {
130 if (strcmp($c, 'description') == 0) {
131 $this->tpl->setCurrentBlock('description');
132 $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
133 $this->tpl->parseCurrentBlock();
134 }
135 if (strcmp($c, 'author') == 0) {
136 $this->tpl->setCurrentBlock('author');
137 $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author']));
138 $this->tpl->parseCurrentBlock();
139 }
140 if (strcmp($c, 'ttype') == 0) {
141 $this->tpl->setCurrentBlock('ttype');
142 $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype']));
143 $this->tpl->parseCurrentBlock();
144 }
145 if (strcmp($c, 'points') == 0) {
146 $this->tpl->setCurrentBlock('points');
147 $this->tpl->setVariable("POINTS", ilUtil::prepareFormOutput($data['points']));
148 $this->tpl->parseCurrentBlock();
149 }
150 if (strcmp($c, 'created') == 0) {
151 $this->tpl->setCurrentBlock('created');
152 $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
153 $this->tpl->parseCurrentBlock();
154 }
155 if (strcmp($c, 'updated') == 0) {
156 $this->tpl->setCurrentBlock('updated');
157 $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX)));
158 $this->tpl->parseCurrentBlock();
159 }
160 }
161 if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0)) {
162 $this->tpl->setCurrentBlock("overview_row_detail");
163 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
164 $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]);
165 $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
166 if (strcmp($this->outputmode, "detailed") == 0) {
167 $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);
168 if (strlen($solutionoutput) == 0) {
169 $solutionoutput = $question_gui->getPreview();
170 }
171 $this->tpl->setVariable("DETAILS", $solutionoutput);
172 $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
173 } else {
174 $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
175 $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
176 }
177 $this->tpl->parseCurrentBlock();
178 }
180 }
181
186 public function numericOrdering($column)
187 {
188 if (in_array($column, array('points', 'created', 'updated'))) {
189 return true;
190 }
191
192 return false;
193 }
194
195 public function getTotalPoints()
196 {
197 return $this->totalPoints;
198 }
199
201 {
202 $this->totalPoints = $totalPoints;
203 }
204}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
@classDescription Date and time handling
__construct($a_parent_obj, $a_parent_cmd, $outputmode='')
Constructor.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$c
Definition: cli.php:37
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$cols
Definition: xhr_table.php:11