24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
169 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
172 $this->bipolar_adjective1 =
"";
173 $this->bipolar_adjective2 =
"";
174 $this->rowSeparators = 0;
175 $this->columnSeparators = 0;
176 $this->neutralColumnSeparator = 1;
188 return $this->columns->getCategoryCount();
200 $this->columns->removeCategory($index);
212 $this->columns->removeCategories($array);
224 $this->columns->removeCategoryWithName(
$name);
245 return $this->columns->getCategory($index);
250 return $this->columns->getCategoryForScale($scale);
262 return $this->columns->getCategoryIndex(
$name);
274 $this->columns->flushCategories();
285 return $this->rows->getCategoryCount();
293 function addRow($a_text, $a_other, $a_label)
295 $this->rows->addCategory($a_text, $a_other, 0, $a_label);
306 $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
328 return $this->rows->getCategory($a_index);
333 $this->rows->moveCategoryUp($index);
338 $this->rows->moveCategoryDown($index);
350 $this->rows->removeCategories($array);
360 $this->rows->removeCategory($index);
375 return (strlen($this->bipolar_adjective2)) ? $this->bipolar_adjective2 : NULL;
379 return (strlen($this->bipolar_adjective1)) ? $this->bipolar_adjective1 : NULL;
397 $this->bipolar_adjective2 = $a_value;
401 $this->bipolar_adjective1 = $a_value;
417 $result = $ilDB->queryF(
"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",
418 array(
'integer',
'integer',
'integer'),
419 array($phrase_id, 0, $ilUser->getId())
421 while (
$row = $ilDB->fetchAssoc($result))
423 if ((
$row[
"defaultvalue"] == 1) && (
$row[
"owner_fi"] == 0))
425 $this->columns->addCategory($this->lng->txt(
$row[
"title"]));
429 $this->columns->addCategory(
$row[
"title"]);
449 if ($result->numRows() == 1)
451 return $ilDB->fetchAssoc($result);
472 if ($result->numRows() == 1)
474 $data = $ilDB->fetchAssoc($result);
477 $this->label =
$data[
'label'];
482 include_once(
"./Services/RTE/classes/class.ilRTE.php");
505 $result = $ilDB->queryF(
"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",
509 if ($result->numRows() > 0)
511 while (
$data = $ilDB->fetchAssoc($result))
517 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
521 while (
$row = $ilDB->fetchAssoc($result))
558 function saveToDb($original_id = NULL, $withanswers =
true)
564 if ($affectedRows == 1)
566 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
568 array($this->
getId())
571 question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
572 legend, singleline_row_caption, repeat_column_header, column_header_position, random_rows,
573 column_order, column_images, row_images, bipolar_adjective1, bipolar_adjective2, layout, tstamp)
574 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
576 'integer',
'integer',
'text',
'text',
'text',
'integer',
'text',
'text',
'text',
577 'text',
'text',
'text',
'text',
'text',
'text',
'text',
'text',
'integer'
613 $affectedRows = $ilDB->manipulateF(
"UPDATE " . $this->
getAdditionalTableName() .
" SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
614 array(
'text',
'text',
'integer'),
615 array((strlen($adjective1)) ? $adjective1 : NULL, (strlen($adjective2)) ? $adjective2 : NULL, $this->
getId())
629 global $ilUser,
$ilDB;
631 $result = $ilDB->queryF(
"SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
632 array(
'text',
'text',
'integer'),
633 array($columntext, $neutral, $ilUser->getId())
637 if ($result->numRows())
640 while (
$row = $ilDB->fetchAssoc($result))
642 if (strcmp(
$row[
"title"], $columntext) == 0)
644 $returnvalue =
$row[
"category_id"];
655 $next_id = $ilDB->nextId(
'svy_category');
656 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
657 array(
'integer',
'text',
'text',
'integer',
'text',
'integer'),
658 array($next_id, $columntext, 0, $ilUser->getId(), $neutral, time())
660 $returnvalue = $next_id;
670 $question_id = $this->
getId();
671 if (strlen($original_id))
673 $question_id = $original_id;
677 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
686 $next_id = $ilDB->nextId(
'svy_variable');
687 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
688 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer',
'integer'),
689 array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
700 $question_id = $this->
getId();
701 if (strlen($original_id))
703 $question_id = $original_id;
707 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
715 $next_id = $ilDB->nextId(
'svy_qst_matrixrows');
716 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
717 array(
'integer',
'text',
'text',
'integer',
'integer',
'integer'),
718 array($next_id,
$row->title,
$row->label, (
$row->other) ? 1 : 0, $i, $question_id)
730 function toXML($a_include_header = TRUE, $obligatory_state =
"")
732 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
735 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
736 $xml = $a_xml_writer->xmlDumpMem(FALSE);
737 if (!$a_include_header)
739 $pos = strpos($xml,
"?>");
740 $xml = substr($xml,
$pos + 2);
753 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
756 "id" => $this->
getId(),
758 "type" => $this->getQuestiontype(),
762 $a_xml_writer->xmlStartTag(
"question", $attrs);
764 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
765 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
766 $a_xml_writer->xmlStartTag(
"questiontext");
768 $a_xml_writer->xmlEndTag(
"questiontext");
770 $a_xml_writer->xmlStartTag(
"matrix");
771 $a_xml_writer->xmlStartTag(
"matrixrows");
777 if (strlen($this->
getRow($i)->label))
779 $attrs[
'label'] = $this->
getRow($i)->label;
781 if ($this->
getRow($i)->other)
785 $a_xml_writer->xmlStartTag(
"matrixrow", $attrs);
787 $a_xml_writer->xmlEndTag(
"matrixrow");
789 $a_xml_writer->xmlEndTag(
"matrixrows");
791 $a_xml_writer->xmlStartTag(
"responses");
794 $a_xml_writer->xmlStartTag(
"bipolar_adjectives");
803 $a_xml_writer->xmlEndTag(
"bipolar_adjectives");
812 $attrs[
'label'] =
'neutral';
817 $a_xml_writer->xmlStartTag(
"response_single", $attrs);
820 $a_xml_writer->xmlStartTag(
"response_multiple", $attrs);
827 $a_xml_writer->xmlEndTag(
"response_single");
830 $a_xml_writer->xmlEndTag(
"response_multiple");
835 $a_xml_writer->xmlEndTag(
"responses");
836 $a_xml_writer->xmlEndTag(
"matrix");
838 if (count($this->material))
840 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
843 "label" => $this->material[
"title"]
845 $a_xml_writer->xmlStartTag(
"material", $attrs);
846 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
847 if (strcmp($matches[1],
"") != 0)
849 $intlink = $this->material[
"internal_link"];
851 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
852 $a_xml_writer->xmlEndTag(
"material");
856 $a_xml_writer->xmlStartTag(
"metadata");
857 $a_xml_writer->xmlStartTag(
"metadatafield");
858 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"column_separators");
860 $a_xml_writer->xmlEndTag(
"metadatafield");
862 $a_xml_writer->xmlStartTag(
"metadatafield");
863 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"row_separators");
865 $a_xml_writer->xmlEndTag(
"metadatafield");
867 $a_xml_writer->xmlStartTag(
"metadatafield");
868 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"neutral_column_separator");
870 $a_xml_writer->xmlEndTag(
"metadatafield");
872 $a_xml_writer->xmlStartTag(
"metadatafield");
873 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"layout");
874 $a_xml_writer->xmlElement(
"fieldentry", NULL, serialize($this->
getLayout()));
875 $a_xml_writer->xmlEndTag(
"metadatafield");
877 $a_xml_writer->xmlEndTag(
"metadata");
879 $a_xml_writer->xmlEndTag(
"question");
902 for ($i = $lower_limit; $i <= $upper_limit; $i++)
904 $this->columns->addCategory($i);
920 $next_id = $ilDB->nextId(
'svy_phrase');
921 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
922 array(
'integer',
'text',
'text',
'integer',
'integer'),
923 array($next_id,
$title, 1, $ilUser->getId(), time())
925 $phrase_id = $next_id;
930 $next_id = $ilDB->nextId(
'svy_category');
931 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
932 array(
'integer',
'text',
'text',
'integer',
'integer'),
933 array($next_id, $data[
'answer'], 1, $ilUser->getId(), time())
935 $category_id = $next_id;
936 $next_id = $ilDB->nextId(
'svy_phrase_cat');
937 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
938 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
939 array($next_id, $phrase_id, $category_id, $counter, ($data[
'other']) ? 1 : 0, $data[
'scale'])
953 return "SurveyMatrixQuestion";
964 return "svy_qst_matrix";
976 foreach ($post_data as $key => $value)
981 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
983 if (is_array($value))
985 foreach ($value as $val)
987 array_push(
$data, array(
"value" => $val,
"rowvalue" => $matches[1],
"textanswer" => $post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]]));
992 array_push(
$data, array(
"value" => $value,
"rowvalue" => $matches[1],
"textanswer" => $post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]]));
997 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
999 if (is_array($value))
1001 foreach ($value as $val)
1003 array_push(
$data, array(
"value" => $val,
"rowvalue" => $matches[1],
"textanswer" => $post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]]));
1008 array_push(
$data, array(
"value" => $value,
"rowvalue" => $matches[1],
"textanswer" => $post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]]));
1033 foreach ($post_data as $key => $value)
1035 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
1037 if (array_key_exists(
'matrix_other_' . $this->
getId() .
"_" . $matches[1], $post_data) && strlen($post_data[
'matrix_other_' . $this->
getId() .
"_" . $matches[1]]) == 0)
1039 return $this->lng->txt(
"question_mr_no_other_answer");
1044 if ($counter != $this->
getRowCount())
return $this->lng->txt(
"matrix_question_radio_button_not_checked");
1048 foreach ($post_data as $key => $value)
1050 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
1052 if (array_key_exists(
'matrix_other_' . $this->
getId() .
"_" . $matches[1], $post_data) && strlen($post_data[
'matrix_other_' . $this->
getId() .
"_" . $matches[1]]) == 0)
1054 return $this->lng->txt(
"question_mr_no_other_answer");
1057 if ((!is_array($value)) || (count($value) < 1))
1059 return $this->lng->txt(
"matrix_question_checkbox_not_checked");
1063 if ($counter != $this->
getRowCount())
return $this->lng->txt(
"matrix_question_checkbox_not_checked");
1080 if ($this->getSubType() == 1)
1083 for ($i = 0; $i < $columncount; $i++)
1087 $next_id = $ilDB->nextId(
'svy_answer');
1088 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1089 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer',
'integer'),
1090 array($next_id, $this->
getId(), $active_id, $i, NULL,
$row, time())
1098 $category = rand(0, $columncount-1);
1099 $next_id = $ilDB->nextId(
'svy_answer');
1100 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1101 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer',
'integer'),
1102 array($next_id, $this->
getId(), $active_id, $category, NULL,
$row, time())
1115 foreach ($post_data as $key => $value)
1117 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
1119 $next_id = $ilDB->nextId(
'svy_answer');
1120 $other_value = (array_key_exists(
'matrix_other_' . $this->
getId() .
'_' . $matches[1], $post_data)) ? ($post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]]) : null;
1121 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1122 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer',
'integer'),
1123 array($next_id, $this->
getId(), $active_id, $value, $other_value, $matches[1], time())
1129 foreach ($post_data as $key => $value)
1131 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
1133 $other_value = (array_key_exists(
'matrix_other_' . $this->
getId() .
'_' . $matches[1], $post_data)) ? ($post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]]) : null;
1134 foreach ($value as $checked)
1136 if (strlen($checked))
1138 $next_id = $ilDB->nextId(
'svy_answer');
1139 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1140 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer',
'integer'),
1141 array($next_id, $this->
getId(), $active_id, $checked, $other_value, $matches[1], time())
1162 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
1179 $result = $ilDB->queryF(
"SELECT svy_answer.active_fi, svy_answer.question_fi FROM svy_answer, svy_finished WHERE svy_answer.question_fi = %s AND svy_finished.survey_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
1180 array(
'integer',
'integer'),
1184 while (
$row = $ilDB->fetchAssoc($result))
1186 $found[
$row[
"active_fi"].$row[
"question_fi"]] = 1;
1188 return count($found);
1203 $question_id = $this->
getId();
1205 $result_array = array();
1208 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_answer.question_fi = %s AND svy_finished.survey_fi = %s AND svy_answer.rowvalue = %s AND svy_finished.finished_id = svy_answer.active_fi",
1209 array(
'integer',
'integer',
'integer'),
1217 while (
$row = $ilDB->fetchAssoc($result))
1221 if ($row[
"textanswer"])
1223 $result_array[
"textanswers"][$row[
"value"]][] = $row[
"textanswer"];
1226 if (is_array($result_array[
"textanswers"]))
1228 ksort($result_array[
"textanswers"], SORT_NUMERIC);
1234 $numrows = $result->numRows();
1244 $result_array[
"MODE"] = $prefix . $cat->title;
1245 $result_array[
"MODE_VALUE"] = key(
$cumulated)+1;
1252 $percentage = (float)((
int)
$cumulated[$key]/$numrows);
1255 $result_array[
"variables"][$key] = array(
"title" => $cat->title,
"selected" => (
int)
$cumulated[$key],
"percentage" => $percentage);
1263 for ($i = 0; $i < $key; $i++)
1265 array_push($median, $value+1);
1272 $median_value = 0.5 * ($median[(
$total/2)-1] + $median[(
$total/2)]);
1273 if (round($median_value) != $median_value)
1277 $median_value = $median_value .
"<br />" .
"(" . $this->lng->txt(
"median_between") .
" " . (floor($median_value)) .
"-" . $cat->title .
" " . $this->lng->txt(
"and") .
" " . (ceil($median_value)) .
"-" . $cat2->title .
")";
1282 $median_value = $median[((
$total+1)/2)-1];
1289 $result_array[
"ARITHMETIC_MEAN"] =
"";
1290 $result_array[
"MEDIAN"] = $median_value;
1291 $result_array[
"QUESTION_TYPE"] =
"SurveyMatrixQuestion";
1292 $result_array[
"ROW"] = $this->
getRow($rowindex)->title;
1293 return $result_array;
1307 $question_id = $this->
getId();
1309 $result_array = array();
1312 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_answer.question_fi = %s AND svy_finished.survey_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
1313 array(
'integer',
'integer'),
1321 while (
$row = $ilDB->fetchAssoc($result))
1329 $numrows = $result->numRows();
1339 $result_array[
"MODE"] = $prefix . $cat->title;
1340 $result_array[
"MODE_VALUE"] = key(
$cumulated)+1;
1347 $percentage = (float)((
int)
$cumulated[$key]/$numrows);
1350 $result_array[
"variables"][$key] = array(
"title" => $cat->title,
"selected" => (
int)
$cumulated[$key],
"percentage" => $percentage);
1358 for ($i = 0; $i < $key; $i++)
1360 array_push($median, $value+1);
1367 $median_value = 0.5 * ($median[(
$total/2)-1] + $median[(
$total/2)]);
1368 if (round($median_value) != $median_value)
1372 $median_value = $median_value .
"<br />" .
"(" . $this->lng->txt(
"median_between") .
" " . (floor($median_value)) .
"-" . $cat->title .
" " . $this->lng->txt(
"and") .
" " . (ceil($median_value)) .
"-" . $cat2->title .
")";
1377 $median_value = $median[((
$total+1)/2)-1];
1384 $result_array[
"ARITHMETIC_MEAN"] =
"";
1385 $result_array[
"MEDIAN"] = $median_value;
1386 $result_array[
"QUESTION_TYPE"] =
"SurveyMatrixQuestion";
1388 $cumulated_results = array();
1389 $cumulated_results[
"TOTAL"] = $result_array;
1393 $cumulated_results[$i] = $rowresult;
1395 return $cumulated_results;
1409 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1411 switch ($export_label)
1414 $adapter->setCellValue(
$row, $column, $this->label);
1417 $adapter->setCellValue(
$row, $column, $this->
getTitle());
1420 $adapter->setCellValue(
$row, $column, $this->
getTitle());
1422 $adapter->setCellValue(
$row, $column, $this->label);
1428 $adapter->setCellValue(
$row, $column, $this->lng->txt($eval_data[
"TOTAL"][
"QUESTION_TYPE"]));
1430 $adapter->setCellValue(
$row, $column, $eval_data[
"TOTAL"][
"USERS_ANSWERED"]);
1432 $adapter->setCellValue(
$row, $column, $eval_data[
"TOTAL"][
"USERS_SKIPPED"]);
1434 $adapter->setCellValue(
$row, $column, $eval_data[
"TOTAL"][
"MODE_VALUE"]);
1436 $adapter->setCellValue(
$row, $column, $eval_data[
"TOTAL"][
"MODE"]);
1438 $adapter->setCellValue(
$row, $column, $eval_data[
"TOTAL"][
"MODE_NR_OF_SELECTIONS"]);
1440 $adapter->setCellValue(
$row, $column, str_replace(
"<br />",
" ", $eval_data[
"TOTAL"][
"MEDIAN"]));
1442 $adapter->setCellValue(
$row, $column, $eval_data[
"TOTAL"][
"ARITHMETIC_MEAN"]);
1445 switch ($export_label)
1454 foreach ($eval_data as $evalkey => $evalvalue)
1456 if (is_numeric($evalkey))
1458 $adapter->setCellValue(
$row, 1+$add, $evalvalue[
"ROW"]);
1459 $adapter->setCellValue(
$row, 3+$add, $evalvalue[
"USERS_ANSWERED"]);
1460 $adapter->setCellValue(
$row, 4+$add, $evalvalue[
"USERS_SKIPPED"]);
1461 $adapter->setCellValue(
$row, 5+$add, $evalvalue[
"MODE_VALUE"]);
1462 $adapter->setCellValue(
$row, 6+$add, $evalvalue[
"MODE"]);
1463 $adapter->setCellValue(
$row, 7+$add, $evalvalue[
"MODE_NR_OF_SELECTIONS"]);
1464 $adapter->setCellValue(
$row, 8+$add, str_replace(
"<br />",
" ", $evalvalue[
"MEDIAN"]));
1465 $adapter->setCellValue(
$row, 9+$add, $evalvalue[
"ARITHMETIC_MEAN"]);
1482 foreach ($eval_data as $evalkey => $evalvalue)
1485 if (is_numeric($evalkey))
1487 array_push($csvrow,
"");
1488 array_push($csvrow, $evalvalue[
"ROW"]);
1489 array_push($csvrow,
"");
1493 switch ($export_label)
1496 array_push($csvrow, $this->label);
1499 array_push($csvrow, $this->
getTitle());
1502 array_push($csvrow, $this->
getTitle());
1503 array_push($csvrow, $this->label);
1507 array_push($csvrow, $this->lng->txt($evalvalue[
"QUESTION_TYPE"]));
1509 array_push($csvrow, $evalvalue[
"USERS_ANSWERED"]);
1510 array_push($csvrow, $evalvalue[
"USERS_SKIPPED"]);
1511 array_push($csvrow, $evalvalue[
"MODE"]);
1512 array_push($csvrow, $evalvalue[
"MODE_NR_OF_SELECTIONS"]);
1513 array_push($csvrow, $evalvalue[
"MEDIAN"]);
1514 array_push($csvrow, $evalvalue[
"ARITHMETIC_MEAN"]);
1515 array_push($result, $csvrow);
1529 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1530 $adapter->addWorksheet($this->
getTitle());
1531 $adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
1533 switch ($export_label)
1537 $adapter->setCellValue(0, 1, $this->label);
1541 $adapter->setCellValue(0, 1, $this->
getTitle());
1545 $adapter->setCellValue(0, 1, $this->
getTitle());
1547 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"label"),
CELL_FORMAT_BOLD);
1548 $adapter->setCellValue($rowcounter, 1, $this->label);
1552 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"question"),
CELL_FORMAT_BOLD);
1555 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"question_type"),
CELL_FORMAT_BOLD);
1556 $adapter->setCellValue($rowcounter, 1, $this->lng->txt($this->getQuestionType()));
1558 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"users_answered"),
CELL_FORMAT_BOLD);
1559 $adapter->setCellValue($rowcounter, 1, $eval_data[
"TOTAL"][
"USERS_ANSWERED"]);
1561 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"users_skipped"),
CELL_FORMAT_BOLD);
1562 $adapter->setCellValue($rowcounter, 1, $eval_data[
"TOTAL"][
"USERS_SKIPPED"]);
1565 preg_match(
"/(.*?)\s+-\s+(.*)/", $eval_data[
"TOTAL"][
"MODE"], $matches);
1566 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"mode"),
CELL_FORMAT_BOLD);
1567 $adapter->setCellValue($rowcounter++, 1, $matches[1]);
1568 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"mode_text"),
CELL_FORMAT_BOLD);
1569 $adapter->setCellValue($rowcounter++, 1, $matches[2]);
1570 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"mode_nr_of_selections"),
CELL_FORMAT_BOLD);
1571 $adapter->setCellValue($rowcounter++, 1, $eval_data[
"TOTAL"][
"MODE_NR_OF_SELECTIONS"]);
1572 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"median"),
CELL_FORMAT_BOLD);
1573 $adapter->setCellValue($rowcounter++, 1, str_replace(
"<br />",
" ", $eval_data[
"TOTAL"][
"MEDIAN"]));
1574 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"categories"),
CELL_FORMAT_BOLD);
1575 $adapter->setCellValue($rowcounter, 1, $this->lng->txt(
"title"),
CELL_FORMAT_TITLE);
1576 $adapter->setCellValue($rowcounter, 2, $this->lng->txt(
"value"),
CELL_FORMAT_TITLE);
1577 $adapter->setCellValue($rowcounter, 3, $this->lng->txt(
"category_nr_selected"),
CELL_FORMAT_TITLE);
1578 $adapter->setCellValue($rowcounter++, 4, $this->lng->txt(
"percentage_of_selections"),
CELL_FORMAT_TITLE);
1580 foreach ($eval_data[
"TOTAL"][
"variables"] as $key => $value)
1582 $adapter->setCellValue($rowcounter, 1, $value[
"title"]);
1583 $adapter->setCellValue($rowcounter, 2, $key+1);
1584 $adapter->setCellValue($rowcounter, 3, $value[
"selected"]);
1588 foreach ($eval_data as $evalkey => $evalvalue)
1590 if (is_numeric($evalkey))
1592 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"row"),
CELL_FORMAT_BOLD);
1593 $adapter->setCellValue($rowcounter, 1, $evalvalue[
"ROW"]);
1594 $adapter->setCellValue($rowcounter + 1, 0, $this->lng->txt(
"users_answered"),
CELL_FORMAT_BOLD);
1595 $adapter->setCellValue($rowcounter + 1, 1, $evalvalue[
"USERS_ANSWERED"]);
1596 $adapter->setCellValue($rowcounter + 2, 0, $this->lng->txt(
"users_skipped"),
CELL_FORMAT_BOLD);
1597 $adapter->setCellValue($rowcounter + 2, 1, $evalvalue[
"USERS_SKIPPED"]);
1598 $rowcounter = $rowcounter + 3;
1600 preg_match(
"/(.*?)\s+-\s+(.*)/", $evalvalue[
"MODE"], $matches);
1601 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"mode"),
CELL_FORMAT_BOLD);
1602 $adapter->setCellValue($rowcounter++, 1, $matches[1]);
1603 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"mode_text"),
CELL_FORMAT_BOLD);
1604 $adapter->setCellValue($rowcounter++, 1, $matches[2]);
1605 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"mode_nr_of_selections"),
CELL_FORMAT_BOLD);
1606 $adapter->setCellValue($rowcounter++, 1, $evalvalue[
"MODE_NR_OF_SELECTIONS"]);
1607 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"median"),
CELL_FORMAT_BOLD);
1608 $adapter->setCellValue($rowcounter++, 1, str_replace(
"<br />",
" ", $evalvalue[
"MEDIAN"]));
1609 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"categories"),
CELL_FORMAT_BOLD);
1610 $adapter->setCellValue($rowcounter, 1, $this->lng->txt(
"title"),
CELL_FORMAT_TITLE);
1611 $adapter->setCellValue($rowcounter, 2, $this->lng->txt(
"value"),
CELL_FORMAT_TITLE);
1612 $adapter->setCellValue($rowcounter, 3, $this->lng->txt(
"category_nr_selected"),
CELL_FORMAT_TITLE);
1613 $adapter->setCellValue($rowcounter++, 4, $this->lng->txt(
"percentage_of_selections"),
CELL_FORMAT_TITLE);
1615 foreach ($evalvalue[
"variables"] as $key => $value)
1617 $adapter->setCellValue($rowcounter, 1, $value[
"title"]);
1618 $adapter->setCellValue($rowcounter, 2, $key+1);
1619 $adapter->setCellValue($rowcounter, 3, $value[
"selected"]);
1623 if (is_array($evalvalue[
"textanswers"]))
1625 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"freetext_answers"),
CELL_FORMAT_BOLD);
1626 $adapter->setCellValue($rowcounter, 1, $this->lng->txt(
"title"),
CELL_FORMAT_TITLE);
1627 $adapter->setCellValue($rowcounter++, 2, $this->lng->txt(
"answer"),
CELL_FORMAT_TITLE);
1629 foreach ($evalvalue[
"textanswers"] as $key => $answers)
1631 $title = $evalvalue[
"variables"][$key][
"title"];
1632 foreach ($answers as $answer)
1634 $adapter->setCellValue($rowcounter, 1,
$title);
1635 $adapter->setCellValue($rowcounter++, 2, $answer);
1641 $adapter->setCellValue($rowcounter, 0, $this->lng->txt(
"overview"),
CELL_FORMAT_BOLD);
1646 foreach ($eval_data[
"TOTAL"][
"variables"] as $variable)
1648 $adapter->setCellValue($rowcounter, 1+$counter, $variable[
"title"],
CELL_FORMAT_TITLE);
1653 foreach ($eval_data as $index =>
$data)
1655 if (is_numeric($index))
1659 foreach (
$data[
"variables"] as $vardata)
1661 $adapter->setCellValue($rowcounter, $counter, $vardata[
"selected"],
CELL_FORMAT_CENTER);
1683 switch ($a_export_label)
1697 array_push($a_array,
$title);
1701 array_push($a_array,
$title.
' - '. $this->lng->txt(
'other'));
1712 array_push($a_array, ($index+1) .
" - " . $col->title);
1728 if (count($resultset[
"answers"][$this->
getId()]))
1730 array_push($a_array,
"");
1739 foreach ($resultset[
"answers"][$this->
getId()] as $result)
1741 if ($result[
"rowvalue"] == $i)
1744 array_push($a_array, $result[
"value"] + 1);
1745 if ($result[
"textanswer"])
1747 $textanswer = $result[
"textanswer"];
1753 array_push($a_array, $this->lng->txt(
"skipped"));
1758 array_push($a_array, $textanswer);
1768 $checked_values = array();
1769 foreach ($resultset[
"answers"][$this->
getId()] as $result)
1771 if ($result[
"rowvalue"] == $i)
1774 array_push($checked_values, $result[
"value"] + 1);
1775 if ($result[
"textanswer"])
1777 $textanswer = $result[
"textanswer"];
1783 array_push($a_array, $this->lng->txt(
"skipped"));
1787 array_push($a_array,
"");
1792 array_push($a_array, $textanswer);
1798 array_push($a_array,
"");
1802 if (in_array($index+1, $checked_values))
1804 array_push($a_array, 1);
1808 array_push($a_array, 0);
1818 array_push($a_array, $this->lng->txt(
"skipped"));
1821 array_push($a_array,
"");
1827 array_push($a_array,
"");
1837 array_push($a_array,
"");
1858 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_finished.survey_fi = %s AND svy_answer.question_fi = %s AND svy_finished.finished_id = svy_answer.active_fi ORDER BY rowvalue, value",
1859 array(
'integer',
'integer'),
1863 while (
$row = $ilDB->fetchAssoc($result))
1866 if (!is_array($answers[
$row[
"active_fi"]])) $answers[$row[
"active_fi"]] = array();
1867 $rowobj = $this->
getRow($row[
"rowvalue"]);
1868 array_push($answers[$row[
"active_fi"]], $rowobj->title . (($rowobj->other) ? (
" " . $row[
"textanswer"]) :
"") .
": " . ($row[
"value"] + 1) .
" - " . $column->title);
1870 foreach ($answers as $key => $value)
1872 $answers[$key] = implode(
"<br />", $value);
1904 $this->subtype = $a_subtype;
1924 $this->columnSeparators = 1;
1928 $this->columnSeparators = 0;
1941 return ($this->columnSeparators) ? 1 : 0;
1955 $this->rowSeparators = 1;
1959 $this->rowSeparators = 0;
1972 return ($this->rowSeparators) ? 1 : 0;
1986 $this->neutralColumnSeparator = 1;
1990 $this->neutralColumnSeparator = 0;
2003 return ($this->neutralColumnSeparator) ? 1 : 0;
2016 foreach ($a_meta as $key => $value)
2018 switch ($value[
"label"])
2020 case "column_separators":
2023 case "row_separators":
2029 case "neutral_column_separator":
2045 foreach ($a_data as $adjective)
2047 if (is_numeric($adjective[
"label"]))
2067 foreach ($a_data as
$row)
2069 $this->
addRow($row[
'title'], $row[
'other'], $row[
'label']);
2086 $column .= $material[
"text"];
2088 $this->columns->addCategory($column, null, (strcmp(
$data[
"label"],
"neutral") == 0) ?
true :
false);
2123 include_once
"./Services/Form/classes/class.ilSelectInputGUI.php";
2126 $step3->setOptions($options);
2127 $step3->setValue($default);
2141 if (count($this->cumulated) == 0)
2143 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
2148 if (is_numeric(
$type))
2150 foreach ($this->cumulated[
$type][
"variables"] as $key => $value)
2152 foreach ($value as $key2 => $value2)
2154 $this->cumulated[
"variables"][$key][$key2] = utf8_decode($value2);
2158 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyChart.php";
2159 $b1 =
new SurveyChart(
"bars", 400, 250, utf8_decode(
$title),utf8_decode($this->lng->txt(
"answers")), utf8_decode($this->lng->txt(
"users_answered")), $this->cumulated[
$type][
"variables"]);
2172 function saveLayout($percent_row, $percent_columns, $percent_bipolar_adjective1 =
"", $percent_bipolar_adjective2 =
"", $percent_neutral)
2177 "percent_row" => $percent_row,
2178 "percent_columns" => $percent_columns,
2179 "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
2180 "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
2181 "percent_neutral" => $percent_neutral
2183 $affectedRows = $ilDB->manipulateF(
"UPDATE " . $this->
getAdditionalTableName() .
" SET layout = %s WHERE question_fi = %s",
2184 array(
'text',
'integer'),
2191 if (!is_array($this->layout) || count($this->layout) == 0)
2195 $this->layout = array(
2196 "percent_row" => 30,
2197 "percent_columns" => 40,
2198 "percent_bipolar_adjective1" => 10,
2199 "percent_bipolar_adjective2" => 10,
2200 "percent_neutral" => 10
2205 $this->layout = array(
2206 "percent_row" => 30,
2207 "percent_columns" => 50,
2208 "percent_bipolar_adjective1" => 10,
2209 "percent_bipolar_adjective2" => 10,
2210 "percent_neutral" => 0
2215 $this->layout = array(
2216 "percent_row" => 30,
2217 "percent_columns" => 50,
2218 "percent_bipolar_adjective1" => 0,
2219 "percent_bipolar_adjective2" => 0,
2220 "percent_neutral" => 20
2225 $this->layout = array(
2226 "percent_row" => 30,
2227 "percent_columns" => 70,
2228 "percent_bipolar_adjective1" => 0,
2229 "percent_bipolar_adjective2" => 0,
2230 "percent_neutral" => 0
2245 $this->layout = unserialize(
$layout);
2273 foreach ($this->columns as $column)
2275 if ($column->neutral && strlen($column->title))
return true;
2287 $this->columnPlaceholders = ($a_value) ? 1 : 0;
2297 return ($this->columnPlaceholders) ? 1 : 0;
2307 $this->legend = ($a_value) ? 1 : 0;
2317 return ($this->legend) ? 1 : 0;
2322 $this->singleLineRowCaption = ($a_value) ? 1 : 0;
2327 return ($this->singleLineRowCaption) ? 1 : 0;
2332 $this->repeatColumnHeader = ($a_value) ? 1 : 0;
2337 return ($this->repeatColumnHeader) ? 1 : 0;
2342 $this->columnHeaderPosition = $a_value;
2347 return ($this->columnHeaderPosition) ? $this->columnHeaderPosition : 0;
2352 $this->randomRows = ($a_value) ? 1 : 0;
2357 return ($this->randomRows) ? 1 : 0;
2362 $this->columnOrder = $a_value;
2367 return ($this->columnOrder) ? $this->columnOrder : 0;
2372 $this->columnImages = ($a_value) ? 1 : 0;
2377 return ($this->columnImages) ? 1 : 0;
2382 $this->rowImages = ($a_value) ? 1 : 0;
2387 return ($this->rowImages) ? 1 : 0;
2407 include_once
"./Services/Utilities/classes/class.ilStr.php";
2412 'counter' => $counter,
2415 'users_answered' =>
$cumulated[
'TOTAL'][
'USERS_ANSWERED'],
2416 'users_skipped' =>
$cumulated[
'TOTAL'][
'USERS_SKIPPED'],
2417 'question_type' => $this->lng->txt(
$cumulated[
'TOTAL'][
'QUESTION_TYPE']),
2419 'mode_nr_of_selections' =>
$cumulated[
'TOTAL'][
'MODE_NR_OF_SELECTIONS'],
2421 'arithmetic_mean' =>
$cumulated[
'TOTAL'][
'ARITHMETIC_MEAN']
2423 array_push($result,
$row);
2426 if (is_numeric($key))
2430 'question' => ($key+1) .
". " . $value[
'ROW'],
2431 'users_answered' => $value[
'USERS_ANSWERED'],
2432 'users_skipped' => $value[
'USERS_SKIPPED'],
2433 'question_type' =>
'',
2434 'mode' => $value[
"MODE"],
2435 'mode_nr_of_selections' => $value[
"MODE_NR_OF_SELECTIONS"],
2436 'median' => $value[
"MEDIAN"],
2437 'arithmetic_mean' => $value[
"ARITHMETIC_MEAN"]
2439 array_push($result,
$row);