ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 $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

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

References $columns, $header, ilPropertyFormGUI\addItem(), array, object, ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), and ilCheckboxInputGUI\setValue().

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  {
73  $subtype->addOption(new ilRadioOption($this->lng->txt($st), $idx));
74  }
75  $a_form->addItem($subtype);
76 
77 
79  $header->setTitle($this->lng->txt("matrix_appearance"));
80  $a_form->addItem($header);
81 
82  // column separators
83  $column_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_column_separators"), "column_separators");
84  $column_separators->setValue(1);
85  $column_separators->setInfo($this->lng->txt("matrix_column_separators_description"));
86  $column_separators->setRequired(false);
87  $a_form->addItem($column_separators);
88 
89  // row separators
90  $row_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_row_separators"), "row_separators");
91  $row_separators->setValue(1);
92  $row_separators->setInfo($this->lng->txt("matrix_row_separators_description"));
93  $row_separators->setRequired(false);
94  $a_form->addItem($row_separators);
95 
96  // neutral column separators
97  $neutral_column_separator = new ilCheckboxInputGUI($this->lng->txt("matrix_neutral_column_separator"), "neutral_column_separator");
98  $neutral_column_separator->setValue(1);
99  $neutral_column_separator->setInfo($this->lng->txt("matrix_neutral_column_separator_description"));
100  $neutral_column_separator->setRequired(false);
101  $a_form->addItem($neutral_column_separator);
102 
103 
105  $header->setTitle($this->lng->txt("matrix_columns"));
106  $a_form->addItem($header);
107 
108  // Answers
109  include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
110  $columns = new ilCategoryWizardInputGUI("", "columns");
111  $columns->setRequired(false);
112  $columns->setAllowMove(true);
113  $columns->setShowWizard(true);
114  $columns->setShowNeutralCategory(true);
115  $columns->setDisabledScale(false);
116  $columns->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
117  $columns->setCategoryText($this->lng->txt('matrix_standard_answers'));
118  $columns->setShowSavePhrase(true);
119  $a_form->addItem($columns);
120 
121 
123  $header->setTitle($this->lng->txt("matrix_column_settings"));
124  $a_form->addItem($header);
125 
126  // bipolar adjectives
127  $bipolar = new ilCustomInputGUI($this->lng->txt("matrix_bipolar_adjectives"));
128  $bipolar->setInfo($this->lng->txt("matrix_bipolar_adjectives_description"));
129 
130  // left pole
131  $bipolar1 = new ilTextInputGUI($this->lng->txt("matrix_left_pole"), "bipolar1");
132  $bipolar1->setRequired(false);
133  $bipolar->addSubItem($bipolar1);
134 
135  // right pole
136  $bipolar2 = new ilTextInputGUI($this->lng->txt("matrix_right_pole"), "bipolar2");
137  $bipolar2->setRequired(false);
138  $bipolar->addSubItem($bipolar2);
139 
140  $a_form->addItem($bipolar);
141 
142 
144  $header->setTitle($this->lng->txt("matrix_rows"));
145  $a_form->addItem($header);
146 
147  // matrix rows
148  include_once "./Modules/SurveyQuestionPool/classes/class.ilMatrixRowWizardInputGUI.php";
149  $rows = new ilMatrixRowWizardInputGUI("", "rows");
150  $rows->setRequired(false);
151  $rows->setAllowMove(true);
152  $rows->setLabelText($this->lng->txt('label'));
153  $rows->setUseOtherAnswer(true);
154  $a_form->addItem($rows);
155 
156 
157  // values
158  $subtype->setValue($this->object->getSubtype());
159  $column_separators->setChecked($this->object->getColumnSeparators());
160  $row_separators->setChecked($this->object->getRowSeparators());
161  $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
162 
163  if (!$this->object->getColumnCount())
164  {
165  $this->object->columns->addCategory("");
166  }
167  $columns->setValues($this->object->getColumns());
168 
169  $bipolar1->setValue($this->object->getBipolarAdjective(0));
170  $bipolar2->setValue($this->object->getBipolarAdjective(1));
171 
172  if ($this->object->getRowCount() == 0)
173  {
174  $this->object->getRows()->addCategory("");
175  }
176  $rows->setValues($this->object->getRows());
177  }
This class represents an option in a radio group.
This class represents a section header in a property form.
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
$header
setValue($a_value)
Set Value.
This class represents a text property in a property form.
This class represents a survey question category wizard property in a property form.
Create styles array
The data for the language used.
This class represents a survey question category wizard property in a property form.
This class represents a custom property in a property form.
Create new PHPExcel object
obj_idprivate
if(! $in) $columns
Definition: Utf8Test.php:45
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ getLayoutRow()

