ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SurveyMatrixQuestionGUI Class Reference

Matrix question GUI representation. More...

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

Public Member Functions

 setQuestionTabs ()
 
 getParsedAnswers (array $a_working_data=null, $a_only_user_anwers=false)
 
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
 Creates a HTML representation of the question. More...
 
 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 ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 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 ($a_url)
 
 setQuestionTabsForClass ($guiclass)
 
 getPrintView ($question_title=1, $show_questiontext=1)
 
 preview ()
 Creates a preview of the question. More...
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 
 material ($checkonly=false)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase ($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 ($template)
 
 initEditForm ()
 
 addCommandButtons ($a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save ($a_return=false, $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving ($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 ($question_title=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

 $show_layout_row
 
- Protected Attributes inherited from SurveyQuestionGUI
 $rbacsystem
 
 $user
 
 $access
 
 $tree
 
 $toolbar
 
 $tabs
 
 $tpl
 
 $lng
 
 $ctrl
 
 $cumulated
 
 $parent_url
 
 $log
 

Additional Inherited Members

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

Detailed Description

Matrix question GUI representation.

The SurveyMatrixQuestionGUI class encapsulates the GUI representation for matrix question types.

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
Version
$Id$

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

Member Function Documentation

◆ addFieldsToEditForm()

SurveyMatrixQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

58 {
59 // subtype
60 $subtype = new ilRadioGroupInputGUI($this->lng->txt("subtype"), "type");
61 $subtype->setRequired(false);
62 $subtypes = array(
63 "0" => "matrix_subtype_sr",
64 "1" => "matrix_subtype_mr",
65 //"2" => "matrix_subtype_text",
66 //"3" => "matrix_subtype_integer",
67 //"4" => "matrix_subtype_double",
68 //"5" => "matrix_subtype_date",
69 //"6" => "matrix_subtype_time"
70 );
71 foreach ($subtypes as $idx => $st) {
72 $subtype->addOption(new ilRadioOption($this->lng->txt($st), $idx));
73 }
74 $a_form->addItem($subtype);
75
76
78 $header->setTitle($this->lng->txt("matrix_appearance"));
79 $a_form->addItem($header);
80
81 // column separators
82 $column_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_column_separators"), "column_separators");
83 $column_separators->setValue(1);
84 $column_separators->setInfo($this->lng->txt("matrix_column_separators_description"));
85 $column_separators->setRequired(false);
86 $a_form->addItem($column_separators);
87
88 // row separators
89 $row_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_row_separators"), "row_separators");
90 $row_separators->setValue(1);
91 $row_separators->setInfo($this->lng->txt("matrix_row_separators_description"));
92 $row_separators->setRequired(false);
93 $a_form->addItem($row_separators);
94
95 // neutral column separators
96 $neutral_column_separator = new ilCheckboxInputGUI($this->lng->txt("matrix_neutral_column_separator"), "neutral_column_separator");
97 $neutral_column_separator->setValue(1);
98 $neutral_column_separator->setInfo($this->lng->txt("matrix_neutral_column_separator_description"));
99 $neutral_column_separator->setRequired(false);
100 $a_form->addItem($neutral_column_separator);
101
102
104 $header->setTitle($this->lng->txt("matrix_columns"));
105 $a_form->addItem($header);
106
107 // Answers
108 include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
109 $columns = new ilCategoryWizardInputGUI("", "columns");
110 $columns->setRequired(false);
111 $columns->setAllowMove(true);
112 $columns->setShowWizard(true);
113 $columns->setShowNeutralCategory(true);
114 $columns->setDisabledScale(false);
115 $columns->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
116 $columns->setCategoryText($this->lng->txt('matrix_standard_answers'));
117 $columns->setShowSavePhrase(true);
118 $a_form->addItem($columns);
119
120
122 $header->setTitle($this->lng->txt("matrix_column_settings"));
123 $a_form->addItem($header);
124
125 // bipolar adjectives
126 $bipolar = new ilCustomInputGUI($this->lng->txt("matrix_bipolar_adjectives"));
127 $bipolar->setInfo($this->lng->txt("matrix_bipolar_adjectives_description"));
128
129 // left pole
130 $bipolar1 = new ilTextInputGUI($this->lng->txt("matrix_left_pole"), "bipolar1");
131 $bipolar1->setRequired(false);
132 $bipolar->addSubItem($bipolar1);
133
134 // right pole
135 $bipolar2 = new ilTextInputGUI($this->lng->txt("matrix_right_pole"), "bipolar2");
136 $bipolar2->setRequired(false);
137 $bipolar->addSubItem($bipolar2);
138
139 $a_form->addItem($bipolar);
140
141
143 $header->setTitle($this->lng->txt("matrix_rows"));
144 $a_form->addItem($header);
145
146 // matrix rows
147 include_once "./Modules/SurveyQuestionPool/classes/class.ilMatrixRowWizardInputGUI.php";
148 $rows = new ilMatrixRowWizardInputGUI("", "rows");
149 $rows->setRequired(false);
150 $rows->setAllowMove(true);
151 $rows->setLabelText($this->lng->txt('label'));
152 $rows->setUseOtherAnswer(true);
153 $a_form->addItem($rows);
154
155
156 // values
157 $subtype->setValue($this->object->getSubtype());
158 $column_separators->setChecked($this->object->getColumnSeparators());
159 $row_separators->setChecked($this->object->getRowSeparators());
160 $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
161
162 if (!$this->object->getColumnCount()) {
163 $this->object->columns->addCategory("");
164 }
165 $columns->setValues($this->object->getColumns());
166
167 $bipolar1->setValue($this->object->getBipolarAdjective(0));
168 $bipolar2->setValue($this->object->getBipolarAdjective(1));
169
170 if ($this->object->getRowCount() == 0) {
171 $this->object->getRows()->addCategory("");
172 }
173 $rows->setValues($this->object->getRows());
174 }
if(! $in) $columns
Definition: Utf8Test.php:45
This class represents a survey question category wizard property in a property form.
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 class represents a survey question category wizard property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
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.
$rows
Definition: xhr_table.php:10

References $columns, $header, $rows, and ilPropertyFormGUI\addItem().

+ Here is the call graph for this function:

◆ getLayoutRow()

SurveyMatrixQuestionGUI::getLayoutRow ( )

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

@access public

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

551 {
552 $percent_values = $this->object->getLayout();
553 $template = new ilTemplate("tpl.il_svy_out_matrix_layout.html", true, true, "Modules/SurveyQuestionPool");
554 if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1))) {
555 $template->setCurrentBlock("bipolar_start");
556 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE1", " value=\"" . $percent_values["percent_bipolar_adjective1"] . "\"");
557 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective1"] . "%\"");
558 $template->parseCurrentBlock();
559 $template->setCurrentBlock("bipolar_end");
560 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE2", " value=\"" . $percent_values["percent_bipolar_adjective2"] . "\"");
561 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective2"] . "%\"");
562 $template->parseCurrentBlock();
563 }
564 $counter = $this->object->getColumnCount();
565 if (strlen($this->object->hasNeutralColumn())) {
566 $template->setCurrentBlock("neutral_start");
567 $template->setVariable("VALUE_PERCENT_NEUTRAL", " value=\"" . $percent_values["percent_neutral"] . "\"");
568 $template->setVariable("STYLE_NEUTRAL", " style=\"width:" . $percent_values["percent_neutral"] . "%\"");
569 $template->parseCurrentBlock();
570 $counter--;
571 }
572 $template->setVariable("VALUE_PERCENT_ROW", " value=\"" . $percent_values["percent_row"] . "\"");
573 $template->setVariable("STYLE_ROW", " style=\"width:" . $percent_values["percent_row"] . "%\"");
574 $template->setVariable("COLSPAN_COLUMNS", $counter);
575 $template->setVariable("VALUE_PERCENT_COLUMNS", " value=\"" . $percent_values["percent_columns"] . "\"");
576 $template->setVariable("STYLE_COLUMNS", " style=\"width:" . $percent_values["percent_columns"] . "%\"");
577 return $template->get();
578 }
special template class to simplify handling of ITX/PEAR
$counter
$template

References $counter, and $template.

Referenced by getPrintView(), and getWorkingForm().

+ Here is the caller graph for this function:

◆ getParsedAnswers()

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

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

209 {
210 if (is_array($a_working_data)) {
211 $user_answers = $a_working_data;
212 }
213
214 $options = array();
215 for ($i = 0; $i < $this->object->getRowCount(); $i++) {
216 $rowobj = $this->object->getRow($i);
217
218 $text = null;
219
220 $cols = array();
221 for ($j = 0; $j < $this->object->getColumnCount(); $j++) {
222 $cat = $this->object->getColumn($j);
223 $value = ($cat->scale) ? ($cat->scale - 1) : $j;
224
225 $checked = "unchecked";
226 if (is_array($a_working_data)) {
227 foreach ($user_answers as $user_answer) {
228 if ($user_answer["rowvalue"] == $i &&
229 $user_answer["value"] == $value) {
230 $checked = "checked";
231 if ($user_answer["textanswer"]) {
232 $text = $user_answer["textanswer"];
233 }
234 }
235 }
236 }
237
238 if (!$a_only_user_anwers || $checked == "checked") {
239 $cols[$value] = array(
240 "title" => trim($cat->title)
241 ,"neutral" => (bool) $cat->neutral
242 ,"checked" => $checked
243 );
244 }
245 }
246
247 if ($a_only_user_anwers || sizeof($cols) || $text) {
248 $row_idx = $i;
249 $options[$row_idx] = array(
250 "title" => trim($rowobj->title)
251 ,"other" => (bool) $rowobj->other
252 ,"textanswer" => $text
253 ,"cols" => $cols
254 );
255 }
256 }
257
258 return $options;
259 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$i
Definition: disco.tpl.php:19
$text
Definition: errorreport.php:18
$cols
Definition: xhr_table.php:11

References $cols, $i, $options, and $text.

Referenced by getPrintView().

+ Here is the caller graph for this function:

◆ getPrintView()

SurveyMatrixQuestionGUI::getPrintView (   $question_title = 1,
  $show_questiontext = 1,
  $survey_id = null,
array  $a_working_data = null 
)

Creates a HTML representation of the question.

@access private

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

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

References $i, $layout, $options, $style, $template, $text, ilUtil\getHtmlPath(), ilUtil\getImagePath(), getLayoutRow(), getParsedAnswers(), SurveyQuestionGUI\getPrintViewQuestionTitle(), SurveyQuestionGUI\outQuestionText(), ilUtil\prepareFormOutput(), and sprintf.

+ Here is the call graph for this function:

◆ getWorkingForm()

SurveyMatrixQuestionGUI::getWorkingForm (   $working_data = "",
  $question_title = 1,
  $show_questiontext = 1,
  $error_message = "",
  $survey_id = null 
)

Creates the question output form for the learner.

@access public

Reimplemented from SurveyQuestionGUI.

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

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

References $data, $i, $layout, $style, $template, getLayoutRow(), SurveyQuestionGUI\getMaterialOutput(), SurveyQuestionGUI\outQuestionText(), ilUtil\prepareFormOutput(), and sprintf.

Referenced by layout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importEditFormValues()

SurveyMatrixQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

177 {
178 $this->object->setSubtype($a_form->getInput("type"));
179 $this->object->setRowSeparators($a_form->getInput("row_separators") ? 1 : 0);
180 $this->object->setColumnSeparators($a_form->getInput("column_separators") ? 1 : 0);
181 $this->object->setNeutralColumnSeparator($a_form->getInput("neutral_column_separator") ? 1 : 0);
182
183 // Set bipolar adjectives
184 $this->object->setBipolarAdjective(0, $a_form->getInput("bipolar1"));
185 $this->object->setBipolarAdjective(1, $a_form->getInput("bipolar2"));
186
187 // set columns
188 $this->object->flushColumns();
189
190 foreach ($_POST['columns']['answer'] as $key => $value) {
191 if (strlen($value)) {
192 $this->object->getColumns()->addCategory($value, $_POST['columns']['other'][$key], 0, null, $_POST['columns']['scale'][$key]);
193 }
194 }
195 if (strlen($_POST["columns"]["neutral"])) {
196 $this->object->getColumns()->addCategory($_POST['columns']['neutral'], 0, 1, null, $_POST['columns_neutral_scale']);
197 }
198
199 // set rows
200 $this->object->flushRows();
201 foreach ($_POST['rows']['answer'] as $key => $value) {
202 if (strlen($value)) {
203 $this->object->getRows()->addCategory($value, $_POST['rows']['other'][$key], 0, $_POST['rows']['label'][$key]);
204 }
205 }
206 }
$_POST["username"]
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
$key
Definition: croninfo.php:18

References $_POST, $key, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyMatrixQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

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

42 {
43 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyMatrixQuestion.php";
44 $this->object = new SurveyMatrixQuestion();
45 }
The SurveyMatrixQuestion class defines and encapsulates basic methods and attributes for matrix quest...

◆ layout()

SurveyMatrixQuestionGUI::layout ( )

Creates a layout view of the question.

@access public

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

500 {
501 $ilTabs = $this->tabs;
502
503 $ilTabs->activateTab("layout");
504
505 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_layout.html", "Modules/SurveyQuestionPool");
506 $this->show_layout_row = true;
507 $question_output = $this->getWorkingForm();
508 $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
509 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveLayout"));
510 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
511 }
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
Creates the question output form for the learner.

References SurveyQuestionGUI\$tabs, and getWorkingForm().

Referenced by saveLayout().

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

Returns
void

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

519 {
520 $percent_values = array(
521 "percent_row" => (int) $_POST["percent_row"],
522 "percent_columns" => (int) $_POST["percent_columns"],
523 "percent_bipolar_adjective1" => (int) $_POST['percent_bipolar_adjective1'],
524 "percent_bipolar_adjective2" => (int) $_POST['percent_bipolar_adjective2'],
525 "percent_neutral" => (int) $_POST["percent_neutral"]
526 );
527 $this->object->setLayout($percent_values);
528
529 // #9364
530 if (array_sum($percent_values) == 100) {
531 $this->object->saveLayout(
532 $percent_values["percent_row"],
533 $percent_values['percent_columns'],
534 $percent_values['percent_bipolar_adjective1'],
535 $percent_values['percent_bipolar_adjective2'],
536 $percent_values["percent_neutral"]
537 );
538 ilUtil::sendSuccess($this->lng->txt("settings_saved"));
539 } else {
540 ilUtil::sendFailure($this->lng->txt("svy_matrix_layout_percentages_sum_invalid"));
541 }
542 $this->layout();
543 }
layout()
Creates a layout view of the question.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $_POST, layout(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ setQuestionTabs()

SurveyMatrixQuestionGUI::setQuestionTabs ( )

Reimplemented from SurveyQuestionGUI.

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

53 {
54 $this->setQuestionTabsForClass("surveymatrixquestiongui");
55 }

References SurveyQuestionGUI\setQuestionTabsForClass().

+ Here is the call graph for this function:

Field Documentation

◆ $show_layout_row

SurveyMatrixQuestionGUI::$show_layout_row
protected

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


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