ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilQuestionPoolPrintViewTableGUI.php
Go to the documentation of this file.
1<?php
2
27{
28 protected $outputmode;
29
30 protected $totalPoints;
31
32 public function __construct($a_parent_obj, $a_parent_cmd, $outputmode = '')
33 {
34 $this->setId("qpl_print");
35 parent::__construct($a_parent_obj, $a_parent_cmd);
36
37 global $DIC;
38 $lng = $DIC['lng'];
39 $ilCtrl = $DIC['ilCtrl'];
40
41 $this->lng = $lng;
42 $this->ctrl = $ilCtrl;
43 $this->outputmode = $outputmode;
44 $this->setTitle($this->lng->txt($this->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", "components/ILIAS/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"] = [
99 "txt" => $lng->txt("description"),
100 "default" => true
101 ];
102 $cols["author"] = [
103 "txt" => $lng->txt("author"),
104 "default" => true
105 ];
106 $cols["ttype"] = [
107 "txt" => $lng->txt("question_type"),
108 "default" => true
109 ];
110 $cols["points"] = [
111 "txt" => $lng->txt("points"),
112 "default" => true
113 ];
114 $cols["created"] = [
115 "txt" => $lng->txt("create_date"),
116 "default" => true
117 ];
118 $cols["updated"] = [
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_output_solutions") == 0) || (strcmp($this->outputmode, "detailed_output_printview") == 0)) {
171 $this->tpl->setCurrentBlock("overview_row_detail");
172 $question_gui = assQuestion::instantiateQuestionGUI($a_set["question_id"]);
173 $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
174 if (strcmp($this->outputmode, "detailed_output_solutions") == 0) {
175 $solutionoutput = $question_gui->getSolutionOutput(0, null, false, false, false, false, true, false);
176 if (strlen($solutionoutput) == 0) {
177 $solutionoutput = $question_gui->getPreview();
178 }
179 $this->tpl->setVariable("DETAILS", $solutionoutput);
180 $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
181 } else {
182 $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
183 $this->tpl->setVariable("ROW_DETAIL_COLSPAN", $this->column_count);
184 }
185 $this->tpl->parseCurrentBlock();
186 }
188 }
189
194 public function numericOrdering(string $a_field): bool
195 {
196 if (in_array($a_field, ['points', 'created', 'updated'])) {
197 return true;
198 }
199
200 return false;
201 }
202
203 public function getTotalPoints()
204 {
205 return $this->totalPoints;
206 }
207
208 public function setTotalPoints($totalPoints): void
209 {
210 $this->totalPoints = $totalPoints;
211 }
212}
const IL_CAL_UNIX
return true
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, ?ilObjUser $user=null,)
@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...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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: deliver.php:25
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26