SurveyMatrixQuestionGUI::getLayoutRow ( )

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

public

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

References $counter, and object.

Referenced by getPrintView(), and getWorkingForm().

620  {
621  $percent_values = $this->object->getLayout();
622  $template = new ilTemplate("tpl.il_svy_out_matrix_layout.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
623  if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1)))
624  {
625  $template->setCurrentBlock("bipolar_start");
626  $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE1", " value=\"" . $percent_values["percent_bipolar_adjective1"] . "\"");
627  $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective1"] . "%\"");
628  $template->parseCurrentBlock();
629  $template->setCurrentBlock("bipolar_end");
630  $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE2", " value=\"" . $percent_values["percent_bipolar_adjective2"] . "\"");
631  $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective2"] . "%\"");
632  $template->parseCurrentBlock();
633  }
634  $counter = $this->object->getColumnCount();
635  if (strlen($this->object->hasNeutralColumn()))
636  {
637  $template->setCurrentBlock("neutral_start");
638  $template->setVariable("VALUE_PERCENT_NEUTRAL", " value=\"" . $percent_values["percent_neutral"] . "\"");
639  $template->setVariable("STYLE_NEUTRAL", " style=\"width:" . $percent_values["percent_neutral"] . "%\"");
640  $template->parseCurrentBlock();
641  $counter--;
642  }
643  $template->setVariable("VALUE_PERCENT_ROW", " value=\"" . $percent_values["percent_row"] . "\"");
644  $template->setVariable("STYLE_ROW", " style=\"width:" . $percent_values["percent_row"] . "%\"");
645  $template->setVariable("COLSPAN_COLUMNS", $counter);
646  $template->setVariable("VALUE_PERCENT_COLUMNS", " value=\"" . $percent_values["percent_columns"] . "\"");
647  $template->setVariable("STYLE_COLUMNS", " style=\"width:" . $percent_values["percent_columns"] . "%\"");
648  return $template->get();
649  }
$counter
special template class to simplify handling of ITX/PEAR
Create new PHPExcel object
obj_idprivate
+ Here is the caller graph for this function:

◆ getParsedAnswers()

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

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

References $options, $text, and array.

Referenced by getPrintView().

211  {
212  if(is_array($a_working_data))
213  {
214  $user_answers = $a_working_data;
215  }
216 
217  $options = array();
218  for ($i = 0; $i < $this->object->getRowCount(); $i++)
219  {
220  $rowobj = $this->object->getRow($i);
221 
222  $text = null;
223 
224  $cols = array();
225  for ($j = 0; $j < $this->object->getColumnCount(); $j++)
226  {
227  $cat = $this->object->getColumn($j);
228  $value = ($cat->scale) ? ($cat->scale - 1) : $j;
229 
230  $checked = "unchecked";
231  if(is_array($a_working_data))
232  {
233  foreach($user_answers as $user_answer)
234  {
235  if($user_answer["rowvalue"] == $i &&
236  $user_answer["value"] == $value)
237  {
238  $checked = "checked";
239  if($user_answer["textanswer"])
240  {
241  $text = $user_answer["textanswer"];
242  }
243  }
244  }
245  }
246 
247  if(!$a_only_user_anwers || $checked == "checked")
248  {
249  $cols[$value] = array(
250  "title" => trim($cat->title)
251  ,"neutral" => (bool)$cat->neutral
252  ,"checked" => $checked
253  );
254  }
255  }
256 
257  if($a_only_user_anwers || sizeof($cols) || $text)
258  {
259  $row_idx = $i;
260  $options[$row_idx] = array(
261  "title" => trim($rowobj->title)
262  ,"other" => (bool)$rowobj->other
263  ,"textanswer" => $text
264  ,"cols" => $cols
265  );
266  }
267  }
268 
269  return $options;
270  }
if(!is_array($argv)) $options
Create styles array
The data for the language used.
$text
+ 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.

