ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SurveyMatrixQuestionGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for SurveyMatrixQuestionGUI:
+ Collaboration diagram for SurveyMatrixQuestionGUI:

Public Member Functions

 setQuestionTabs ()
 
 getParsedAnswers (?array $a_working_data=null, bool $a_only_user_anwers=false)
 
 getPrintView (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 layout ()
 Creates a layout view of the question. More...
 
 saveLayout ()
 Saves the layout for the matrix question. More...
 
 getLayoutRow ()
 Creates a row to define the matrix question layout with percentage values. More...
 
 getWorkingForm (?array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", ?int $survey_id=null, bool $compress_view=false)
 Creates the question output form for the learner. More...
 
- Public Member Functions inherited from SurveyQuestionGUI
 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
 executeCommand ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl (string $a_url)
 
 setQuestionTabsForClass (string $guiclass)
 
 getPrintView (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 preview ()
 
 getWorkingForm (?array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", ?int $survey_id=null, bool $compress_view=false)
 

Protected Member Functions

 initObject ()
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
- Protected Member Functions inherited from SurveyQuestionGUI
 initObject ()
 
 outQuestionText (ilTemplate $template)
 
 initEditForm ()
 
 addCommandButtons (ilPropertyFormGUI $a_form)
 
 editQuestion (?ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save (bool $a_return=false, bool $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving (bool $a_return=false)
 Redirect to calling survey or to edit form. More...
 
 cancel ()
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 getPrintViewQuestionTitle (int $question_title=1)
 
 getQuestionTitle (int $question_title_mode=1)
 
 renderStatisticsDetailsTable (array $a_head, array $a_rows, ?array $a_foot=null)
 

Protected Attributes

bool $show_layout_row = false
 
- Protected Attributes inherited from SurveyQuestionGUI
ILIAS Survey InternalGUIService $gui
 
EditingGUIRequest $request
 
EditManager $edit_manager
 
ilRbacSystem $rbacsystem
 
ilObjUser $user
 
ilAccessHandler $access
 
ilTree $tree
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
array $cumulated = []
 
string $parent_url = ""
 
ilLogger $log
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestionGUI
static _getQuestionGUI (?string $questiontype, int $question_id=-1)
 Creates a question gui representation. More...
 
static _getGUIClassNameForId (int $a_q_id)
 
static _getClassNameForQType (string $q_type)
 
- Data Fields inherited from SurveyQuestionGUI
SurveyQuestion $object = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Matrix question GUI representation

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

Definition at line 23 of file class.SurveyMatrixQuestionGUI.php.

Member Function Documentation

◆ addFieldsToEditForm()

SurveyMatrixQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Definition at line 41 of file class.SurveyMatrixQuestionGUI.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilFormPropertyGUI\setRequired().

41  : void
42  {
43  // subtype
44  $subtype = new ilRadioGroupInputGUI($this->lng->txt("subtype"), "type");
45  $subtype->setRequired(false);
46  $subtypes = array(
47  "0" => "matrix_subtype_sr",
48  "1" => "matrix_subtype_mr",
49  //"2" => "matrix_subtype_text",
50  //"3" => "matrix_subtype_integer",
51  //"4" => "matrix_subtype_double",
52  //"5" => "matrix_subtype_date",
53  //"6" => "matrix_subtype_time"
54  );
55  foreach ($subtypes as $idx => $st) {
56  $subtype->addOption(new ilRadioOption($this->lng->txt($st), $idx));
57  }
58  $a_form->addItem($subtype);
59 
60 
61  $header = new ilFormSectionHeaderGUI();
62  $header->setTitle($this->lng->txt("matrix_appearance"));
63  $a_form->addItem($header);
64 
65  // column separators
66  $column_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_column_separators"), "column_separators");
67  $column_separators->setValue(1);
68  $column_separators->setInfo($this->lng->txt("matrix_column_separators_description"));
69  $column_separators->setRequired(false);
70  $a_form->addItem($column_separators);
71 
72  // row separators
73  $row_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_row_separators"), "row_separators");
74  $row_separators->setValue(1);
75  $row_separators->setInfo($this->lng->txt("matrix_row_separators_description"));
76  $row_separators->setRequired(false);
77  $a_form->addItem($row_separators);
78 
79  // neutral column separators
80  $neutral_column_separator = new ilCheckboxInputGUI($this->lng->txt("matrix_neutral_column_separator"), "neutral_column_separator");
81  $neutral_column_separator->setValue(1);
82  $neutral_column_separator->setInfo($this->lng->txt("matrix_neutral_column_separator_description"));
83  $neutral_column_separator->setRequired(false);
84  $a_form->addItem($neutral_column_separator);
85 
86 
87  $header = new ilFormSectionHeaderGUI();
88  $header->setTitle($this->lng->txt("matrix_columns"));
89  $a_form->addItem($header);
90 
91  // Answers
92  $columns = new ilCategoryWizardInputGUI("", "columns");
93  $columns->setRequired(false);
94  $columns->setAllowMove(true);
95  $columns->setShowWizard(true);
96  $columns->setShowNeutralCategory(true);
97  $columns->setDisabledScale(false);
98  $columns->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
99  $columns->setCategoryText($this->lng->txt('matrix_standard_answers'));
100  $a_form->addItem($columns);
101 
102 
103  $header = new ilFormSectionHeaderGUI();
104  $header->setTitle($this->lng->txt("matrix_column_settings"));
105  $a_form->addItem($header);
106 
107  // bipolar adjectives
108  $bipolar = new ilCustomInputGUI($this->lng->txt("matrix_bipolar_adjectives"));
109  $bipolar->setInfo($this->lng->txt("matrix_bipolar_adjectives_description"));
110 
111  // left pole
112  $bipolar1 = new ilTextInputGUI($this->lng->txt("matrix_left_pole"), "bipolar1");
113  $bipolar1->setRequired(false);
114  $bipolar->addSubItem($bipolar1);
115 
116  // right pole
117  $bipolar2 = new ilTextInputGUI($this->lng->txt("matrix_right_pole"), "bipolar2");
118  $bipolar2->setRequired(false);
119  $bipolar->addSubItem($bipolar2);
120 
121  $a_form->addItem($bipolar);
122 
123 
124  $header = new ilFormSectionHeaderGUI();
125  $header->setTitle($this->lng->txt("matrix_rows"));
126  $a_form->addItem($header);
127 
128  // matrix rows
129  $rows = new ilMatrixRowWizardInputGUI("", "rows");
130  $rows->setRequired(false);
131  $rows->setAllowMove(true);
132  $rows->setLabelText($this->lng->txt('label'));
133  $rows->setUseOtherAnswer(true);
134  $a_form->addItem($rows);
135 
136 
137  // values
138  $subtype->setValue($this->object->getSubtype());
139  $column_separators->setChecked($this->object->getColumnSeparators());
140  $row_separators->setChecked($this->object->getRowSeparators());
141  $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
142 
143  if (!$this->object->getColumnCount()) {
144  $this->object->columns->addCategory("");
145  }
146  $columns->setValues($this->object->getColumns());
147 
148  $bipolar1->setValue($this->object->getBipolarAdjective(0));
149  $bipolar2->setValue($this->object->getBipolarAdjective(1));
150 
151  if ($this->object->getRowCount() === 0) {
152  $this->object->getRows()->addCategory("");
153  }
154  $rows->setValues($this->object->getRows());
155  }
This class represents an option in a radio group.
This class represents a property in a property form.
setRequired(bool $a_required)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getLayoutRow()

SurveyMatrixQuestionGUI::getLayoutRow ( )

Creates a row to define the matrix question layout with percentage values.

Definition at line 516 of file class.SurveyMatrixQuestionGUI.php.

References ILIAS\Repository\object().

Referenced by getPrintView(), and getWorkingForm().

516  : string
517  {
518  $percent_values = $this->object->getLayout();
519  $template = new ilTemplate("tpl.il_svy_out_matrix_layout.html", true, true, "components/ILIAS/SurveyQuestionPool");
520  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
521  $template->setCurrentBlock("bipolar_start");
522  $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE1", " value=\"" . $percent_values["percent_bipolar_adjective1"] . "\"");
523  $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective1"] . "%\"");
524  $template->parseCurrentBlock();
525  $template->setCurrentBlock("bipolar_end");
526  $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE2", " value=\"" . $percent_values["percent_bipolar_adjective2"] . "\"");
527  $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective2"] . "%\"");
528  $template->parseCurrentBlock();
529  }
530  $counter = $this->object->getColumnCount();
531  if ($this->object->hasNeutralColumn()) {
532  $template->setCurrentBlock("neutral_start");
533  $template->setVariable("VALUE_PERCENT_NEUTRAL", " value=\"" . $percent_values["percent_neutral"] . "\"");
534  $template->setVariable("STYLE_NEUTRAL", " style=\"width:" . $percent_values["percent_neutral"] . "%\"");
535  $template->parseCurrentBlock();
536  $counter--;
537  }
538  $template->setVariable("VALUE_PERCENT_ROW", " value=\"" . $percent_values["percent_row"] . "\"");
539  $template->setVariable("STYLE_ROW", " style=\"width:" . $percent_values["percent_row"] . "%\"");
540  $template->setVariable("COLSPAN_COLUMNS", $counter);
541  $template->setVariable("VALUE_PERCENT_COLUMNS", " value=\"" . $percent_values["percent_columns"] . "\"");
542  $template->setVariable("STYLE_COLUMNS", " style=\"width:" . $percent_values["percent_columns"] . "%\"");
543  return $template->get();
544  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParsedAnswers()

SurveyMatrixQuestionGUI::getParsedAnswers ( ?array  $a_working_data = null,
bool  $a_only_user_anwers = false 
)

Definition at line 197 of file class.SurveyMatrixQuestionGUI.php.

References null.

Referenced by getPrintView().

200  : array {
201  if (is_array($a_working_data)) {
202  $user_answers = $a_working_data;
203  }
204 
205  $options = array();
206  for ($i = 0; $i < $this->object->getRowCount(); $i++) {
207  $rowobj = $this->object->getRow($i);
208 
209  $text = null;
210 
211  $cols = array();
212  for ($j = 0; $j < $this->object->getColumnCount(); $j++) {
213  $cat = $this->object->getColumn($j);
214  $value = ($cat->scale) ? ($cat->scale - 1) : $j;
215 
216  $checked = "unchecked";
217  if (is_array($a_working_data)) {
218  foreach ($user_answers as $user_answer) {
219  if ($user_answer["rowvalue"] == $i &&
220  $user_answer["value"] == $value) {
221  $checked = "checked";
222  if ($user_answer["textanswer"]) {
223  $text = $user_answer["textanswer"];
224  }
225  }
226  }
227  }
228 
229  if (!$a_only_user_anwers || $checked === "checked") {
230  $cols[$value] = array(
231  "title" => trim($cat->title)
232  ,"neutral" => (bool) $cat->neutral
233  ,"checked" => $checked
234  );
235  }
236  }
237 
238  if ($a_only_user_anwers || count($cols) || $text) {
239  $row_idx = $i;
240  $options[$row_idx] = array(
241  "title" => trim($rowobj->title)
242  ,"other" => (bool) $rowobj->other
243  ,"textanswer" => $text
244  ,"cols" => $cols
245  );
246  }
247  }
248 
249  return $options;
250  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getPrintView()

SurveyMatrixQuestionGUI::getPrintView ( int  $question_title = 1,
bool  $show_questiontext = true,
?int  $survey_id = null,
?array  $working_data = null 
)

Definition at line 252 of file class.SurveyMatrixQuestionGUI.php.

References ilUtil\getHtmlPath(), ilUtil\getImagePath(), getLayoutRow(), getParsedAnswers(), SurveyQuestionGUI\getPrintViewQuestionTitle(), ILIAS\Repository\lng(), ILIAS\Repository\object(), SurveyQuestionGUI\outQuestionText(), and ilLegacyFormElementsUtil\prepareFormOutput().

257  : string {
258  $options = $this->getParsedAnswers($working_data);
259 
260  $layout = $this->object->getLayout();
261  $neutralstyle = "3px solid #808080";
262  $bordercolor = "#808080";
263  $template = new ilTemplate("tpl.il_svy_qpl_matrix_printview.html", true, true, "components/ILIAS/SurveyQuestionPool");
264 
265  if ($this->show_layout_row) {
266  $layout_row = $this->getLayoutRow();
267  $template->setCurrentBlock("matrix_row");
268  $template->setVariable("ROW", $layout_row);
269  $template->parseCurrentBlock();
270  }
271 
272  $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", true, true, "components/ILIAS/SurveyQuestionPool");
273  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
274  $tplheaders->setCurrentBlock("bipolar_start");
275  $style = array();
276  $style[] = sprintf("width: %.2F%s!important", $layout["percent_bipolar_adjective1"], "%");
277  if (count($style) > 0) {
278  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
279  }
280  $tplheaders->parseCurrentBlock();
281  }
282  // column headers
283  for ($i = 0; $i < $this->object->getColumnCount(); $i++) {
284  $cat = $this->object->getColumn($i);
285  if ($cat->neutral) {
286  $tplheaders->setCurrentBlock("neutral_column_header");
287  $tplheaders->setVariable("TEXT", ilLegacyFormElementsUtil::prepareFormOutput($cat->title));
288  $tplheaders->setVariable("CLASS", "rsep");
289  $style = array();
290  $style[] = sprintf("width: %.2F%s!important", $layout["percent_neutral"], "%");
291  if ($this->object->getNeutralColumnSeparator()) {
292  $style[] = "border-left: $neutralstyle!important;";
293  }
294  } else {
295  $style = array();
296  if ($this->object->getColumnSeparators()) {
297  if (($i < $this->object->getColumnCount() - 1)) {
298  $style[] = "border-right: 1px solid $bordercolor!important";
299  }
300  }
301  $style[] = sprintf(
302  "width: %.2F%s!important",
303  $layout["percent_columns"] / $this->object->getColumnCount(),
304  "%"
305  );
306  $tplheaders->setCurrentBlock("column_header");
307  $tplheaders->setVariable("TEXT", ilLegacyFormElementsUtil::prepareFormOutput($cat->title));
308  $tplheaders->setVariable("CLASS", "center");
309  }
310  if (count($style) > 0) {
311  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
312  }
313  $tplheaders->parseCurrentBlock();
314  }
315 
316  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
317  $tplheaders->setCurrentBlock("bipolar_end");
318  $style = array();
319  $style[] = sprintf("width: %.2F%s!important", $layout["percent_bipolar_adjective2"], "%");
320  if (count($style) > 0) {
321  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
322  }
323  $tplheaders->parseCurrentBlock();
324  }
325 
326  $style = array();
327  $style[] = sprintf("width: %.2F%s!important", $layout["percent_row"], "%");
328  if (count($style) > 0) {
329  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
330  }
331 
332  $template->setCurrentBlock("matrix_row");
333  $template->setVariable("ROW", $tplheaders->get());
334  $template->parseCurrentBlock();
335 
336  $rowclass = array("tblrow1", "tblrow2");
337 
338  for ($i = 0; $i < $this->object->getRowCount(); $i++) {
339  $rowobj = $this->object->getRow($i);
340  $tplrow = new ilTemplate("tpl.il_svy_qpl_matrix_printview_row.html", true, true, "components/ILIAS/SurveyQuestionPool");
341  for ($j = 0; $j < $this->object->getColumnCount(); $j++) {
342  $cat = $this->object->getColumn($j);
343  if ($i === 0 && $j === 0) {
344  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
345  $tplrow->setCurrentBlock("bipolar_start");
346  $tplrow->setVariable(
347  "TEXT_BIPOLAR_START",
348  ilLegacyFormElementsUtil::prepareFormOutput($this->object->getBipolarAdjective(0))
349  );
350  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
351  $tplrow->parseCurrentBlock();
352  }
353  }
354  if ($i === 0 && $j === $this->object->getColumnCount() - 1) {
355  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
356  $tplrow->setCurrentBlock("bipolar_end");
357  $tplrow->setVariable(
358  "TEXT_BIPOLAR_END",
359  ilLegacyFormElementsUtil::prepareFormOutput($this->object->getBipolarAdjective(1))
360  );
361  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
362  $tplrow->parseCurrentBlock();
363  }
364  }
365 
366  $value = ($cat->scale) ? ($cat->scale - 1) : $j;
367  $col = $options[$i]["cols"][$value];
368 
369  switch ($this->object->getSubtype()) {
370  case 0:
371  if ($cat->neutral) {
372  $tplrow->setCurrentBlock("neutral_radiobutton");
373  } else {
374  $tplrow->setCurrentBlock("radiobutton");
375  }
376  $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("object/radiobutton_" . $col["checked"] . ".png")));
377  $tplrow->setVariable("ALT_RADIO", $this->lng->txt($col["checked"]));
378  $tplrow->setVariable("TITLE_RADIO", $this->lng->txt($col["checked"]));
379  $tplrow->parseCurrentBlock();
380  break;
381  case 1:
382  if ($cat->neutral) {
383  $tplrow->setCurrentBlock("neutral_checkbox");
384  } else {
385  $tplrow->setCurrentBlock("checkbox");
386  }
387  $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("object/checkbox_" . $col["checked"] . ".png")));
388  $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt($col["checked"]));
389  $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt($col["checked"]));
390  $tplrow->parseCurrentBlock();
391  break;
392  }
393  if ($cat->neutral) {
394  $tplrow->setCurrentBlock("neutral_answer");
395  $style = array();
396  if ($this->object->getNeutralColumnSeparator()) {
397  $style[] = "border-left: $neutralstyle!important";
398  }
399  } else {
400  $tplrow->setCurrentBlock("answer");
401  $style = array();
402  }
403  if ($this->object->getColumnSeparators()) {
404  if ($j < $this->object->getColumnCount() - 1) {
405  $style[] = "border-right: 1px solid $bordercolor!important";
406  }
407  }
408  if ($this->object->getRowSeparators()) {
409  if ($i < $this->object->getRowCount() - 1) {
410  $style[] = "border-bottom: 1px solid $bordercolor!important";
411  }
412  }
413  if (count($style)) {
414  $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
415  }
416  $tplrow->parseCurrentBlock();
417  }
418 
419  if ($rowobj->other) {
420  $text = $options[$i]["textanswer"];
421  $tplrow->setCurrentBlock("text_other");
422  $tplrow->setVariable("TEXT_OTHER", $text
423  ?: "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
424  $tplrow->parseCurrentBlock();
425  }
426 
427  #force to have always the title
428  #22526
429  $row_title = ilLegacyFormElementsUtil::prepareFormOutput($rowobj->title);
430  if ($question_title === 3) {
431  if (trim($rowobj->label)) {
432  $row_title .= ' <span class="questionLabel">(' . ilLegacyFormElementsUtil::prepareFormOutput(
433  $rowobj->label
434  ) . ')</span>';
435  }
436  }
437 
438  $tplrow->setVariable("TEXT_ROW", $row_title);
439  $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]);
440  if ($this->object->getRowSeparators()) {
441  if ($i < $this->object->getRowCount() - 1) {
442  $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid $bordercolor!important\"");
443  }
444  }
445  $template->setCurrentBlock("matrix_row");
446  $template->setVariable("ROW", $tplrow->get());
447  $template->parseCurrentBlock();
448  }
449 
450  if ($question_title) {
451  $template->setVariable("QUESTION_TITLE", $this->getPrintViewQuestionTitle($question_title));
452  }
453  $template->setCurrentBlock();
454  if ($show_questiontext) {
455  $this->outQuestionText($template);
456  }
457  $template->parseCurrentBlock();
458  return $template->get();
459  }
getPrintViewQuestionTitle(int $question_title=1)
static prepareFormOutput($a_str, bool $a_strip=false)
outQuestionText(ilTemplate $template)
getParsedAnswers(?array $a_working_data=null, bool $a_only_user_anwers=false)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getHtmlPath(string $relative_path)
get url of path
getLayoutRow()
Creates a row to define the matrix question layout with percentage values.
+ Here is the call graph for this function:

◆ getWorkingForm()

SurveyMatrixQuestionGUI::getWorkingForm ( ?array  $working_data = null,
int  $question_title = 1,
bool  $show_questiontext = true,
string  $error_message = "",
?int  $survey_id = null,
bool  $compress_view = false 
)

Creates the question output form for the learner.

Definition at line 554 of file class.SurveyMatrixQuestionGUI.php.

References $data, getLayoutRow(), SurveyQuestionGUI\getQuestionTitle(), ILIAS\Repository\object(), SurveyQuestionGUI\outQuestionText(), and ilLegacyFormElementsUtil\prepareFormOutput().

Referenced by layout().

561  : string {
562  $layout = $this->object->getLayout();
563  $neutralstyle = "3px solid #808080";
564  $bordercolor = "#808080";
565  $template = new ilTemplate("tpl.il_svy_out_matrix.html", true, true, "components/ILIAS/SurveyQuestionPool");
566 
567  if ($this->show_layout_row) {
568  $layout_row = $this->getLayoutRow();
569  $template->setCurrentBlock("matrix_row");
570  $template->setVariable("ROW", $layout_row);
571  $template->parseCurrentBlock();
572  }
573 
574  $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", true, true, "components/ILIAS/SurveyQuestionPool");
575  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
576  $tplheaders->setCurrentBlock("bipolar_start");
577  $style = array();
578  $style[] = sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective1"], "%");
579  if (count($style) > 0) {
580  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
581  }
582  $tplheaders->parseCurrentBlock();
583  }
584  // column headers
585  for ($i = 0; $i < $this->object->getColumnCount(); $i++) {
586  $style = array();
587  $col = $this->object->getColumn($i);
588  if ($col->neutral) {
589  $tplheaders->setCurrentBlock("neutral_column_header");
590  $tplheaders->setVariable("TEXT", ilLegacyFormElementsUtil::prepareFormOutput($col->title));
591  $tplheaders->setVariable("CLASS", "rsep");
592  $style[] = sprintf("width: %.2f%s!important", $layout["percent_neutral"], "%");
593  if ($this->object->getNeutralColumnSeparator()) {
594  $style[] = "border-left: $neutralstyle!important;";
595  }
596  } else {
597  if ($this->object->getColumnSeparators()) {
598  if (($i < $this->object->getColumnCount() - 1)) {
599  $style[] = "border-right: 1px solid $bordercolor!important";
600  }
601  }
602  $style[] = sprintf(
603  "width: %.2f%s!important",
604  $layout["percent_columns"] / $this->object->getColumnCount(),
605  "%"
606  );
607  $tplheaders->setCurrentBlock("column_header");
608  $tplheaders->setVariable("TEXT", ilLegacyFormElementsUtil::prepareFormOutput($col->title));
609  $tplheaders->setVariable("CLASS", "center");
610  }
611  if (count($style) > 0) {
612  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
613  }
614  $tplheaders->parseCurrentBlock();
615  }
616  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
617  $tplheaders->setCurrentBlock("bipolar_end");
618  $style = array();
619  $style[] = sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective2"], "%");
620  if (count($style) > 0) {
621  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
622  }
623  $tplheaders->parseCurrentBlock();
624  }
625 
626  $style = array();
627  $style[] = sprintf("width: %.2f%s!important", $layout["percent_row"], "%");
628  if (count($style) > 0) {
629  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
630  }
631 
632  $template->setCurrentBlock("matrix_row");
633  $template->setVariable("ROW", $tplheaders->get());
634  $template->parseCurrentBlock();
635 
636  $rowclass = array("tblrow1", "tblrow2");
637  for ($i = 0; $i < $this->object->getRowCount(); $i++) {
638  $rowobj = $this->object->getRow($i);
639  $tplrow = new ilTemplate("tpl.il_svy_out_matrix_row.html", true, true, "components/ILIAS/SurveyQuestionPool");
640  for ($j = 0; $j < $this->object->getColumnCount(); $j++) {
641  $cat = $this->object->getColumn($j);
642  if ($i === 0 && $j === 0) {
643  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
644  $tplrow->setCurrentBlock("bipolar_start");
645  $tplrow->setVariable(
646  "TEXT_BIPOLAR_START",
647  ilLegacyFormElementsUtil::prepareFormOutput($this->object->getBipolarAdjective(0))
648  );
649  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
650  $tplrow->parseCurrentBlock();
651  }
652  }
653  if ($i === 0 && $j === $this->object->getColumnCount() - 1) {
654  if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
655  $tplrow->setCurrentBlock("bipolar_end");
656  $tplrow->setVariable(
657  "TEXT_BIPOLAR_END",
658  ilLegacyFormElementsUtil::prepareFormOutput($this->object->getBipolarAdjective(1))
659  );
660  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
661  $tplrow->parseCurrentBlock();
662  }
663  }
664  switch ($this->object->getSubtype()) {
665  case 0:
666  if ($cat->neutral) {
667  $tplrow->setCurrentBlock("neutral_radiobutton");
668  } else {
669  $tplrow->setCurrentBlock("radiobutton");
670  }
671  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
672  $tplrow->setVariable("ROW", $i);
673  $tplrow->setVariable("VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
674  if (is_array($working_data)) {
675  foreach ($working_data as $data) {
676  if (($data["value"] == $cat->scale - 1) && ($data["rowvalue"] == $i)) {
677  $tplrow->setVariable("CHECKED_RADIOBUTTON", " checked=\"checked\"");
678  }
679  }
680  }
681  $tplrow->parseCurrentBlock();
682  break;
683  case 1:
684  if ($cat->neutral) {
685  $tplrow->setCurrentBlock("neutral_checkbox");
686  } else {
687  $tplrow->setCurrentBlock("checkbox");
688  }
689  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
690  $tplrow->setVariable("ROW", $i);
691  $tplrow->setVariable("VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
692  if (is_array($working_data)) {
693  foreach ($working_data as $data) {
694  if (($data["value"] == $cat->scale - 1) && ($data["rowvalue"] == $i)) {
695  $tplrow->setVariable("CHECKED_CHECKBOX", " checked=\"checked\"");
696  }
697  }
698  }
699  $tplrow->parseCurrentBlock();
700  break;
701  }
702  if ($cat->neutral) {
703  $tplrow->setCurrentBlock("neutral_answer");
704  $style = array();
705  if ($this->object->getNeutralColumnSeparator()) {
706  $style[] = "border-left: $neutralstyle!important";
707  }
708  } else {
709  $tplrow->setCurrentBlock("answer");
710  $style = array();
711  }
712  if ($this->object->getColumnSeparators()) {
713  if ($j < $this->object->getColumnCount() - 1) {
714  $style[] = "border-right: 1px solid $bordercolor!important";
715  }
716  }
717  if ($this->object->getRowSeparators()) {
718  if ($i < $this->object->getRowCount() - 1) {
719  $style[] = "border-bottom: 1px solid $bordercolor!important";
720  }
721  }
722  if (count($style)) {
723  $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
724  }
725  $tplrow->parseCurrentBlock();
726  }
727 
728  if ($rowobj->other) {
729  $tplrow->setCurrentBlock("row_other");
730  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
731  $tplrow->setVariable("ROW", $i);
732  if (is_array($working_data)) {
733  foreach ($working_data as $data) {
734  if ($data["rowvalue"] == $i) {
735  $tplrow->setVariable(
736  "VALUE_OTHER",
738  );
739  }
740  }
741  }
742  $tplrow->parseCurrentBlock();
743  }
744  $tplrow->setVariable("TEXT_ROW", ilLegacyFormElementsUtil::prepareFormOutput($rowobj->title));
745  $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]);
746  if ($this->object->getRowSeparators()) {
747  if ($i < $this->object->getRowCount() - 1) {
748  $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid $bordercolor!important\"");
749  }
750  }
751  $template->setCurrentBlock("matrix_row");
752  $template->setVariable("ROW", $tplrow->get());
753  $template->parseCurrentBlock();
754  }
755 
756  $template->setVariable(
757  "QUESTION_TITLE",
758  $this->getQuestionTitle($question_title)
759  );
760  $template->setCurrentBlock("question_data_matrix");
761  if (strcmp($error_message, "") !== 0) {
762  $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
763  }
764  if ($show_questiontext) {
765  $this->outQuestionText($template);
766  }
767  $template->parseCurrentBlock();
768  return $template->get();
769  }
getQuestionTitle(int $question_title_mode=1)
static prepareFormOutput($a_str, bool $a_strip=false)
outQuestionText(ilTemplate $template)
getLayoutRow()
Creates a row to define the matrix question layout with percentage values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importEditFormValues()

SurveyMatrixQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Definition at line 157 of file class.SurveyMatrixQuestionGUI.php.

References ilPropertyFormGUI\getInput(), and null.

157  : void
158  {
159  $this->object->setSubtype($a_form->getInput("type"));
160  $this->object->setRowSeparators($a_form->getInput("row_separators") ? 1 : 0);
161  $this->object->setColumnSeparators($a_form->getInput("column_separators") ? 1 : 0);
162  $this->object->setNeutralColumnSeparator($a_form->getInput("neutral_column_separator") ? 1 : 0);
163 
164  // Set bipolar adjectives
165  $this->object->setBipolarAdjective(0, $a_form->getInput("bipolar1"));
166  $this->object->setBipolarAdjective(1, $a_form->getInput("bipolar2"));
167 
168  // set columns
169  $this->object->flushColumns();
170 
171  $columns = $this->request->getColumns();
172  foreach ($columns['answer'] as $key => $value) {
173  if (strlen($value ?? "")) {
174  $this->object->getColumns()->addCategory($value, $columns['other'][$key] ?? 0, 0, null, $columns['scale'][$key]);
175  }
176  }
177  if (isset($columns["neutral"][0]) && trim($columns["neutral"][0]) !== "") {
178  $this->object->getColumns()->addCategory(
179  $columns['neutral'][0],
180  0,
181  1,
182  null,
183  $this->request->getColumnNeutralScale()
184  );
185  }
186 
187  // set rows
188  $this->object->flushRows();
189  $rows = $this->request->getRows();
190  foreach ($rows['answer'] as $key => $value) {
191  if (strlen($value ?? "")) {
192  $this->object->getRows()->addCategory($value, $rows['other'][$key] ?? 0, 0, $rows['label'][$key] ?? null);
193  }
194  }
195  }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ initObject()

SurveyMatrixQuestionGUI::initObject ( )
protected

Definition at line 27 of file class.SurveyMatrixQuestionGUI.php.

27  : void
28  {
29  $this->object = new SurveyMatrixQuestion();
30  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ layout()

SurveyMatrixQuestionGUI::layout ( )

Creates a layout view of the question.

Definition at line 469 of file class.SurveyMatrixQuestionGUI.php.

References SurveyQuestionGUI\$tabs, ilTabsGUI\activateTab(), ILIAS\Repository\ctrl(), getWorkingForm(), and ILIAS\Repository\lng().

Referenced by saveLayout().

469  : void
470  {
471  $ilTabs = $this->tabs;
472 
473  $ilTabs->activateTab("layout");
474 
475  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_layout.html", "components/ILIAS/SurveyQuestionPool");
476  $this->show_layout_row = true;
477  $question_output = $this->getWorkingForm();
478  $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
479  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveLayout"));
480  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
481  }
getWorkingForm(?array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", ?int $survey_id=null, bool $compress_view=false)
Creates the question output form for the learner.
activateTab(string $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveLayout()

SurveyMatrixQuestionGUI::saveLayout ( )

Saves the layout for the matrix question.

Definition at line 486 of file class.SurveyMatrixQuestionGUI.php.

References layout(), and ILIAS\Repository\lng().

486  : void
487  {
488  $percent_values = array(
489  "percent_row" => $this->request->getPercentRow(),
490  "percent_columns" => $this->request->getPercentColumns(),
491  "percent_bipolar_adjective1" => $this->request->getPercentBipAdj1(),
492  "percent_bipolar_adjective2" => $this->request->getPercentBipAdj2(),
493  "percent_neutral" => $this->request->getPercentNeutral()
494  );
495  $this->object->setLayout($percent_values);
496 
497  // #9364
498  if (array_sum($percent_values) == 100) {
499  $this->object->saveLayout(
500  $percent_values["percent_row"],
501  $percent_values['percent_columns'],
502  $percent_values['percent_bipolar_adjective1'],
503  $percent_values['percent_bipolar_adjective2'],
504  $percent_values["percent_neutral"]
505  );
506  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
507  } else {
508  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_matrix_layout_percentages_sum_invalid"));
509  }
510  $this->layout();
511  }
layout()
Creates a layout view of the question.
+ Here is the call graph for this function:

◆ setQuestionTabs()

SurveyMatrixQuestionGUI::setQuestionTabs ( )

Definition at line 36 of file class.SurveyMatrixQuestionGUI.php.

References SurveyQuestionGUI\setQuestionTabsForClass().

36  : void
37  {
38  $this->setQuestionTabsForClass("surveymatrixquestiongui");
39  }
setQuestionTabsForClass(string $guiclass)
+ Here is the call graph for this function:

Field Documentation

◆ $show_layout_row

bool SurveyMatrixQuestionGUI::$show_layout_row = false
protected

Definition at line 25 of file class.SurveyMatrixQuestionGUI.php.


The documentation for this class was generated from the following file: