ILIAS  release_8 Revision v8.24
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)
 
 material (bool $checkonly=false)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase (bool $a_reload=false)
 Creates an output to save the current answers as a phrase. More...
 
 confirmSavePhrase ()
 Save a new phrase to the database. More...
 

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)
 
 getMaterialOutput ()
 Creates the HTML output of the question material(s) More...
 
 initPhrasesForm ()
 
 addPhrase (ilPropertyFormGUI $a_form=null)
 Creates an output for the addition of phrases. More...
 
 addSelectedPhrase ()
 
 renderStatisticsDetailsTable (array $a_head, array $a_rows, array $a_foot=null)
 

Protected Attributes

bool $show_layout_row = false
 
- Protected Attributes inherited from SurveyQuestionGUI
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

Reimplemented from SurveyQuestionGUI.

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

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 $columns->setShowSavePhrase(true);
101 $a_form->addItem($columns);
102
103
104 $header = new ilFormSectionHeaderGUI();
105 $header->setTitle($this->lng->txt("matrix_column_settings"));
106 $a_form->addItem($header);
107
108 // bipolar adjectives
109 $bipolar = new ilCustomInputGUI($this->lng->txt("matrix_bipolar_adjectives"));
110 $bipolar->setInfo($this->lng->txt("matrix_bipolar_adjectives_description"));
111
112 // left pole
113 $bipolar1 = new ilTextInputGUI($this->lng->txt("matrix_left_pole"), "bipolar1");
114 $bipolar1->setRequired(false);
115 $bipolar->addSubItem($bipolar1);
116
117 // right pole
118 $bipolar2 = new ilTextInputGUI($this->lng->txt("matrix_right_pole"), "bipolar2");
119 $bipolar2->setRequired(false);
120 $bipolar->addSubItem($bipolar2);
121
122 $a_form->addItem($bipolar);
123
124
125 $header = new ilFormSectionHeaderGUI();
126 $header->setTitle($this->lng->txt("matrix_rows"));
127 $a_form->addItem($header);
128
129 // matrix rows
130 $rows = new ilMatrixRowWizardInputGUI("", "rows");
131 $rows->setRequired(false);
132 $rows->setAllowMove(true);
133 $rows->setLabelText($this->lng->txt('label'));
134 $rows->setUseOtherAnswer(true);
135 $a_form->addItem($rows);
136
137
138 // values
139 $subtype->setValue($this->object->getSubtype());
140 $column_separators->setChecked($this->object->getColumnSeparators());
141 $row_separators->setChecked($this->object->getRowSeparators());
142 $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
143
144 if (!$this->object->getColumnCount()) {
145 $this->object->columns->addCategory("");
146 }
147 $columns->setValues($this->object->getColumns());
148
149 $bipolar1->setValue($this->object->getBipolarAdjective(0));
150 $bipolar2->setValue($this->object->getBipolarAdjective(1));
151
152 if ($this->object->getRowCount() === 0) {
153 $this->object->getRows()->addCategory("");
154 }
155 $rows->setValues($this->object->getRows());
156 }
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 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...
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
$rows
Definition: xhr_table.php:10

References $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 517 of file class.SurveyMatrixQuestionGUI.php.

517 : string
518 {
519 $percent_values = $this->object->getLayout();
520 $template = new ilTemplate("tpl.il_svy_out_matrix_layout.html", true, true, "Modules/SurveyQuestionPool");
521 if ($this->object->getBipolarAdjective(0) !== '' && $this->object->getBipolarAdjective(1) !== '') {
522 $template->setCurrentBlock("bipolar_start");
523 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE1", " value=\"" . $percent_values["percent_bipolar_adjective1"] . "\"");
524 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective1"] . "%\"");
525 $template->parseCurrentBlock();
526 $template->setCurrentBlock("bipolar_end");
527 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE2", " value=\"" . $percent_values["percent_bipolar_adjective2"] . "\"");
528 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective2"] . "%\"");
529 $template->parseCurrentBlock();
530 }
531 $counter = $this->object->getColumnCount();
532 if ($this->object->hasNeutralColumn()) {
533 $template->setCurrentBlock("neutral_start");
534 $template->setVariable("VALUE_PERCENT_NEUTRAL", " value=\"" . $percent_values["percent_neutral"] . "\"");
535 $template->setVariable("STYLE_NEUTRAL", " style=\"width:" . $percent_values["percent_neutral"] . "%\"");
536 $template->parseCurrentBlock();
537 $counter--;
538 }
539 $template->setVariable("VALUE_PERCENT_ROW", " value=\"" . $percent_values["percent_row"] . "\"");
540 $template->setVariable("STYLE_ROW", " style=\"width:" . $percent_values["percent_row"] . "%\"");
541 $template->setVariable("COLSPAN_COLUMNS", $counter);
542 $template->setVariable("VALUE_PERCENT_COLUMNS", " value=\"" . $percent_values["percent_columns"] . "\"");
543 $template->setVariable("STYLE_COLUMNS", " style=\"width:" . $percent_values["percent_columns"] . "%\"");
544 return $template->get();
545 }
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 198 of file class.SurveyMatrixQuestionGUI.php.

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

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

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

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

◆ importEditFormValues()

SurveyMatrixQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

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

References ILIAS\LTI\ToolProvider\$key, $rows, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyMatrixQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

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

470 : void
471 {
472 $ilTabs = $this->tabs;
473
474 $ilTabs->activateTab("layout");
475
476 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_layout.html", "Modules/SurveyQuestionPool");
477 $this->show_layout_row = true;
478 $question_output = $this->getWorkingForm();
479 $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
480 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveLayout"));
481 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
482 }
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 487 of file class.SurveyMatrixQuestionGUI.php.

487 : void
488 {
489 $percent_values = array(
490 "percent_row" => $this->request->getPercentRow(),
491 "percent_columns" => $this->request->getPercentColumns(),
492 "percent_bipolar_adjective1" => $this->request->getPercentBipAdj1(),
493 "percent_bipolar_adjective2" => $this->request->getPercentBipAdj2(),
494 "percent_neutral" => $this->request->getPercentNeutral()
495 );
496 $this->object->setLayout($percent_values);
497
498 // #9364
499 if (array_sum($percent_values) == 100) {
500 $this->object->saveLayout(
501 $percent_values["percent_row"],
502 $percent_values['percent_columns'],
503 $percent_values['percent_bipolar_adjective1'],
504 $percent_values['percent_bipolar_adjective2'],
505 $percent_values["percent_neutral"]
506 );
507 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
508 } else {
509 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_matrix_layout_percentages_sum_invalid"));
510 }
511 $this->layout();
512 }
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 36 of file class.SurveyMatrixQuestionGUI.php.

36 : void
37 {
38 $this->setQuestionTabsForClass("surveymatrixquestiongui");
39 }
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 25 of file class.SurveyMatrixQuestionGUI.php.


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