ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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->setTitle($this->lng->txt($this->outputmode));
46  $this->ctrl->setParameterByClass('ilObjQuestionPoolGUI', 'output', $outputmode);
47 
48  $this->setFormName('printviewform');
49  $this->setStyle('table', 'fullwidth');
50 
51  $this->addCommandButton('print', $this->lng->txt('print'), "javascript:window.print();return false;");
52 
53  $this->setRowTemplate("tpl.il_as_qpl_printview_row.html", "Modules/TestQuestionPool");
54 
55  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
56  $this->setDefaultOrderField("title");
57  $this->setDefaultOrderDirection("asc");
58 
59  $this->enable('sort');
60  $this->enable('header');
61  $this->disable('select_all');
62  }
63 
64  public function initColumns(): void
65  {
66  $this->addColumn($this->lng->txt("title"), 'title', '');
67 
68  foreach ($this->getSelectedColumns() as $c) {
69  if (strcmp($c, 'description') == 0) {
70  $this->addColumn($this->lng->txt("description"), 'description', '');
71  }
72  if (strcmp($c, 'author') == 0) {
73  $this->addColumn($this->lng->txt("author"), 'author', '');
74  }
75  if (strcmp($c, 'ttype') == 0) {
76  $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
77  }
78  if (strcmp($c, 'points') == 0) {
79  $this->addColumn($this->getPointsColumnHeader(), 'points', '');
80  }
81  if (strcmp($c, 'created') == 0) {
82  $this->addColumn($this->lng->txt("create_date"), 'created', '');
83  }
84  if (strcmp($c, 'updated') == 0) {
85  $this->addColumn($this->lng->txt("last_update"), 'updated', '');
86  }
87  }
88  }
89 
90  private function getPointsColumnHeader(): string
91  {
92  return $this->lng->txt("points") . ' (' . $this->getTotalPoints() . ')';
93  }
94 
95  public function getSelectableColumns(): array
96  {
97  global $DIC;
98  $lng = $DIC['lng'];
99  $cols["description"] = array(
100  "txt" => $lng->txt("description"),
101  "default" => true
102  );
103  $cols["author"] = array(
104  "txt" => $lng->txt("author"),
105  "default" => true
106  );
107  $cols["ttype"] = array(
108  "txt" => $lng->txt("question_type"),
109  "default" => true
110  );
111  $cols["points"] = array(
112  "txt" => $lng->txt("points"),
113  "default" => true
114  );
115  $cols["created"] = array(
116  "txt" => $lng->txt("create_date"),
117  "default" => true
118  );
119  $cols["updated"] = array(
120  "txt" => $lng->txt("last_update"),
121  "default" => true
122  );
123  return $cols;
124  }
125 
132  public function fillRow(array $a_set): void
133  {
135  $this->tpl->setVariable("TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set['title']));
136  foreach ($this->getSelectedColumns() as $c) {
137  if (strcmp($c, 'description') == 0) {
138  $this->tpl->setCurrentBlock('description');
139  $this->tpl->setVariable(
140  "DESCRIPTION",
141  ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['description'])
142  );
143  $this->tpl->parseCurrentBlock();
144  }
145  if (strcmp($c, 'author') == 0) {
146  $this->tpl->setCurrentBlock('author');
147  $this->tpl->setVariable("AUTHOR", ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['author']));
148  $this->tpl->parseCurrentBlock();
149  }
150  if (strcmp($c, 'ttype') == 0) {
151  $this->tpl->setCurrentBlock('ttype');
152  $this->tpl->setVariable("TYPE", ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['ttype']));
153  $this->tpl->parseCurrentBlock();
154  }
155  if (strcmp($c, 'points') == 0) {
156  $this->tpl->setCurrentBlock('points');
157  $this->tpl->setVariable("POINTS", ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['points']));
158  $this->tpl->parseCurrentBlock();
159  }
160  if (strcmp($c, 'created') == 0) {
161  $this->tpl->setCurrentBlock('created');
162  $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($a_set['created'], IL_CAL_UNIX)));
163  $this->tpl->parseCurrentBlock();
164  }
165  if (strcmp($c, 'updated') == 0) {
166  $this->tpl->setCurrentBlock('updated');
167  $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($a_set['updated'], IL_CAL_UNIX)));
168  $this->tpl->parseCurrentBlock();
169  }
170  }
171  if ((strcmp($this->outputmode, "detailed_output_solutions") == 0) || (strcmp($this->outputmode, "detailed_output_printview") == 0)) {
172  $this->tpl->setCurrentBlock("overview_row_detail");
173  $question_gui = assQuestion::instantiateQuestionGUI($a_set["question_id"]);
174  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
175  if (strcmp($this->outputmode, "detailed_output_solutions") == 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 }
__construct($a_parent_obj, $a_parent_cmd, $outputmode='')
enable(string $a_module_name)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static prepareFormOutput($a_str, bool $a_strip=false)
const IL_CAL_UNIX
setFormName(string $a_name="")
ilLanguage $lng
setId(string $a_val)
static instantiateQuestionGUI(int $a_question_id)
global $DIC
Definition: feed.php:28
setStyle(string $a_element, string $a_style)
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)
disable(string $a_module_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setUseRelativeDates(bool $a_status)
set use relative dates