ILIAS  release_8 Revision v8.24
class.ilQuestionPoolPrintViewTableGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 protected $outputmode;
30
31 protected $totalPoints;
32
33 public function __construct($a_parent_obj, $a_parent_cmd, $outputmode = '')
34 {
35 $this->setId("qpl_print");
36 parent::__construct($a_parent_obj, $a_parent_cmd);
37
38 global $DIC;
39 $lng = $DIC['lng'];
40 $ilCtrl = $DIC['ilCtrl'];
41
42 $this->lng = $lng;
43 $this->ctrl = $ilCtrl;
44 $this->outputmode = $outputmode;
45 $this->ctrl->setParameterByClass('ilObjQuestionPoolGUI', 'output', $outputmode);
46
47 $this->setFormName('printviewform');
48 $this->setStyle('table', 'fullwidth');
49
50 $this->addCommandButton('print', $this->lng->txt('print'), "javascript:window.print();return false;");
51
52 $this->setRowTemplate("tpl.il_as_qpl_printview_row.html", "Modules/TestQuestionPool");
53
54 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
55 $this->setDefaultOrderField("title");
56 $this->setDefaultOrderDirection("asc");
57
58 $this->enable('sort');
59 $this->enable('header');
60 $this->disable('select_all');
61 }
62
63 public function initColumns(): void
64 {
65 $this->addColumn($this->lng->txt("title"), 'title', '');
66
67 foreach ($this->getSelectedColumns() as $c) {
68 if (strcmp($c, 'description') == 0) {
69 $this->addColumn($this->lng->txt("description"), 'description', '');
70 }
71 if (strcmp($c, 'author') == 0) {
72 $this->addColumn($this->lng->txt("author"), 'author', '');
73 }
74 if (strcmp($c, 'ttype') == 0) {
75 $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
76 }
77 if (strcmp($c, 'points') == 0) {
78 $this->addColumn($this->getPointsColumnHeader(), 'points', '');
79 }
80 if (strcmp($c, 'created') == 0) {
81 $this->addColumn($this->lng->txt("create_date"), 'created', '');
82 }
83 if (strcmp($c, 'updated') == 0) {
84 $this->addColumn($this->lng->txt("last_update"), 'updated', '');
85 }
86 }
87 }
88
89 private function getPointsColumnHeader(): string
90 {
91 return $this->lng->txt("points") . ' (' . $this->getTotalPoints() . ')';
92 }
93
94 public function getSelectableColumns(): array
95 {
96 global $DIC;
97 $lng = $DIC['lng'];
98 $cols["description"] = array(
99 "txt" => $lng->txt("description"),
100 "default" => true
101 );
102 $cols["author"] = array(
103 "txt" => $lng->txt("author"),
104 "default" => true
105 );
106 $cols["ttype"] = array(
107 "txt" => $lng->txt("question_type"),
108 "default" => true
109 );
110 $cols["points"] = array(
111 "txt" => $lng->txt("points"),
112 "default" => true
113 );
114 $cols["created"] = array(
115 "txt" => $lng->txt("create_date"),
116 "default" => true
117 );
118 $cols["updated"] = array(
119 "txt" => $lng->txt("last_update"),
120 "default" => true
121 );
122 return $cols;
123 }
124
131 public function fillRow(array $a_set): void
132 {
134 $this->tpl->setVariable("TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set['title']));
135 foreach ($this->getSelectedColumns() as $c) {
136 if (strcmp($c, 'description') == 0) {
137 $this->tpl->setCurrentBlock('description');
138 $this->tpl->setVariable(
139 "DESCRIPTION",
140 ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['description'])
141 );
142 $this->tpl->parseCurrentBlock();
143 }
144 if (strcmp($c, 'author') == 0) {
145 $this->tpl->setCurrentBlock('author');
146 $this->tpl->setVariable("AUTHOR", ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['author']));
147 $this->tpl->parseCurrentBlock();
148 }
149 if (strcmp($c, 'ttype') == 0) {
150 $this->tpl->setCurrentBlock('ttype');
151 $this->tpl->setVariable("TYPE", ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['ttype']));
152 $this->tpl->parseCurrentBlock();
153 }
154 if (strcmp($c, 'points') == 0) {
155 $this->tpl->setCurrentBlock('points');
156 $this->tpl->setVariable("POINTS", ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['points']));
157 $this->tpl->parseCurrentBlock();
158 }
159 if (strcmp($c, 'created') == 0) {
160 $this->tpl->setCurrentBlock('created');
161 $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($a_set['created'], IL_CAL_UNIX)));
162 $this->tpl->parseCurrentBlock();
163 }
164 if (strcmp($c, 'updated') == 0) {
165 $this->tpl->setCurrentBlock('updated');
166 $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($a_set['updated'], IL_CAL_UNIX)));
167 $this->tpl->parseCurrentBlock();
168 }
169 }
170 if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0)) {
171 $this->tpl->setCurrentBlock("overview_row_detail");
172 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
173 $question_gui = assQuestion::instantiateQuestionGUI($a_set["question_id"]);
174 $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
175 if (strcmp($this->outputmode, "detailed") == 0) {
176 $solutionoutput = $question_gui->getSolutionOutput(0, null, false, false, false, false, true, false);
177 if (strlen($solutionoutput) == 0) {
178 $solutionoutput = $question_gui->getPreview();
179 }
180 $this->tpl->setVariable("DETAILS", $solutionoutput);
181 $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
182 } else {
183 $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
184 $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
185 }
186 $this->tpl->parseCurrentBlock();
187 }
189 }
190
195 public function numericOrdering(string $a_field): bool
196 {
197 if (in_array($a_field, array('points', 'created', 'updated'))) {
198 return true;
199 }
200
201 return false;
202 }
203
204 public function getTotalPoints()
205 {
206 return $this->totalPoints;
207 }
208
209 public function setTotalPoints($totalPoints): void
210 {
211 $this->totalPoints = $totalPoints;
212 }
213}
const IL_CAL_UNIX
static instantiateQuestionGUI(int $a_question_id)
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($a_parent_obj, $a_parent_cmd, $outputmode='')
fillRow(array $a_set)
fill row @access public
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormName(string $a_name="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
ilLanguage $lng
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
disable(string $a_module_name)
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$cols
Definition: xhr_table.php:11