66 $this->
user = $DIC->user();
67 $this->db =
$DIC->database();
73 $this->bipolar_adjective1 =
"";
74 $this->bipolar_adjective2 =
"";
75 $this->rowSeparators = 0;
76 $this->columnSeparators = 0;
77 $this->neutralColumnSeparator = 1;
82 return $this->columns->getCategoryCount();
87 $this->columns->removeCategory(
$index);
95 $this->columns->removeCategories($array);
100 $this->columns->removeCategoryWithName(
$name);
110 return $this->columns->getCategory(
$index);
115 return $this->columns->getCategoryForScale($scale);
120 return $this->columns->getCategoryIndex(
$name);
125 $this->columns->flushCategories();
130 return $this->rows->getCategoryCount();
138 $this->rows->addCategory($a_text, (
int) $a_other, 0, $a_label);
146 $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
156 return $this->rows->getCategory($a_index);
161 $this->rows->moveCategoryUp(
$index);
166 $this->rows->moveCategoryDown(
$index);
174 $this->rows->removeCategories($array);
179 $this->rows->removeCategory(
$index);
188 if ($a_index === 1) {
189 return $this->bipolar_adjective2;
191 return $this->bipolar_adjective1;
198 if ($a_index === 1) {
199 $this->bipolar_adjective2 = $a_value;
201 $this->bipolar_adjective1 = $a_value;
213 $result =
$ilDB->queryF(
214 "SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s AND (svy_category.owner_fi = %s OR svy_category.owner_fi = %s) ORDER BY svy_phrase_cat.sequence",
215 array(
'integer',
'integer',
'integer'),
216 array($phrase_id, 0,
$ilUser->getId())
218 while ($row =
$ilDB->fetchAssoc($result)) {
219 $neutral = $row[
"neutral"];
220 if ((
int) $row[
"defaultvalue"] === 1 && (
int) $row[
"owner_fi"] === 0) {
221 $this->columns->addCategory($this->
lng->txt($row[
"title"]), 0, $neutral);
223 $this->columns->addCategory($row[
"title"], 0, $neutral);
235 $result =
$ilDB->queryF(
236 "SELECT svy_question.*, " . $this->getAdditionalTableName() .
".* FROM svy_question, " . $this->getAdditionalTableName() .
" WHERE svy_question.question_id = %s AND svy_question.question_id = " . $this->getAdditionalTableName() .
".question_fi",
240 if ($result->numRows() === 1) {
241 return $ilDB->fetchAssoc($result);
250 $result =
$ilDB->queryF(
251 "SELECT svy_question.*, " . $this->getAdditionalTableName() .
".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() .
" ON " . $this->getAdditionalTableName() .
".question_fi = svy_question.question_id WHERE svy_question.question_id = %s",
255 if ($result->numRows() === 1) {
257 $this->setId((
int)
$data[
"question_id"]);
258 $this->setTitle((
string)
$data[
"title"]);
259 $this->label = (string)
$data[
'label'];
260 $this->setDescription((
string)
$data[
"description"]);
261 $this->setObjId((
int)
$data[
"obj_fi"]);
262 $this->setAuthor((
string)
$data[
"author"]);
263 $this->setOwner((
int)
$data[
"owner_fi"]);
265 $this->setObligatory((
bool)
$data[
"obligatory"]);
266 $this->setComplete((
bool)
$data[
"complete"]);
267 $this->setOriginalId((
int)
$data[
"original_id"]);
268 $this->setSubtype((
int)
$data[
"subtype"]);
269 $this->setRowSeparators((
bool)
$data[
"row_separators"]);
270 $this->setNeutralColumnSeparator((
bool)
$data[
"neutral_column_separator"]);
271 $this->setColumnSeparators((
bool)
$data[
"column_separators"]);
272 $this->setColumnPlaceholders((
bool)
$data[
"column_placeholders"]);
273 $this->setLegend((
bool)
$data[
"legend"]);
274 $this->setSingleLineRowCaption((
string)
$data[
"singleline_row_caption"]);
275 $this->setRepeatColumnHeader((
bool)
$data[
"repeat_column_header"]);
276 $this->setBipolarAdjective(0, (
string)
$data[
"bipolar_adjective1"]);
277 $this->setBipolarAdjective(1, (
string)
$data[
"bipolar_adjective2"]);
278 $this->setLayout(
$data[
"layout"]);
279 $this->flushColumns();
281 $result =
$ilDB->queryF(
282 "SELECT svy_variable.*, svy_category.title, svy_category.neutral FROM svy_variable, svy_category WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ORDER BY sequence ASC",
286 if ($result->numRows() > 0) {
288 $this->columns->addCategory((
string)
$data[
"title"], (
int)
$data[
"other"], (
int)
$data[
"neutral"],
null, (
$data[
'scale']) ?: (
$data[
'sequence'] + 1));
292 $result =
$ilDB->queryF(
293 "SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
297 while ($row =
$ilDB->fetchAssoc($result)) {
298 $this->addRow((
string) $row[
"title"], (
string) $row[
'other'], (
string) ($row[
'label'] ??
""));
301 parent::loadFromDb($question_id);
307 $this->getTitle() !==
'' &&
308 $this->getAuthor() !==
'' &&
309 $this->getQuestiontext() !==
'' &&
310 $this->getColumnCount() &&
319 $affectedRows = parent::saveToDb($original_id);
321 if ($affectedRows === 1) {
323 "DELETE FROM " . $this->getAdditionalTableName() .
" WHERE question_fi = %s",
325 array($this->
getId())
328 "INSERT INTO " . $this->getAdditionalTableName() .
" (
329 question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
330 legend, singleline_row_caption, repeat_column_header,
331 bipolar_adjective1, bipolar_adjective2, layout, tstamp)
332 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
334 'integer',
'integer',
'text',
'text',
'text',
'integer',
'text',
'text',
'text',
335 'text',
'text',
'text',
'integer'
340 $this->getColumnSeparators(),
341 $this->getRowSeparators(),
342 $this->getNeutralColumnSeparator(),
343 $this->getColumnPlaceholders(),
345 $this->getSingleLineRowCaption(),
346 $this->getRepeatColumnHeader(),
347 $this->getBipolarAdjective(0),
348 $this->getBipolarAdjective(1),
349 serialize($this->getLayout()),
355 $this->saveMaterial();
357 $this->saveColumnsToDb();
358 $this->saveRowsToDb();
360 return $affectedRows;
370 "UPDATE " . $this->getAdditionalTableName() .
" SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
371 array(
'text',
'text',
'integer'),
372 array(($adjective1 !==
'') ? $adjective1 :
null, ($adjective2 !==
'') ? $adjective2 :
null, $this->
getId())
383 $result =
$ilDB->queryF(
384 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
385 array(
'text',
'text',
'integer'),
386 array($columntext, $neutral,
$ilUser->getId())
391 if ($result->numRows()) {
392 while ($row =
$ilDB->fetchAssoc($result)) {
393 if (strcmp($row[
"title"] ??
'', $columntext) === 0) {
394 $returnvalue = $row[
"category_id"];
400 $next_id =
$ilDB->nextId(
'svy_category');
401 $affectedRows =
$ilDB->manipulateF(
402 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
403 array(
'integer',
'text',
'text',
'integer',
'text',
'integer'),
404 array($next_id, $columntext, 0,
$ilUser->getId(), $neutral, time())
406 $returnvalue = $next_id;
417 $question_id = $this->
getId();
418 if ($original_id > 0) {
419 $question_id = $original_id;
423 $affectedRows =
$ilDB->manipulateF(
424 "DELETE FROM svy_variable WHERE question_fi = %s",
429 for (
$i = 0;
$i < $this->getColumnCount();
$i++) {
430 $cat = $this->getColumn(
$i);
431 $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
432 $next_id =
$ilDB->nextId(
'svy_variable');
433 $affectedRows =
$ilDB->manipulateF(
434 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
435 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer',
'integer'),
436 array($next_id, $column_id, $question_id, (
$i + 1), $cat->other,
$i, ($cat->scale > 0) ? $cat->scale :
null, time())
439 $this->saveCompletionStatus($original_id);
448 $question_id = $this->
getId();
449 if ($original_id > 0) {
450 $question_id = $original_id;
454 $affectedRows =
$ilDB->manipulateF(
455 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
460 for (
$i = 0;
$i < $this->getRowCount();
$i++) {
461 $row = $this->getRow(
$i);
462 $next_id =
$ilDB->nextId(
'svy_qst_matrixrows');
463 $affectedRows =
$ilDB->manipulateF(
464 "INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
465 array(
'integer',
'text',
'text',
'integer',
'integer',
'integer'),
466 array($next_id, $row->title, $row->label, ($row->other) ? 1 : 0,
$i, $question_id)
469 $this->saveCompletionStatus($original_id);
479 bool $a_include_header =
true,
480 bool $obligatory_state =
false
484 $this->insertXML($a_xml_writer, $a_include_header);
485 $xml = $a_xml_writer->xmlDumpMem(
false);
486 if (!$a_include_header) {
487 $pos = strpos(
$xml,
"?>");
498 bool $a_include_header =
true
501 "id" => $this->
getId(),
502 "title" => $this->getTitle(),
503 "type" => $this->getQuestionType(),
504 "subtype" => $this->getSubtype(),
505 "obligatory" => $this->getObligatory()
509 $a_xml_writer->
xmlElement(
"description",
null, $this->getDescription());
510 $a_xml_writer->
xmlElement(
"author",
null, $this->getAuthor());
512 $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
513 $a_xml_writer->
xmlEndTag(
"questiontext");
517 for (
$i = 0;
$i < $this->getRowCount();
$i++) {
521 if (strlen($this->getRow(
$i)->label)) {
522 $attrs[
'label'] = $this->getRow(
$i)->label;
524 if ($this->getRow(
$i)->other) {
528 $this->addMaterialTag($a_xml_writer, $this->getRow(
$i)->title);
534 if ($this->getBipolarAdjective(0) !==
'' && ($this->getBipolarAdjective(1) !==
'')) {
539 $a_xml_writer->
xmlElement(
"adjective", $attribs, $this->getBipolarAdjective(0));
543 $a_xml_writer->
xmlElement(
"adjective", $attribs, $this->getBipolarAdjective(1));
544 $a_xml_writer->
xmlEndTag(
"bipolar_adjectives");
546 for (
$i = 0;
$i < $this->getColumnCount();
$i++) {
550 if ($this->getColumn(
$i)->neutral) {
551 $attrs[
'label'] =
'neutral';
553 switch ($this->getSubtype()) {
555 $a_xml_writer->
xmlStartTag(
"response_single", $attrs);
558 $a_xml_writer->
xmlStartTag(
"response_multiple", $attrs);
561 $this->addMaterialTag($a_xml_writer, $this->getColumn(
$i)->title);
562 switch ($this->getSubtype()) {
564 $a_xml_writer->
xmlEndTag(
"response_single");
567 $a_xml_writer->
xmlEndTag(
"response_multiple");
575 if (count($this->material)) {
576 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
578 "label" => $this->material[
"title"]
581 $intlink =
"il_" .
IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
582 if (strcmp($matches[1],
"") !== 0) {
583 $intlink = $this->material[
"internal_link"];
585 $a_xml_writer->
xmlElement(
"mattext",
null, $intlink);
592 $a_xml_writer->
xmlElement(
"fieldlabel",
null,
"column_separators");
593 $a_xml_writer->
xmlElement(
"fieldentry",
null, $this->getColumnSeparators());
594 $a_xml_writer->
xmlEndTag(
"metadatafield");
597 $a_xml_writer->
xmlElement(
"fieldlabel",
null,
"row_separators");
598 $a_xml_writer->
xmlElement(
"fieldentry",
null, $this->getRowSeparators());
599 $a_xml_writer->
xmlEndTag(
"metadatafield");
602 $a_xml_writer->
xmlElement(
"fieldlabel",
null,
"neutral_column_separator");
603 $a_xml_writer->
xmlElement(
"fieldentry",
null, $this->getNeutralColumnSeparator());
604 $a_xml_writer->
xmlEndTag(
"metadatafield");
607 $a_xml_writer->
xmlElement(
"fieldlabel",
null,
"layout");
608 $a_xml_writer->
xmlElement(
"fieldentry",
null, serialize($this->getLayout()));
609 $a_xml_writer->
xmlEndTag(
"metadatafield");
618 if ($this->getOriginalId()) {
619 parent::syncWithOriginal();
620 $this->saveColumnsToDb($this->getOriginalId());
621 $this->saveRowsToDb($this->getOriginalId());
632 for (
$i = $lower_limit;
$i <= $upper_limit;
$i++) {
633 $this->columns->addCategory(
$i);
647 $next_id =
$ilDB->nextId(
'svy_phrase');
649 "INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
650 array(
'integer',
'text',
'text',
'integer',
'integer'),
651 array($next_id, $title, 1,
$ilUser->getId(), time())
653 $phrase_id = $next_id;
656 $phrase_data = $this->edit_manager->getPhraseData();
657 foreach ($phrase_data as
$data) {
658 $next_id =
$ilDB->nextId(
'svy_category');
659 $affectedRows =
$ilDB->manipulateF(
660 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
661 array(
'integer',
'text',
'text',
'integer',
'integer',
'text'),
664 $category_id = $next_id;
665 $next_id =
$ilDB->nextId(
'svy_phrase_cat');
666 $affectedRows =
$ilDB->manipulateF(
667 "INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
668 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
669 array($next_id, $phrase_id, $category_id, $counter, (
$data[
'other']) ? 1 : 0,
$data[
'scale'])
677 return "SurveyMatrixQuestion";
685 return "svy_qst_matrix";
691 foreach ($post_data as
$key => $value) {
692 switch ($this->getSubtype()) {
695 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/",
$key, $matches)) {
696 if (is_array($value)) {
697 foreach ($value as $val) {
698 $data[] = array(
"value" => $val,
699 "rowvalue" => $matches[1],
700 "textanswer" => $post_data[
'matrix_other_' . $this->
getId(
701 ) .
'_' . $matches[1]] ??
""
705 $data[] = array(
"value" => $value,
706 "rowvalue" => $matches[1],
707 "textanswer" => $post_data[
'matrix_other_' . $this->
getId(
708 ) .
'_' . $matches[1]] ??
""
727 if (!$this->getObligatory()) {
730 switch ($this->getSubtype()) {
733 foreach ($post_data as
$key => $value) {
734 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/",
$key, $matches)) {
735 if (array_key_exists(
'matrix_other_' . $this->
getId() .
"_" . $matches[1], $post_data) && strlen($post_data[
'matrix_other_' . $this->
getId() .
"_" . $matches[1]]) == 0) {
736 return $this->
lng->txt(
"question_mr_no_other_answer");
741 if ($counter !== $this->getRowCount()) {
742 return $this->
lng->txt(
"matrix_question_radio_button_not_checked");
747 foreach ($post_data as
$key => $value) {
748 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/",
$key, $matches)) {
749 if (array_key_exists(
'matrix_other_' . $this->
getId() .
"_" . $matches[1], $post_data) && strlen($post_data[
'matrix_other_' . $this->
getId() .
"_" . $matches[1]]) == 0) {
750 return $this->
lng->txt(
"question_mr_no_other_answer");
753 if ((!is_array($value)) || (count($value) < 1)) {
754 return $this->
lng->txt(
"matrix_question_checkbox_not_checked");
758 if ($counter !== $this->getRowCount()) {
759 return $this->
lng->txt(
"matrix_question_checkbox_not_checked");
769 bool $a_return =
false
773 $answer_data = array();
776 switch ($this->getSubtype()) {
778 foreach ($post_data as
$key => $value) {
779 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/",
$key, $matches)) {
780 if (strlen($value)) {
781 $other_value = (array_key_exists(
'matrix_other_' . $this->
getId() .
'_' . $matches[1], $post_data))
782 ? $this->stripSlashesAddSpaceFallback($post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]])
784 $answer_data[] = array(
"value" => $value,
785 "textanswer" => $other_value,
786 "rowvalue" => $matches[1]);
793 foreach ($post_data as
$key => $value) {
794 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/",
$key, $matches)) {
795 $other_value = (array_key_exists(
'matrix_other_' . $this->
getId() .
'_' . $matches[1], $post_data))
796 ? $this->stripSlashesAddSpaceFallback($post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]])
798 foreach ($value as $checked) {
799 $answer_data[] = array(
"value" => $checked,
800 "textanswer" => $other_value,
801 "rowvalue" => $matches[1]);
813 if (count($answer_data)) {
815 foreach ($answer_data as $item) {
816 $next_id =
$ilDB->nextId(
'svy_answer');
819 $fields[
'answer_id'] = array(
"integer", $next_id);
820 $fields[
'question_fi'] = array(
"integer", $this->
getId());
821 $fields[
'active_fi'] = array(
"integer", $active_id);
822 $fields[
'value'] = array(
"float", $item[
'value']);
823 $fields[
'textanswer'] = array(
"clob", $item[
'textanswer']);
824 $fields[
'rowvalue'] = array(
"integer", $item[
'rowvalue']);
825 $fields[
'tstamp'] = array(
"integer", time());
827 $affectedRows =
$ilDB->insert(
"svy_answer", $fields);
839 parent::deleteAdditionalTableData($question_id);
843 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
854 return $this->subtype;
862 switch ($a_subtype) {
869 $this->subtype = $a_subtype;
883 $this->columnSeparators = $enable;
888 return $this->columnSeparators;
896 $this->rowSeparators = $enable;
901 return $this->rowSeparators;
906 $this->neutralColumnSeparator = $enable;
911 return $this->neutralColumnSeparator;
919 foreach ($a_meta as
$key => $value) {
920 switch ($value[
"label"]) {
921 case "column_separators":
922 $this->setColumnSeparators($value[
"entry"]);
924 case "row_separators":
925 $this->setRowSeparators($value[
"entry"]);
928 $this->setLayout($value[
"entry"]);
930 case "neutral_column_separator":
931 $this->setNeutralColumnSeparator($value[
"entry"]);
943 foreach ($a_data as $adjective) {
944 if (is_numeric($adjective[
"label"])) {
945 $this->setBipolarAdjective($adjective[
"label"], $adjective[
"text"]);
947 $this->setBipolarAdjective(
$i, $adjective[
"text"]);
959 foreach ($a_data as $row) {
960 $this->addRow($row[
'title'], $row[
'other'], $row[
'label']);
971 foreach (
$data[
"material"] as $material) {
972 $column .= $material[
"text"];
974 $this->columns->addCategory($column, 0, strcmp(
$data[
"label"],
"neutral") == 0);
1003 $options = $this->getPreconditionOptions();
1004 $step3->setOptions($options);
1005 $step3->setValue($default);
1020 float $percent_columns,
1021 float $percent_bipolar_adjective1 = 0,
1022 float $percent_bipolar_adjective2 = 0,
1023 float $percent_neutral = 0
1028 "percent_row" => $percent_row,
1029 "percent_columns" => $percent_columns,
1030 "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
1031 "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
1032 "percent_neutral" => $percent_neutral
1034 $affectedRows =
$ilDB->manipulateF(
1035 "UPDATE " . $this->getAdditionalTableName() .
" SET layout = %s WHERE question_fi = %s",
1036 array(
'text',
'integer'),
1037 array(serialize($layout), $this->
getId())
1043 if (count($this->layout) === 0) {
1044 if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn()) {
1045 $this->layout = array(
1046 "percent_row" => 30,
1047 "percent_columns" => 40,
1048 "percent_bipolar_adjective1" => 10,
1049 "percent_bipolar_adjective2" => 10,
1050 "percent_neutral" => 10
1052 } elseif ($this->hasBipolarAdjectives()) {
1053 $this->layout = array(
1054 "percent_row" => 30,
1055 "percent_columns" => 50,
1056 "percent_bipolar_adjective1" => 10,
1057 "percent_bipolar_adjective2" => 10,
1058 "percent_neutral" => 0
1060 } elseif ($this->hasNeutralColumn()) {
1061 $this->layout = array(
1062 "percent_row" => 30,
1063 "percent_columns" => 50,
1064 "percent_bipolar_adjective1" => 0,
1065 "percent_bipolar_adjective2" => 0,
1066 "percent_neutral" => 20
1069 $this->layout = array(
1070 "percent_row" => 30,
1071 "percent_columns" => 70,
1072 "percent_bipolar_adjective1" => 0,
1073 "percent_bipolar_adjective2" => 0,
1074 "percent_neutral" => 0
1078 return $this->layout;
1086 if (is_array($layout)) {
1087 $this->layout = $layout;
1089 $this->layout = unserialize($layout, [
'allowed_classes' =>
false]) ?: [];
1098 return $this->getBipolarAdjective(0) !==
'' && $this->getBipolarAdjective(1) !==
'';
1106 for (
$i = 0;
$i < $this->getColumnCount();
$i++) {
1107 $column = $this->getColumn(
$i);
1108 if ($column->neutral && strlen($column->title)) {
1120 $this->columnPlaceholders = $a_value;
1125 return $this->columnPlaceholders;
1133 $this->legend = $a_value;
1138 return $this->legend;
1143 $this->singleLineRowCaption = $a_value;
1148 return $this->singleLineRowCaption;
1153 $this->repeatColumnHeader = $a_value;
1158 return $this->repeatColumnHeader;
1172 $db =
$DIC->database();
1175 "SELECT MAX(scale) max_sum_score, q.question_id FROM svy_svy_qst sq " .
1176 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1177 "JOIN svy_variable v ON (v.question_fi = q.question_id) " .
1178 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1179 "GROUP BY (q.question_id)",
1180 [
"integer",
"integer"],
1184 while ($rec = $db->fetchAssoc($set)) {
1185 $max_score[$rec[
"question_id"]] = $rec[
"max_sum_score"];
1189 "SELECT COUNT(mr.id_svy_qst_matrixrows) cnt_rows, q.question_id FROM svy_svy_qst sq " .
1190 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1191 "JOIN svy_qst_matrixrows mr ON (mr.question_fi = q.question_id) " .
1192 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1193 "GROUP BY (q.question_id)",
1194 [
"integer",
"integer"],
1198 while ($rec = $db->fetchAssoc($set)) {
1199 $cnt_rows[$rec[
"question_id"]] = $rec[
"cnt_rows"];
1203 foreach ($max_score as $qid => $s) {
1204 $sum_sum_score += $s * $cnt_rows[$qid];
1207 return $sum_sum_score;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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...
setRepeatColumnHeader(bool $a_value=false)
hasNeutralColumn()
Returns TRUE if a neutral column exists.
removeColumnWithName(string $name)
int $subtype
Matrix question subtype 0 = Single choice 1 = Multiple choice 2 = Text 3 = Integer 4 = Double 5 = Dat...
savePhrase(string $title)
Saves a set of columns to a default phrase (data currently comes from session)
__construct(string $title="", string $description="", string $author="", string $questiontext="", int $owner=-1)
saveRowsToDb(int $original_id=0)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
importAdjectives(array $a_data)
Import bipolar adjectives from the question import file.
setBipolarAdjective(int $a_index, string $a_value)
setLegend(bool $a_value=false)
Set whether the legend should be shown or not.
getWorkingDataFromUserInput(array $post_data)
Creates the user data of the svy_answer table from the POST data.
saveColumnsToDb(int $original_id=0)
getPreconditionSelectValue(string $default, string $title, string $variable)
Creates a form property for the precondition value.
getQuestionDataArray(int $id)
Returns the question data fields from the database.
SurveyCategories $columns
setRowSeparators(bool $enable=false)
Enables/Disables separators for the matrix rows.
setColumnSeparators(bool $enable=false)
Enables/Disables separators for the matrix columns.
getSubtype()
Returns the subtype of the matrix question.
toXML(bool $a_include_header=true, bool $obligatory_state=false)
Returns an xml representation of the question.
saveToDb(int $original_id=0)
Saves a SurveyQuestion object to a database.
getNeutralColumnSeparator()
addPhrase(int $phrase_id)
Adds a phrase to the question.
saveColumnToDb(string $columntext, int $neutral=0)
setSingleLineRowCaption(bool $a_value=false)
bool $neutralColumnSeparator
importResponses(array $a_data)
Import response data from the question import file.
addRow(string $a_text, string $a_other, string $a_label)
usableForPrecondition()
Returns if the question is usable for preconditions.
checkUserInput(array $post_data, int $survey_id)
Checks the input of the active user for obligatory status and entered values.
saveBipolarAdjectives(string $adjective1, string $adjective2)
saveUserInput(array $post_data, int $active_id, bool $a_return=false)
getSingleLineRowCaption()
insertXML(ilXmlWriter $a_xml_writer, bool $a_include_header=true)
Adds the question XML to a given XMLWriter object.
importAdditionalMetadata(array $a_meta)
Import additional meta data from the question import file.
loadFromDb(int $question_id)
load question data into object note: this base implementation only loads the material data
removeColumns(array $array)
addStandardNumbers(int $lower_limit, int $upper_limit)
Adds standard numbers as columns.
getBipolarAdjective(int $a_index)
Returns one of the bipolar adjectives.
importMatrix(array $a_data)
Import matrix rows from the question import file.
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.
getColumnForScale(int $scale)
getPreconditionValueOutput(string $value)
Returns the output for a precondition value.
setColumnPlaceholders(bool $a_value=false)
Set whether placeholders should be used for the column titles or not.
deleteAdditionalTableData(int $question_id)
Delete question data from additional table.
string $bipolar_adjective1
saveLayout(float $percent_row, float $percent_columns, float $percent_bipolar_adjective1=0, float $percent_bipolar_adjective2=0, float $percent_neutral=0)
Saves the layout of a matrix question.
bool $singleLineRowCaption
static getMaxSumScore(int $survey_id)
Get max sum score for specific survey (and this question type)
setSubtype(int $a_subtype=0)
Sets the subtype of the matrix question.
getColumnIndex(string $name)
addRowAtPosition(string $a_text, string $a_other, int $a_position)
setNeutralColumnSeparator(bool $enable=true)
string $bipolar_adjective2
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
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...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc