ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 InternalDomainService $domain
 
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
 
ilHtmlPurifierInterface $purifier
 

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 25 of file class.SurveyMatrixQuestionGUI.php.

Member Function Documentation

◆ addFieldsToEditForm()

SurveyMatrixQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

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

References ILIAS\Scripts\PHPStan\$rows, ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ 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 533 of file class.SurveyMatrixQuestionGUI.php.

533 : string
534 {
535 $percent_values = $this->object->getLayout();
536 $template = new ilTemplate("tpl.il_svy_out_matrix_layout.html", true, true, "components/ILIAS/SurveyQuestionPool");
537 if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
538 $template->setCurrentBlock("bipolar_start");
539 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE1", " value=\"" . $percent_values["percent_bipolar_adjective1"] . "\"");
540 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective1"] . "%\"");
541 $template->parseCurrentBlock();
542 $template->setCurrentBlock("bipolar_end");
543 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE2", " value=\"" . $percent_values["percent_bipolar_adjective2"] . "\"");
544 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective2"] . "%\"");
545 $template->parseCurrentBlock();
546 }
547 $counter = $this->object->getColumnCount();
548 if ($this->object->hasNeutralColumn()) {
549 $template->setCurrentBlock("neutral_start");
550 $template->setVariable("VALUE_PERCENT_NEUTRAL", " value=\"" . $percent_values["percent_neutral"] . "\"");
551 $template->setVariable("STYLE_NEUTRAL", " style=\"width:" . $percent_values["percent_neutral"] . "%\"");
552 $template->parseCurrentBlock();
553 $counter--;
554 }
555 $template->setVariable("VALUE_PERCENT_ROW", " value=\"" . $percent_values["percent_row"] . "\"");
556 $template->setVariable("STYLE_ROW", " style=\"width:" . $percent_values["percent_row"] . "%\"");
557 $template->setVariable("COLSPAN_COLUMNS", $counter);
558 $template->setVariable("VALUE_PERCENT_COLUMNS", " value=\"" . $percent_values["percent_columns"] . "\"");
559 $template->setVariable("STYLE_COLUMNS", " style=\"width:" . $percent_values["percent_columns"] . "%\"");
560 return $template->get();
561 }
special template class to simplify handling of ITX/PEAR

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getParsedAnswers()

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

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

217 : array {
218 if (is_array($a_working_data)) {
219 $user_answers = $a_working_data;
220 }
221
222 $options = array();
223 for ($i = 0; $i < $this->object->getRowCount(); $i++) {
224 $rowobj = $this->object->getRow($i);
225
226 $text = null;
227
228 $cols = array();
229 for ($j = 0; $j < $this->object->getColumnCount(); $j++) {
230 $cat = $this->object->getColumn($j);
231 $value = ($cat->scale) ? ($cat->scale - 1) : $j;
232
233 $checked = "unchecked";
234 if (is_array($a_working_data)) {
235 foreach ($user_answers as $user_answer) {
236 if ($user_answer["rowvalue"] == $i &&
237 $user_answer["value"] == $value) {
238 $checked = "checked";
239 if ($user_answer["textanswer"]) {
240 $text = $user_answer["textanswer"];
241 }
242 }
243 }
244 }
245
246 if (!$a_only_user_anwers || $checked === "checked") {
247 $cols[$value] = array(
248 "title" => trim((string) $cat->title)
249 ,"neutral" => (bool) $cat->neutral
250 ,"checked" => $checked
251 );
252 }
253 }
254
255 if ($a_only_user_anwers || count($cols) || $text) {
256 $row_idx = $i;
257 $options[$row_idx] = array(
258 "title" => trim((string) $rowobj->title)
259 ,"other" => (bool) $rowobj->other
260 ,"textanswer" => $text
261 ,"cols" => $cols
262 );
263 }
264 }
265
266 return $options;
267 }
$text
Definition: xapiexit.php:21

◆ getPrintView()

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

Reimplemented from SurveyQuestionGUI.

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

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

◆ 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.

Reimplemented from SurveyQuestionGUI.

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

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

◆ importEditFormValues()

SurveyMatrixQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

159 : void
160 {
161 $this->object->setSubtype((int) $a_form->getInput("type"));
162 $this->object->setRowSeparators((bool) $a_form->getInput("row_separators"));
163 $this->object->setColumnSeparators((bool) $a_form->getInput("column_separators"));
164 $this->object->setNeutralColumnSeparator((bool) $a_form->getInput("neutral_column_separator"));
165
166 // Set bipolar adjectives
167 $this->object->setBipolarAdjective(0, (string) $a_form->getInput("bipolar1"));
168 $this->object->setBipolarAdjective(1, (string) $a_form->getInput("bipolar2"));
169
170 // set columns
171 $this->object->flushColumns();
172
173 $columns = $this->request->getColumns();
174 foreach ($columns['answer'] as $key => $value) {
175 if (strlen((string) ($value ?? ""))) {
176 $this->object->getColumns()->addCategory(
177 (string) $value,
178 (int) ($columns['other'][$key] ?? 0),
179 0,
180 null,
181 isset($columns['scale'][$key]) && $columns['scale'][$key] !== ''
182 ? (int) $columns['scale'][$key]
183 : null
184 );
185 }
186 }
187 if (isset($columns["neutral"][0]) && trim((string) $columns["neutral"][0]) !== "") {
188 $this->object->getColumns()->addCategory(
189 (string) $columns['neutral'][0],
190 0,
191 1,
192 null,
193 $this->request->getColumnNeutralScale() !== ''
194 ? (int) $this->request->getColumnNeutralScale()
195 : null
196 );
197 }
198
199 // set rows
200 $this->object->flushRows();
201 $rows = $this->request->getRows();
202 foreach ($rows['answer'] as $key => $value) {
203 if (strlen((string) ($value ?? ""))) {
204 $this->object->getRows()->addCategory(
205 (string) $value,
206 (int) ($rows['other'][$key] ?? 0),
207 0,
208 isset($rows['label'][$key]) ? (string) $rows['label'][$key] : null
209 );
210 }
211 }
212 }
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-...

References ILIAS\Scripts\PHPStan\$rows, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyMatrixQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

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

29 : void
30 {
31 $this->object = new SurveyMatrixQuestion();
32 }
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 486 of file class.SurveyMatrixQuestionGUI.php.

486 : void
487 {
488 $ilTabs = $this->tabs;
489
490 $ilTabs->activateTab("layout");
491
492 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_layout.html", "components/ILIAS/SurveyQuestionPool");
493 $this->show_layout_row = true;
494 $question_output = $this->getWorkingForm();
495 $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
496 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveLayout"));
497 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
498 }
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)

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

+ Here is the call graph for this function:

◆ saveLayout()

SurveyMatrixQuestionGUI::saveLayout ( )

Saves the layout for the matrix question.

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

503 : void
504 {
505 $percent_values = array(
506 "percent_row" => $this->request->getPercentRow(),
507 "percent_columns" => $this->request->getPercentColumns(),
508 "percent_bipolar_adjective1" => $this->request->getPercentBipAdj1(),
509 "percent_bipolar_adjective2" => $this->request->getPercentBipAdj2(),
510 "percent_neutral" => $this->request->getPercentNeutral()
511 );
512 $this->object->setLayout($percent_values);
513
514 // #9364
515 if (array_sum($percent_values) == 100) {
516 $this->object->saveLayout(
517 $percent_values["percent_row"],
518 $percent_values['percent_columns'],
519 $percent_values['percent_bipolar_adjective1'],
520 $percent_values['percent_bipolar_adjective2'],
521 $percent_values["percent_neutral"]
522 );
523 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
524 } else {
525 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_matrix_layout_percentages_sum_invalid"));
526 }
527 $this->layout();
528 }
layout()
Creates a layout view of the question.

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setQuestionTabs()

SurveyMatrixQuestionGUI::setQuestionTabs ( )

Reimplemented from SurveyQuestionGUI.

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

38 : void
39 {
40 $this->setQuestionTabsForClass("surveymatrixquestiongui");
41 }
setQuestionTabsForClass(string $guiclass)

References SurveyQuestionGUI\setQuestionTabsForClass().

+ Here is the call graph for this function:

Field Documentation

◆ $show_layout_row

bool SurveyMatrixQuestionGUI::$show_layout_row = false
protected

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


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