private

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

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

278  {
279  $options = $this->getParsedAnswers($a_working_data);
280 
281  $layout = $this->object->getLayout();
282  $neutralstyle = "3px solid #808080";
283  $bordercolor = "#808080";
284  $template = new ilTemplate("tpl.il_svy_qpl_matrix_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
285 
286  if ($this->show_layout_row)
287  {
288  $layout_row = $this->getLayoutRow();
289  $template->setCurrentBlock("matrix_row");
290  $template->setVariable("ROW", $layout_row);
291  $template->parseCurrentBlock();
292  }
293 
294  $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
295  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
296  {
297  $tplheaders->setCurrentBlock("bipolar_start");
298  $style = array();
299  array_push($style, sprintf("width: %.2F%s!important", $layout["percent_bipolar_adjective1"], "%"));
300  if (count($style) > 0)
301  {
302  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
303  }
304  $tplheaders->parseCurrentBlock();
305  }
306  // column headers
307  for ($i = 0; $i < $this->object->getColumnCount(); $i++)
308  {
309  $cat = $this->object->getColumn($i);
310  if ($cat->neutral)
311  {
312  $tplheaders->setCurrentBlock("neutral_column_header");
313  $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($cat->title));
314  $tplheaders->setVariable("CLASS", "rsep");
315  $style = array();
316  array_push($style, sprintf("width: %.2F%s!important", $layout["percent_neutral"], "%"));
317  if ($this->object->getNeutralColumnSeparator())
318  {
319  array_push($style, "border-left: $neutralstyle!important;");
320  }
321  if (count($style) > 0)
322  {
323  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
324  }
325  $tplheaders->parseCurrentBlock();
326  }
327  else
328  {
329  $style = array();
330  if ($this->object->getColumnSeparators() == 1)
331  {
332  if (($i < $this->object->getColumnCount() - 1))
333  {
334  array_push($style, "border-right: 1px solid $bordercolor!important");
335  }
336  }
337  array_push($style, sprintf("width: %.2F%s!important", $layout["percent_columns"] / $this->object->getColumnCount(), "%"));
338  $tplheaders->setCurrentBlock("column_header");
339  $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($cat->title));
340  $tplheaders->setVariable("CLASS", "center");
341  if (count($style) > 0)
342  {
343  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
344  }
345  $tplheaders->parseCurrentBlock();
346  }
347  }
348 
349  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
350  {
351  $tplheaders->setCurrentBlock("bipolar_end");
352  $style = array();
353  array_push($style, sprintf("width: %.2F%s!important", $layout["percent_bipolar_adjective2"], "%"));
354  if (count($style) > 0)
355  {
356  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
357  }
358  $tplheaders->parseCurrentBlock();
359  }
360 
361  $style = array();
362  array_push($style, sprintf("width: %.2F%s!important", $layout["percent_row"], "%"));
363  if (count($style) > 0)
364  {
365  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
366  }
367 
368  $template->setCurrentBlock("matrix_row");
369  $template->setVariable("ROW", $tplheaders->get());
370  $template->parseCurrentBlock();
371 
372  $rowclass = array("tblrow1", "tblrow2");
373 
374  for ($i = 0; $i < $this->object->getRowCount(); $i++)
375  {
376  $rowobj = $this->object->getRow($i);
377  $tplrow = new ilTemplate("tpl.il_svy_qpl_matrix_printview_row.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
378  for ($j = 0; $j < $this->object->getColumnCount(); $j++)
379  {
380  $cat = $this->object->getColumn($j);
381  if (($i == 0) && ($j == 0))
382  {
383  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
384  {
385  $tplrow->setCurrentBlock("bipolar_start");
386  $tplrow->setVariable("TEXT_BIPOLAR_START", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(0)));
387  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
388  $tplrow->parseCurrentBlock();
389  }
390  }
391  if (($i == 0) && ($j == $this->object->getColumnCount()-1))
392  {
393  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
394  {
395  $tplrow->setCurrentBlock("bipolar_end");
396  $tplrow->setVariable("TEXT_BIPOLAR_END", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(1)));
397  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
398  $tplrow->parseCurrentBlock();
399  }
400  }
401 
402  $value = ($cat->scale) ? ($cat->scale - 1) : $j;
403  $col = $options[$i]["cols"][$value];
404 
405  switch ($this->object->getSubtype())
406  {
407  case 0:
408  if ($cat->neutral)
409  {
410  $tplrow->setCurrentBlock("neutral_radiobutton");
411  $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_".$col["checked"].".png")));
412  $tplrow->setVariable("ALT_RADIO", $this->lng->txt($col["checked"]));
413  $tplrow->setVariable("TITLE_RADIO", $this->lng->txt($col["checked"]));
414  $tplrow->parseCurrentBlock();
415  }
416  else
417  {
418  $tplrow->setCurrentBlock("radiobutton");
419  $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_".$col["checked"].".png")));
420  $tplrow->setVariable("ALT_RADIO", $this->lng->txt($col["checked"]));
421  $tplrow->setVariable("TITLE_RADIO", $this->lng->txt($col["checked"]));
422  $tplrow->parseCurrentBlock();
423  }
424  break;
425  case 1:
426  if ($cat->neutral)
427  {
428  $tplrow->setCurrentBlock("neutral_checkbox");
429  $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_".$col["checked"].".png")));
430  $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt($col["checked"]));
431  $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt($col["checked"]));
432  $tplrow->parseCurrentBlock();
433  }
434  else
435  {
436  $tplrow->setCurrentBlock("checkbox");
437  $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_".$col["checked"].".png")));
438  $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt($col["checked"]));
439  $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt($col["checked"]));
440  $tplrow->parseCurrentBlock();
441  }
442  break;
443  }
444  if ($cat->neutral)
445  {
446  $tplrow->setCurrentBlock("neutral_answer");
447  $style = array();
448  if ($this->object->getNeutralColumnSeparator())
449  {
450  array_push($style, "border-left: $neutralstyle!important");
451  }
452  if ($this->object->getColumnSeparators() == 1)
453  {
454  if ($j < $this->object->getColumnCount() - 1)
455  {
456  array_push($style, "border-right: 1px solid $bordercolor!important");
457  }
458  }
459 
460  if ($this->object->getRowSeparators() == 1)
461  {
462  if ($i < $this->object->getRowCount() - 1)
463  {
464  array_push($style, "border-bottom: 1px solid $bordercolor!important");
465  }
466  }
467  if (count($style))
468  {
469  $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
470  }
471  $tplrow->parseCurrentBlock();
472  }
473  else
474  {
475  $tplrow->setCurrentBlock("answer");
476  $style = array();
477 
478  if ($this->object->getColumnSeparators() == 1)
479  {
480  if ($j < $this->object->getColumnCount() - 1)
481  {
482  array_push($style, "border-right: 1px solid $bordercolor!important");
483  }
484  }
485 
486  if ($this->object->getRowSeparators() == 1)
487  {
488  if ($i < $this->object->getRowCount() - 1)
489  {
490  array_push($style, "border-bottom: 1px solid $bordercolor!important");
491  }
492  }
493  if (count($style))
494  {
495  $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
496  }
497  $tplrow->parseCurrentBlock();
498  }
499  }
500 
501  if ($rowobj->other)
502  {
503  $text = $options[$i]["textanswer"];
504  $tplrow->setCurrentBlock("text_other");
505  $tplrow->setVariable("TEXT_OTHER", $text
506  ? $text
507  : "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
508  $tplrow->parseCurrentBlock();
509  }
510 
511  switch ($question_title)
512  {
513  case 1:
514  $row_title = ilUtil::prepareFormOutput($rowobj->title);
515  break;
516  #19448 matrix rows always contains the titles.(never only labels because they are optional)
517  /*case 2:
518  $row_title = ilUtil::prepareFormOutput($rowobj->label);
519  break;
520 
521  case 3:*/
522  default:
523  $row_title = ilUtil::prepareFormOutput($rowobj->title);
524  if(trim($rowobj->label))
525  {
526  $row_title .= ' <span class="questionLabel">('.ilUtil::prepareFormOutput($rowobj->label).')</span>';
527  }
528  break;
529  }
530  $tplrow->setVariable("TEXT_ROW", $row_title);
531  $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]);
532  if ($this->object->getRowSeparators() == 1)
533  {
534  if ($i < $this->object->getRowCount() - 1)
535  {
536  $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid $bordercolor!important\"");
537  }
538  }
539  $template->setCurrentBlock("matrix_row");
540  $template->setVariable("ROW", $tplrow->get());
541  $template->parseCurrentBlock();
542  }
543 
544  if ($question_title)
545  {
546  $template->setVariable("QUESTION_TITLE", $this->getPrintViewQuestionTitle($question_title));
547  }
548  $template->setCurrentBlock();
549  if ($show_questiontext)
550  {
551  $this->outQuestionText($template);
552  }
553  $template->parseCurrentBlock();
554  return $template->get();
555  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$style
Definition: example_012.php:70
if(!is_array($argv)) $options
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static getHtmlPath($relative_path)
get url of path
Create styles array
The data for the language used.
getLayoutRow()
Creates a row to define the matrix question layout with percentage values.
Create new PHPExcel object
obj_idprivate
$text
getPrintViewQuestionTitle($question_title=1)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
+ 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.

public

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

References $data, $layout, $style, array, getLayoutRow(), SurveyQuestionGUI\getMaterialOutput(), object, SurveyQuestionGUI\outQuestionText(), and ilUtil\prepareFormOutput().

Referenced by layout().

662  {
663  $layout = $this->object->getLayout();
664  $neutralstyle = "3px solid #808080";
665  $bordercolor = "#808080";
666  $template = new ilTemplate("tpl.il_svy_out_matrix.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
667  $template->setCurrentBlock("material_matrix");
668  $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
669  $template->parseCurrentBlock();
670 
671  if ($this->show_layout_row)
672  {
673  $layout_row = $this->getLayoutRow();
674  $template->setCurrentBlock("matrix_row");
675  $template->setVariable("ROW", $layout_row);
676  $template->parseCurrentBlock();
677  }
678 
679  $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
680  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
681  {
682  $tplheaders->setCurrentBlock("bipolar_start");
683  $style = array();
684  array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective1"], "%"));
685  if (count($style) > 0)
686  {
687  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
688  }
689  $tplheaders->parseCurrentBlock();
690  }
691  // column headers
692  for ($i = 0; $i < $this->object->getColumnCount(); $i++)
693  {
694  $style = array();
695  $col = $this->object->getColumn($i);
696  if ($col->neutral)
697  {
698  $tplheaders->setCurrentBlock("neutral_column_header");
699  $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($col->title));
700  $tplheaders->setVariable("CLASS", "rsep");
701  $style = array();
702  array_push($style, sprintf("width: %.2f%s!important", $layout["percent_neutral"], "%"));
703  if ($this->object->getNeutralColumnSeparator())
704  {
705  array_push($style, "border-left: $neutralstyle!important;");
706  }
707  if (count($style) > 0)
708  {
709  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
710  }
711  $tplheaders->parseCurrentBlock();
712  }
713  else
714  {
715  if ($this->object->getColumnSeparators() == 1)
716  {
717  if (($i < $this->object->getColumnCount() - 1))
718  {
719  array_push($style, "border-right: 1px solid $bordercolor!important");
720  }
721  }
722  array_push($style, sprintf("width: %.2f%s!important", $layout["percent_columns"] / $this->object->getColumnCount(), "%"));
723  $tplheaders->setCurrentBlock("column_header");
724  $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($col->title));
725  $tplheaders->setVariable("CLASS", "center");
726  if (count($style) > 0)
727  {
728  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
729  }
730  $tplheaders->parseCurrentBlock();
731  }
732  }
733  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
734  {
735  $tplheaders->setCurrentBlock("bipolar_end");
736  $style = array();
737  array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective2"], "%"));
738  if (count($style) > 0)
739  {
740  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
741  }
742  $tplheaders->parseCurrentBlock();
743  }
744 
745  $style = array();
746  array_push($style, sprintf("width: %.2f%s!important", $layout["percent_row"], "%"));
747  if (count($style) > 0)
748  {
749  $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
750  }
751 
752  $template->setCurrentBlock("matrix_row");
753  $template->setVariable("ROW", $tplheaders->get());
754  $template->parseCurrentBlock();
755 
756  $rowclass = array("tblrow1", "tblrow2");
757  for ($i = 0; $i < $this->object->getRowCount(); $i++)
758  {
759  $rowobj = $this->object->getRow($i);
760  $tplrow = new ilTemplate("tpl.il_svy_out_matrix_row.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
761  for ($j = 0; $j < $this->object->getColumnCount(); $j++)
762  {
763  $cat = $this->object->getColumn($j);
764  if (($i == 0) && ($j == 0))
765  {
766  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
767  {
768  $tplrow->setCurrentBlock("bipolar_start");
769  $tplrow->setVariable("TEXT_BIPOLAR_START", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(0)));
770  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
771  $tplrow->parseCurrentBlock();
772  }
773  }
774  if (($i == 0) && ($j == $this->object->getColumnCount()-1))
775  {
776  if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
777  {
778  $tplrow->setCurrentBlock("bipolar_end");
779  $tplrow->setVariable("TEXT_BIPOLAR_END", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(1)));
780  $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
781  $tplrow->parseCurrentBlock();
782  }
783  }
784  switch ($this->object->getSubtype())
785  {
786  case 0:
787  if ($cat->neutral)
788  {
789  $tplrow->setCurrentBlock("neutral_radiobutton");
790  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
791  $tplrow->setVariable("ROW", $i);
792  $tplrow->setVariable("VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
793  if (is_array($working_data))
794  {
795  foreach ($working_data as $data)
796  {
797  if (($data["value"] == $cat->scale-1) && ($data["rowvalue"] == $i))
798  {
799  $tplrow->setVariable("CHECKED_RADIOBUTTON", " checked=\"checked\"");
800  }
801  }
802  }
803  $tplrow->parseCurrentBlock();
804  }
805  else
806  {
807  $tplrow->setCurrentBlock("radiobutton");
808  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
809  $tplrow->setVariable("ROW", $i);
810  $tplrow->setVariable("VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
811  if (is_array($working_data))
812  {
813  foreach ($working_data as $data)
814  {
815  if (($data["value"] == $cat->scale-1) && ($data["rowvalue"] == $i))
816  {
817  $tplrow->setVariable("CHECKED_RADIOBUTTON", " checked=\"checked\"");
818  }
819  }
820  }
821  $tplrow->parseCurrentBlock();
822  }
823  break;
824  case 1:
825  if ($cat->neutral)
826  {
827  $tplrow->setCurrentBlock("neutral_checkbox");
828  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
829  $tplrow->setVariable("ROW", $i);
830  $tplrow->setVariable("VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
831  if (is_array($working_data))
832  {
833  foreach ($working_data as $data)
834  {
835  if (($data["value"] == $cat->scale-1) && ($data["rowvalue"] == $i))
836  {
837  $tplrow->setVariable("CHECKED_CHECKBOX", " checked=\"checked\"");
838  }
839  }
840  }
841  $tplrow->parseCurrentBlock();
842  }
843  else
844  {
845  $tplrow->setCurrentBlock("checkbox");
846  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
847  $tplrow->setVariable("ROW", $i);
848  $tplrow->setVariable("VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
849  if (is_array($working_data))
850  {
851  foreach ($working_data as $data)
852  {
853  if (($data["value"] == $cat->scale-1) && ($data["rowvalue"] == $i))
854  {
855  $tplrow->setVariable("CHECKED_CHECKBOX", " checked=\"checked\"");
856  }
857  }
858  }
859  $tplrow->parseCurrentBlock();
860  }
861  break;
862  }
863  if ($cat->neutral)
864  {
865  $tplrow->setCurrentBlock("neutral_answer");
866  $style = array();
867  if ($this->object->getNeutralColumnSeparator())
868  {
869  array_push($style, "border-left: $neutralstyle!important");
870  }
871  if ($this->object->getColumnSeparators() == 1)
872  {
873  if ($j < $this->object->getColumnCount() - 1)
874  {
875  array_push($style, "border-right: 1px solid $bordercolor!important");
876  }
877  }
878  }
879  else
880  {
881  $tplrow->setCurrentBlock("answer");
882  $style = array();
883 
884  if ($this->object->getColumnSeparators() == 1)
885  {
886  if ($j < $this->object->getColumnCount() - 1)
887  {
888  array_push($style, "border-right: 1px solid $bordercolor!important");
889  }
890  }
891  }
892  if ($this->object->getRowSeparators() == 1)
893  {
894  if ($i < $this->object->getRowCount() - 1)
895  {
896  array_push($style, "border-bottom: 1px solid $bordercolor!important");
897  }
898  }
899  if (count($style))
900  {
901  $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
902  }
903  $tplrow->parseCurrentBlock();
904  }
905 
906  if ($rowobj->other)
907  {
908  $tplrow->setCurrentBlock("row_other");
909  $tplrow->setVariable("QUESTION_ID", $this->object->getId());
910  $tplrow->setVariable("ROW", $i);
911  if (is_array($working_data))
912  {
913  foreach ($working_data as $data)
914  {
915  if ($data["rowvalue"] == $i)
916  {
917  $tplrow->setVariable("VALUE_OTHER", ilUtil::prepareFormOutput($data['textanswer']));
918  }
919  }
920  }
921  $tplrow->parseCurrentBlock();
922  }
923  $tplrow->setVariable("TEXT_ROW", ilUtil::prepareFormOutput($rowobj->title));
924  $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]);
925  if ($this->object->getRowSeparators() == 1)
926  {
927  if ($i < $this->object->getRowCount() - 1)
928  {
929  $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid $bordercolor!important\"");
930  }
931  }
932  $template->setCurrentBlock("matrix_row");
933  $template->setVariable("ROW", $tplrow->get());
934  $template->parseCurrentBlock();
935  }
936 
937  if ($question_title)
938  {
939  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
940  }
941  $template->setCurrentBlock("question_data_matrix");
942  if (strcmp($error_message, "") != 0)
943  {
944  $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
945  }
946  if ($show_questiontext)
947  {
948  $this->outQuestionText($template);
949  }
950  $template->parseCurrentBlock();
951  return $template->get();
952  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getMaterialOutput()
Creates the HTML output of the question material(s)
$style
Definition: example_012.php:70
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
getLayoutRow()
Creates a row to define the matrix question layout with percentage values.
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importEditFormValues()

SurveyMatrixQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

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

References $_POST, and ilPropertyFormGUI\getInput().

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

◆ initObject()

SurveyMatrixQuestionGUI::initObject ( )
protected

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.

public

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

References getWorkingForm().

Referenced by saveLayout().

568  {
569  global $ilTabs;
570 
571  $ilTabs->activateTab("layout");
572 
573  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_layout.html", "Modules/SurveyQuestionPool");
574  $this->show_layout_row = TRUE;
575  $question_output = $this->getWorkingForm();
576  $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
577  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveLayout"));
578  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
579  }
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
Creates the question output form for the learner.
+ 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 586 of file class.SurveyMatrixQuestionGUI.php.

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

587  {
588  $percent_values = array(
589  "percent_row" => (int)$_POST["percent_row"],
590  "percent_columns" => (int)$_POST["percent_columns"],
591  "percent_bipolar_adjective1" => (int)$_POST['percent_bipolar_adjective1'],
592  "percent_bipolar_adjective2" => (int)$_POST['percent_bipolar_adjective2'],
593  "percent_neutral" => (int)$_POST["percent_neutral"]
594  );
595  $this->object->setLayout($percent_values);
596 
597  // #9364
598  if(array_sum($percent_values) == 100)
599  {
600  $this->object->saveLayout($percent_values["percent_row"],
601  $percent_values['percent_columns'],
602  $percent_values['percent_bipolar_adjective1'],
603  $percent_values['percent_bipolar_adjective2'],
604  $percent_values["percent_neutral"]);
605  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
606  }
607  else
608  {
609  ilUtil::sendFailure($this->lng->txt("svy_matrix_layout_percentages_sum_invalid"));
610  }
611  $this->layout();
612  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
layout()
Creates a layout view of the question.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ setQuestionTabs()

SurveyMatrixQuestionGUI::setQuestionTabs ( )

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

References SurveyQuestionGUI\setQuestionTabsForClass().

53  {
54  $this->setQuestionTabsForClass("surveymatrixquestiongui");
55  }
+ 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: