24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
168 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
171 $this->bipolar_adjective1 =
"";
172 $this->bipolar_adjective2 =
"";
173 $this->rowSeparators = 0;
174 $this->columnSeparators = 0;
175 $this->neutralColumnSeparator = 1;
187 return $this->columns->getCategoryCount();
199 $this->columns->removeCategory($index);
211 $this->columns->removeCategories($array);
223 $this->columns->removeCategoryWithName($name);
244 return $this->columns->getCategory($index);
249 return $this->columns->getCategoryForScale($scale);
261 return $this->columns->getCategoryIndex($name);
273 $this->columns->flushCategories();
284 return $this->rows->getCategoryCount();
292 function addRow($a_text, $a_other, $a_label)
294 $this->rows->addCategory($a_text, $a_other, 0, $a_label);
305 $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
327 return $this->rows->getCategory($a_index);
332 $this->rows->moveCategoryUp($index);
337 $this->rows->moveCategoryDown($index);
349 $this->rows->removeCategories($array);
359 $this->rows->removeCategory($index);
374 return (strlen($this->bipolar_adjective2)) ? $this->bipolar_adjective2 : NULL;
378 return (strlen($this->bipolar_adjective1)) ? $this->bipolar_adjective1 : NULL;
396 $this->bipolar_adjective2 = $a_value;
400 $this->bipolar_adjective1 = $a_value;
416 $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",
417 array(
'integer',
'integer',
'integer'),
418 array($phrase_id, 0, $ilUser->getId())
422 $neutral =
$row[
"neutral"];
423 if ((
$row[
"defaultvalue"] == 1) && (
$row[
"owner_fi"] == 0))
425 $this->columns->addCategory($this->lng->txt(
$row[
"title"]), 0, $neutral);
429 $this->columns->addCategory(
$row[
"title"], 0, $neutral);
451 return $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",
517 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
526 parent::loadFromDb(
$id);
558 function saveToDb($original_id = NULL, $withanswers =
true)
562 $affectedRows = parent::saveToDb($original_id);
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())
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())
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");
886 parent::syncWithOriginal();
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, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
932 array(
'integer',
'text',
'text',
'integer',
'integer',
'text'),
933 array($next_id, $data[
'answer'], 1, $ilUser->getId(), time(), $data[
'neutral'])
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())
1112 $answer_data = array();
1118 foreach ($post_data as $key => $value)
1120 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
1124 $other_value = (array_key_exists(
'matrix_other_' . $this->
getId() .
'_' . $matches[1], $post_data))
1125 ? ($post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]])
1127 $answer_data[] = array(
"value"=>$value,
1128 "textanswer"=>$other_value,
1129 "rowvalue"=>$matches[1]);
1136 foreach ($post_data as $key => $value)
1138 if (preg_match(
"/matrix_" . $this->
getId() .
"_(\d+)/", $key, $matches))
1140 $other_value = (array_key_exists(
'matrix_other_' . $this->
getId() .
'_' . $matches[1], $post_data))
1141 ? ($post_data[
'matrix_other_' . $this->
getId() .
'_' . $matches[1]])
1143 foreach ($value as $checked)
1145 $answer_data[] = array(
"value"=>$checked,
1146 "textanswer"=>$other_value,
1147 "rowvalue"=>$matches[1]);
1156 return $answer_data;
1160 if(
sizeof($answer_data))
1163 foreach ($answer_data as $item)
1165 $next_id = $ilDB->nextId(
'svy_answer');
1168 $fields[
'answer_id'] = array(
"integer", $next_id);
1169 $fields[
'question_fi'] = array(
"integer", $this->
getId());
1170 $fields[
'active_fi'] = array(
"integer", $active_id);
1171 $fields[
'value'] = array(
"float", $item[
'value']);
1172 $fields[
'textanswer'] = array(
"clob", $item[
'textanswer']);
1173 $fields[
'rowvalue'] = array(
"integer", $item[
'rowvalue']);
1174 $fields[
'tstamp'] = array(
"integer", time());
1176 $affectedRows = $ilDB->insert(
"svy_answer", $fields);
1190 parent::deleteAdditionalTableData($question_id);
1193 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
1210 $sql =
"SELECT svy_answer.active_fi, svy_answer.question_fi".
1212 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1213 " WHERE svy_answer.question_fi = ".$ilDB->quote($this->
getId(),
"integer").
1214 " AND svy_finished.survey_fi = ".$ilDB->quote(
$survey_id,
"integer");
1217 $sql .=
" AND ".$ilDB->in(
"svy_finished.finished_id", $finished_ids,
"",
"integer");
1221 $sql .=
" AND rowvalue = ".$ilDB->quote($rowindex,
"integer");
1228 $found[
$row[
"active_fi"].$row[
"question_fi"]] = 1;
1230 return count($found);
1245 $question_id = $this->
getId();
1247 $result_array = array();
1250 $sql =
"SELECT svy_answer.* FROM svy_answer".
1251 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1252 " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id,
"integer").
1253 " AND svy_answer.rowvalue = ".$ilDB->quote($rowindex,
"integer").
1254 " AND svy_finished.survey_fi = ".$ilDB->quote(
$survey_id,
"integer");
1257 $sql .=
" AND ".$ilDB->in(
"svy_finished.finished_id", $finished_ids,
"",
"integer");
1270 if ($row[
"textanswer"])
1272 $result_array[
"textanswers"][$row[
"value"]][] = $row[
"textanswer"];
1276 if (is_array($result_array[
"textanswers"]))
1278 ksort($result_array[
"textanswers"], SORT_NUMERIC);
1284 $numrows =
$result->numRows();
1286 $result_array[
"USERS_SKIPPED"] = $nr_of_users - $result_array[
"USERS_ANSWERED"];
1296 $result_array[
"MODE"] = $prefix . $cat->title;
1297 $result_array[
"MODE_VALUE"] = key(
$cumulated)+1;
1303 $scale = $cat->scale-1;
1308 $percentage = (float)((
int)
$cumulated[$scale]/$numrows);
1311 $result_array[
"variables"][$key] = array(
"title" => $cat->title,
"selected" => (
int)
$cumulated[$scale],
"percentage" => $percentage);
1319 for ($i = 0; $i < $key; $i++)
1321 array_push($median, $value+1);
1328 $median_value = 0.5 * ($median[(
$total/2)-1] + $median[(
$total/2)]);
1329 if (round($median_value) != $median_value)
1333 $median_value = $median_value .
"<br />" .
"(" . $this->lng->txt(
"median_between") .
" " . (floor($median_value)) .
"-" . $cat->title .
" " . $this->lng->txt(
"and") .
" " . (ceil($median_value)) .
"-" . $cat2->title .
")";
1338 $median_value = $median[((
$total+1)/2)-1];
1345 $result_array[
"ARITHMETIC_MEAN"] =
"";
1346 $result_array[
"MEDIAN"] = $median_value;
1347 $result_array[
"QUESTION_TYPE"] =
"SurveyMatrixQuestion";
1348 $result_array[
"ROW"] = $this->
getRow($rowindex)->title;
1349 return $result_array;
1363 $question_id = $this->
getId();
1365 $result_array = array();
1368 $sql =
"SELECT svy_answer.* FROM svy_answer".
1369 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1370 " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id,
"integer").
1371 " AND svy_finished.survey_fi = ".$ilDB->quote(
$survey_id,
"integer");
1374 $sql .=
" AND ".$ilDB->in(
"svy_finished.finished_id", $finished_ids,
"",
"integer");
1390 $numrows =
$result->numRows();
1402 $result_array[
"MODE"] = $prefix . $cat->title;
1403 $result_array[
"MODE_VALUE"] = key(
$cumulated)+1;
1409 $scale = $cat->scale-1;
1414 $percentage = (float)((
int)
$cumulated[$scale]/$numrows);
1417 $result_array[
"variables"][$key] = array(
"title" => $cat->title,
"selected" => (
int)
$cumulated[$scale],
"percentage" => $percentage);
1425 for ($i = 0; $i < $key; $i++)
1427 array_push($median, $value+1);
1434 $median_value = 0.5 * ($median[(
$total/2)-1] + $median[(
$total/2)]);
1435 if (round($median_value) != $median_value)
1439 $median_value = $median_value .
"<br />" .
"(" . $this->lng->txt(
"median_between") .
" " . (floor($median_value)) .
"-" . $cat->title .
" " . $this->lng->txt(
"and") .
" " . (ceil($median_value)) .
"-" . $cat2->title .
")";
1444 $median_value = $median[((
$total+1)/2)-1];
1451 $result_array[
"ARITHMETIC_MEAN"] =
"";
1452 $result_array[
"MEDIAN"] = $median_value;
1453 $result_array[
"QUESTION_TYPE"] =
"SurveyMatrixQuestion";
1455 $cumulated_results = array();
1456 $cumulated_results[
"TOTAL"] = $result_array;
1460 $cumulated_results[$i] = $rowresult;
1462 return $cumulated_results;
1478 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1480 switch ($export_label)
1499 $worksheet->write(
$row, $column, $eval_data[
"TOTAL"][
"USERS_ANSWERED"]);
1501 $worksheet->write(
$row, $column, $eval_data[
"TOTAL"][
"USERS_SKIPPED"]);
1507 $worksheet->write(
$row, $column, $eval_data[
"TOTAL"][
"MODE_NR_OF_SELECTIONS"]);
1511 $worksheet->write(
$row, $column, $eval_data[
"TOTAL"][
"ARITHMETIC_MEAN"]);
1514 switch ($export_label)
1523 foreach ($eval_data as $evalkey => $evalvalue)
1525 if (is_numeric($evalkey))
1528 $worksheet->write(
$row, 3+$add, $evalvalue[
"USERS_ANSWERED"]);
1529 $worksheet->write(
$row, 4+$add, $evalvalue[
"USERS_SKIPPED"]);
1532 $worksheet->write(
$row, 7+$add, $evalvalue[
"MODE_NR_OF_SELECTIONS"]);
1534 $worksheet->write(
$row, 9+$add, $evalvalue[
"ARITHMETIC_MEAN"]);
1555 foreach ($eval_data as $evalkey => $evalvalue)
1558 if (is_numeric($evalkey))
1560 array_push($csvrow,
"");
1561 array_push($csvrow, $evalvalue[
"ROW"]);
1562 array_push($csvrow,
"");
1566 switch ($export_label)
1569 array_push($csvrow, $this->label);
1572 array_push($csvrow, $this->
getTitle());
1575 array_push($csvrow, $this->
getTitle());
1576 array_push($csvrow, $this->label);
1580 array_push($csvrow, $this->lng->txt($evalvalue[
"QUESTION_TYPE"]));
1582 array_push($csvrow, $evalvalue[
"USERS_ANSWERED"]);
1583 array_push($csvrow, $evalvalue[
"USERS_SKIPPED"]);
1584 array_push($csvrow, $evalvalue[
"MODE"]);
1585 array_push($csvrow, $evalvalue[
"MODE_NR_OF_SELECTIONS"]);
1586 array_push($csvrow, str_replace(
"<br />",
" ", $evalvalue[
"MEDIAN"]));
1587 array_push($csvrow, $evalvalue[
"ARITHMETIC_MEAN"]);
1604 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1605 $worksheet =& $workbook->addWorksheet();
1607 switch ($export_label)
1633 $worksheet->write($rowcounter, 1, $eval_data[
"TOTAL"][
"USERS_ANSWERED"]);
1636 $worksheet->write($rowcounter, 1, $eval_data[
"TOTAL"][
"USERS_SKIPPED"]);
1639 preg_match(
"/(.*?)\s+-\s+(.*)/", $eval_data[
"TOTAL"][
"MODE"], $matches);
1654 foreach ($eval_data[
"TOTAL"][
"variables"] as $key => $value)
1657 $worksheet->write($rowcounter, 2, $key+1);
1662 foreach ($eval_data as $evalkey => $evalvalue)
1664 if (is_numeric($evalkey))
1669 $worksheet->write($rowcounter + 1, 1, $evalvalue[
"USERS_ANSWERED"]);
1671 $worksheet->write($rowcounter + 2, 1, $evalvalue[
"USERS_SKIPPED"]);
1672 $rowcounter = $rowcounter + 3;
1674 preg_match(
"/(.*?)\s+-\s+(.*)/", $evalvalue[
"MODE"], $matches);
1689 foreach ($evalvalue[
"variables"] as $key => $value)
1692 $worksheet->write($rowcounter, 2, $key+1);
1698 if (is_array($evalvalue[
"textanswers"]))
1704 foreach ($evalvalue[
"textanswers"] as $key => $answers)
1706 $title = $evalvalue[
"variables"][$key][
"title"];
1707 foreach ($answers as $answer)
1717 $format_center =& $workbook->addFormat();
1718 $format_center->setColor(
'black');
1719 $format_center->setAlign(
'center');
1725 $worksheet->write($rowcounter, $counter,
"", $format_title);
1726 foreach ($eval_data[
"TOTAL"][
"variables"] as $variable)
1733 foreach ($eval_data as $index =>
$data)
1735 if (is_numeric($index))
1739 foreach (
$data[
"variables"] as $vardata)
1741 $worksheet->write($rowcounter, $counter, $vardata[
"selected"], $format_center);
1757 parent::addUserSpecificResultsExportTitles($a_array, $a_use_label, $a_substitute);
1779 array_push($a_array,
$title);
1783 if(!$a_use_label || $a_substitute)
1785 array_push($a_array,
$title.
' - '. $this->lng->txt(
'other'));
1789 array_push($a_array,
"");
1801 if(!$a_use_label || $a_substitute)
1803 array_push($a_array, ($index+1) .
" - " . $col->title);
1807 array_push($a_array,
"");
1824 if (count($resultset[
"answers"][$this->
getId()]))
1826 array_push($a_array,
"");
1836 foreach ($resultset[
"answers"][$this->
getId()] as
$result)
1838 if ($result[
"rowvalue"] == $i)
1841 array_push($a_array, $result[
"value"] + 1);
1843 if ($result[
"textanswer"])
1845 $textanswer = $result[
"textanswer"];
1855 array_push($a_array, $textanswer);
1866 $checked_values = array();
1867 foreach ($resultset[
"answers"][$this->
getId()] as
$result)
1869 if ($result[
"rowvalue"] == $i)
1872 array_push($checked_values, $result[
"value"] + 1);
1874 if ($result[
"textanswer"])
1876 $textanswer = $result[
"textanswer"];
1886 array_push($a_array,
"");
1890 array_push($a_array, $textanswer);
1896 array_push($a_array,
"");
1901 $scale = $cat->scale;
1902 if (in_array($scale, $checked_values))
1904 array_push($a_array, $scale);
1908 array_push($a_array, 0);
1921 array_push($a_array,
"");
1927 array_push($a_array,
"");
1937 array_push($a_array,
"");
1958 $sql =
"SELECT svy_answer.* FROM svy_answer".
1959 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1960 " WHERE svy_answer.question_fi = ".$ilDB->quote($this->
getId(),
"integer").
1961 " AND svy_finished.survey_fi = ".$ilDB->quote(
$survey_id,
"integer");
1964 $sql .=
" AND ".$ilDB->in(
"svy_finished.finished_id", $finished_ids,
"",
"integer");
1966 $sql .=
" ORDER BY rowvalue, value";
1972 if (!is_array($answers[
$row[
"active_fi"]])) $answers[$row[
"active_fi"]] = array();
1973 $rowobj = $this->
getRow($row[
"rowvalue"]);
1974 array_push($answers[$row[
"active_fi"]], $rowobj->title . (($rowobj->other) ? (
" " . $row[
"textanswer"]) :
"") .
": " . ($row[
"value"] + 1) .
" - " . $column->title);
1976 foreach ($answers as $key => $value)
1978 $answers[$key] = implode(
"<br />", $value);
2010 $this->subtype = $a_subtype;
2030 $this->columnSeparators = 1;
2034 $this->columnSeparators = 0;
2047 return ($this->columnSeparators) ? 1 : 0;
2061 $this->rowSeparators = 1;
2065 $this->rowSeparators = 0;
2078 return ($this->rowSeparators) ? 1 : 0;
2092 $this->neutralColumnSeparator = 1;
2096 $this->neutralColumnSeparator = 0;
2109 return ($this->neutralColumnSeparator) ? 1 : 0;
2122 foreach ($a_meta as $key => $value)
2124 switch ($value[
"label"])
2126 case "column_separators":
2129 case "row_separators":
2135 case "neutral_column_separator":
2151 foreach ($a_data as $adjective)
2153 if (is_numeric($adjective[
"label"]))
2173 foreach ($a_data as
$row)
2175 $this->
addRow($row[
'title'], $row[
'other'], $row[
'label']);
2192 $column .= $material[
"text"];
2194 $this->columns->addCategory($column, null, (strcmp(
$data[
"label"],
"neutral") == 0) ?
true :
false);
2229 include_once
"./Services/Form/classes/class.ilSelectInputGUI.php";
2233 $step3->setValue($default);
2246 function saveLayout($percent_row, $percent_columns, $percent_bipolar_adjective1 =
"", $percent_bipolar_adjective2 =
"", $percent_neutral)
2251 "percent_row" => $percent_row,
2252 "percent_columns" => $percent_columns,
2253 "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
2254 "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
2255 "percent_neutral" => $percent_neutral
2257 $affectedRows = $ilDB->manipulateF(
"UPDATE " . $this->
getAdditionalTableName() .
" SET layout = %s WHERE question_fi = %s",
2258 array(
'text',
'integer'),
2259 array(serialize($layout), $this->
getId())
2265 if (!is_array($this->layout) || count($this->layout) == 0)
2269 $this->layout = array(
2270 "percent_row" => 30,
2271 "percent_columns" => 40,
2272 "percent_bipolar_adjective1" => 10,
2273 "percent_bipolar_adjective2" => 10,
2274 "percent_neutral" => 10
2279 $this->layout = array(
2280 "percent_row" => 30,
2281 "percent_columns" => 50,
2282 "percent_bipolar_adjective1" => 10,
2283 "percent_bipolar_adjective2" => 10,
2284 "percent_neutral" => 0
2289 $this->layout = array(
2290 "percent_row" => 30,
2291 "percent_columns" => 50,
2292 "percent_bipolar_adjective1" => 0,
2293 "percent_bipolar_adjective2" => 0,
2294 "percent_neutral" => 20
2299 $this->layout = array(
2300 "percent_row" => 30,
2301 "percent_columns" => 70,
2302 "percent_bipolar_adjective1" => 0,
2303 "percent_bipolar_adjective2" => 0,
2304 "percent_neutral" => 0
2313 if (is_array($layout))
2319 $this->layout = unserialize($layout);
2350 if ($column->neutral && strlen($column->title))
return true;
2362 $this->columnPlaceholders = ($a_value) ? 1 : 0;
2372 return ($this->columnPlaceholders) ? 1 : 0;
2382 $this->legend = ($a_value) ? 1 : 0;
2392 return ($this->legend) ? 1 : 0;
2397 $this->singleLineRowCaption = ($a_value) ? 1 : 0;
2402 return ($this->singleLineRowCaption) ? 1 : 0;
2407 $this->repeatColumnHeader = ($a_value) ? 1 : 0;
2412 return ($this->repeatColumnHeader) ? 1 : 0;
2417 $this->columnHeaderPosition = $a_value;
2422 return ($this->columnHeaderPosition) ? $this->columnHeaderPosition : 0;
2427 $this->randomRows = ($a_value) ? 1 : 0;
2432 return ($this->randomRows) ? 1 : 0;
2437 $this->columnOrder = $a_value;
2442 return ($this->columnOrder) ? $this->columnOrder : 0;
2447 $this->columnImages = ($a_value) ? 1 : 0;
2452 return ($this->columnImages) ? 1 : 0;
2457 $this->rowImages = ($a_value) ? 1 : 0;
2462 return ($this->rowImages) ? 1 : 0;
2480 include_once
"./Services/Utilities/classes/class.ilStr.php";
2489 'counter' => $counter,
2490 'title' => $counter.
'. '.$this->getTitle(),
2492 'users_answered' =>
$cumulated[
'TOTAL'][
'USERS_ANSWERED'],
2493 'users_skipped' =>
$cumulated[
'TOTAL'][
'USERS_SKIPPED'],
2494 'question_type' => $this->lng->txt(
$cumulated[
'TOTAL'][
'QUESTION_TYPE']),
2496 'mode_nr_of_selections' =>
$cumulated[
'TOTAL'][
'MODE_NR_OF_SELECTIONS'],
2498 'arithmetic_mean' =>
$cumulated[
'TOTAL'][
'ARITHMETIC_MEAN']
2504 if (is_numeric($key))
2506 if (strlen($value[
'ROW']) > $maxlen + 3)
2508 $value[
'ROW'] = ilStr::substr($value[
'ROW'], 0, $maxlen) .
"...";
2513 'question' => ($key+1) .
". " . $value[
'ROW'],
2514 'users_answered' => $value[
'USERS_ANSWERED'],
2515 'users_skipped' => $value[
'USERS_SKIPPED'],
2516 'question_type' =>
'',
2517 'mode' => $value[
"MODE"],
2518 'mode_nr_of_selections' => $value[
"MODE_NR_OF_SELECTIONS"],
2519 'median' => $value[
"MEDIAN"],
2520 'arithmetic_mean' => $value[
"ARITHMETIC_MEAN"]
toXML($a_include_header=TRUE, $obligatory_state="")
Returns an xml representation of the question.
addRowAtPosition($a_text, $a_other, $a_position)
Adds a row at a given position.
saveCompletionStatus($original_id="")
Saves the complete flag to the database.
getAuthor()
Gets the authors name of the SurveyQuestion object.
$cumulated
An array containing the cumulated results of the question for a given survey.
getColumnForScale($scale)
getTitle()
Gets the title string of the SurveyQuestion object.
getBipolarAdjective($a_index)
Returns one of the bipolar adjectives.
getCumulatedResultData($survey_id, $counter, $finished_ids)
Creates a the cumulated results data for the question.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getRow($a_index)
Returns a specific row.
& getCumulatedResults($survey_id, $nr_of_users, $finished_ids)
Returns the cumulated results for the question.
setExportCumulatedXLS(&$worksheet, &$format_title, &$format_bold, &$eval_data, $row, $export_label)
Creates the Excel output for the cumulated results of this question.
_getQuestionDataArray($id)
Returns the question data fields from the database.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
_convert_text($a_text, $a_target="has been removed")
saveToDb($original_id=NULL, $withanswers=true)
Saves a SurveyMatrixQuestion object to a database.
savePhrase($title)
Saves a set of columns to a default phrase.
setColumnPlaceholders($a_value=0)
Set whether placeholders should be used for the column titles or not.
setId($id=-1)
Sets the id of the SurveyQuestion object.
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.
getNrOfUsersAnswered($survey_id, $finished_ids=null, $rowindex=null)
Returns the number of users that answered the question for a given survey.
SurveyMatrixQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyMatrixQuestion constructor The constructor takes possible arguments an creates an instance of t...
removeRows($array)
Removes rows from the question.
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
saveBipolarAdjectives($adjective1, $adjective2)
setColumnHeaderPosition($a_value)
setSingleLineRowCaption($a_value=0)
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
setColumnImages($a_value=0)
getRowSeparators()
Gets the separators enable state for the matrix rows.
saveRandomData($active_id)
Saves random answers for a given active user in the database.
getColumns()
Return the columns.
getPreconditionValueOutput($value)
Returns the output for a precondition value.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
getColumn($index)
Returns the name of a column for a given index.
setExportDetailsXLS(&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
Creates an Excel worksheet for the detailed cumulated results of this question.
addUserSpecificResultsData(&$a_array, &$resultset)
Adds the values for the user specific results export for a given user.
setComplete($a_complete)
Sets the complete state of the question.
flushColumns()
Empties the columns list.
deleteAdditionalTableData($question_id)
Deletes datasets from the additional question table in the database.
getPreconditionOptions()
Returns the options for preconditions.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
saveLayout($percent_row, $percent_columns, $percent_bipolar_adjective1="", $percent_bipolar_adjective2="", $percent_neutral)
Saves the layout of a matrix question.
importAdjectives($a_data)
Import bipolar adjectives from the question import file.
getSingleLineRowCaption()
setOriginalId($original_id)
SurveyQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the Sur...
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
hasNeutralColumn()
Returns TRUE if a neutral column exists.
setNeutralColumnSeparator($enable=0)
Enables/Disables a separator for the neutral column.
getLegend()
Get whether the legend should be shown or not.
& calculateCumulatedResults($survey_id, $finished_ids)
if(!is_array($argv)) $options
usableForPrecondition()
Returns if the question is usable for preconditions.
getId()
Gets the id of the SurveyQuestion object.
addStandardNumbers($lower_limit, $upper_limit)
Adds standard numbers as columns.
The SurveyMatrixQuestion class defines and encapsulates basic methods and attributes for matrix quest...
setRepeatColumnHeader($a_value=0)
Basic class for all survey question types.
removeRow($index)
Removes a row.
importMatrix($a_data)
Import matrix rows from the question import file.
saveMaterial()
save material to db
importResponses($a_data)
Import response data from the question import file.
loadFromDb($id)
Loads a SurveyMatrixQuestion object from the database.
setLegend($a_value=0)
Set whether the legend should be shown or not.
addUserSpecificResultsExportTitles(&$a_array, $a_use_label=false, $a_substitute=true)
Adds the entries for the title row of the user specific results.
getPreconditionSelectValue($default="", $title, $variable)
Creates a form property for the precondition value.
setColumnSeparators($enable=0)
Enables/Disables separators for the matrix columns.
xmlHeader()
Writes xml header public.
saveColumnToDb($columntext, $neutral=0)
Saves a column to the database.
setSubtype($a_subtype=0)
Sets the subtype of the matrix question.
getColumnHeaderPosition()
getColumnIndex($name)
Returns the index of a column with a given name.
saveUserInput($post_data, $active_id, $a_return=false)
flushRows()
Empties the row list.
getSubtype()
Returns the subtype of the matrix question.
saveColumnsToDb($original_id="")
removeColumn($index)
Removes a column from the list of columns.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
setRowSeparators($enable=0)
Enables/Disables separators for the matrix rows.
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $a_attrs=null)
Creates an XML material tag from a plain text or xhtml text.
importAdditionalMetadata($a_meta)
Import additional meta data from the question import file.
removeColumnWithName($name)
Removes a column from the list of columns.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
addRow($a_text, $a_other, $a_label)
Adds a row to the question.
& getCumulatedResultsForRow($rowindex, $survey_id, $nr_of_users, $finished_ids)
Returns the cumulated results for a given row.
setRandomRows($a_value=0)
& getUserAnswers($survey_id, $finished_ids)
Returns an array containing all answers to this question in a given survey.
saveRowsToDb($original_id="")
getColumnPlaceholders()
Get whether placeholders should be used for the column titles or not.
insertXML(&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
Adds the question XML to a given XMLWriter object.
getDescription()
Gets the description string of the SurveyQuestion object.
getQuestionType()
Returns the question type of the question.
getColumnCount()
Returns the number of columns.
setObjId($obj_id=0)
Set the reference id of the container object.
getColumnSeparators()
Gets the separators enable state for the matrix columns.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setBipolarAdjective($a_index, $a_value)
Sets one of the bipolar adjectives.
& setExportCumulatedCVS(&$eval_data, $export_label)
Creates the CSV output for the cumulated results of this question.
getRowCount()
Returns the number of rows in the question.
getNeutralColumnSeparator()
Gets the separator enable state for the neutral column.
addPhrase($phrase_id)
Adds a phrase to the question.
removeColumns($array)
Removes many columns from the list of columns.
isComplete()
Returns 1 if the question is complete for use.
setTitle($title="")
Sets the title string of the SurveyQuestion object.