24 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
198 if (!$this->author) {
199 $this->author = $this->ilias->account->fullname;
202 if ($this->owner == -1) {
203 $this->owner = $this->ilias->account->id;
206 $this->survey_id = -1;
207 $this->obligatory = 1;
208 $this->orientation = 0;
209 $this->materials = array();
210 $this->material = array();
211 register_shutdown_function(array(&$this,
'_SurveyQuestion'));
247 if (strcmp($questionpool_object,
"") != 0)
249 $refwhere = sprintf(
" AND obj_fi = %s",
250 $ilDB->quote($questionpool_object)
253 $query = sprintf(
"SELECT question_id FROM survey_question WHERE title = %s$refwhere",
256 $result = $ilDB->query($query);
257 if ($result->numRows() == 1)
291 $this->obligatory = 1;
295 $this->obligatory = 0;
312 $this->orientation = 0;
345 $this->survey_id =
$id;
375 if(empty($materials_name))
377 $materials_name = $materials_file;
379 if ((!empty($materials_name))&&(!$this->
keyInArray($materials_name, $this->materials)))
381 $this->materials[$materials_name] = $materials_file;
400 foreach ($array as $key => $value)
402 if (strcmp($key, $searchkey)==0)
420 function setMaterialsfile($materials_filename, $materials_tempfilename=
"", $materials_name=
"")
422 if (!empty($materials_filename))
424 include_once
"./Services/Utilities/classes/class.ilUtil.php";
426 if (!file_exists($materialspath))
432 $materialspath.$materials_filename))
434 print
"image not uploaded!!!! ";
438 $this->
addMaterials($materials_filename, $materials_name);
454 foreach ($this->materials as $key => $value)
456 if (strcmp($key, $materials_name)==0)
462 unset($this->materials[$key]);
477 $this->materials = array();
493 $author = $this->ilias->account->fullname;
570 $query = sprintf(
"SELECT * FROM survey_question_obligatory WHERE survey_fi = %s AND question_fi = %s",
572 $ilDB->quote($this->
getId() .
"")
574 $result = $ilDB->query($query);
575 if ($result->numRows())
577 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
578 return $row[
"obligatory"];
616 switch ($this->orientation)
623 $this->orientation = 0;
721 if ($this->
getId() <= 0)
728 $original_id = $this->
getId();
744 $clone->saveToDb($original_id);
751 $clone->duplicateMaterials($original_id);
753 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
754 return $clone->getId();
766 if ($this->
getId() <= 0)
774 $source_questionpool = $this->
getObjId();
775 $clone->setObjId($target_questionpool);
784 $clone->duplicateMaterials($original_id);
786 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
787 return $clone->getId();
800 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
802 foreach (
$mobs as $mob)
821 $materialspath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $materialspath);
822 if (!file_exists($materialspath))
824 include_once
"./Services/Utilities/classes/class.ilUtil.php";
827 if (!copy($materialspath_original . $filename, $materialspath . $filename))
829 print
"material could not be duplicated!!!! ";
845 $query = sprintf(
"SELECT * FROM survey_material WHERE question_fi = %s",
846 $this->ilias->db->quote($this->getId() .
"")
848 $result = $this->ilias->db->query($query);
849 $this->material = array();
852 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
854 $this->material = array(
855 "internal_link" => $row[
"internal_link"],
856 "import_id" => $row[
"import_id"],
857 "title" => $row[
"material_title"]
875 $query = sprintf(
"SELECT complete FROM survey_question WHERE question_id = %s",
876 $ilDB->quote($question_id .
"")
878 $result = $ilDB->query($query);
879 if ($result->numRows())
881 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
882 if ($row[
"complete"] == 1)
899 $question_id = $this->
getId();
900 if (strlen($original_id))
902 $question_id = $original_id;
913 $query = sprintf(
"UPDATE survey_question SET complete = %s WHERE question_id = %s",
914 $this->ilias->db->quote(
"$complete"),
915 $this->ilias->db->quote($question_id .
"")
917 $result = $this->ilias->db->query($query);
931 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
932 $query = sprintf(
"DELETE FROM survey_material WHERE question_fi = %s",
933 $this->ilias->db->quote($this->getId() .
"")
935 $result = $this->ilias->db->query($query);
937 if (count($this->material))
939 $query = sprintf(
"INSERT INTO survey_material (material_id, question_fi, internal_link, import_id, material_title, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
940 $this->ilias->db->quote($this->getId() .
""),
941 $this->ilias->db->quote($this->material[
"internal_link"] .
""),
942 $this->ilias->db->quote($this->material[
"import_id"] .
""),
943 $this->ilias->db->quote($this->material[
"title"] .
"")
945 $this->ilias->db->query($query);
946 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
976 return CLIENT_WEB_DIR .
"/survey/$this->obj_id/$this->id/images/";
989 return CLIENT_WEB_DIR .
"/survey/$this->obj_id/$this->id/materials/";
1002 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1017 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1034 $query = sprintf(
"DELETE FROM survey_question_material WHERE question_fi = %s",
1035 $this->ilias->db->quote($this->id)
1037 $result = $this->ilias->db->query($query);
1038 if (!empty($this->materials)) {
1039 foreach ($this->materials as $key => $value)
1041 $query = sprintf(
"INSERT INTO survey_question_material (question_fi, materials, materials_file) VALUES (%s, %s, %s)",
1042 $this->ilias->db->quote($this->id),
1043 $this->ilias->db->quote($key),
1044 $this->ilias->db->quote($value)
1046 $result = $this->ilias->db->query($query);
1062 $query = sprintf(
"SELECT * FROM survey_question_material WHERE question_fi = %s",
1063 $this->ilias->db->quote($question_id)
1065 $result = $this->ilias->db->query($query);
1066 if ($result->numRows() > 0)
1068 $this->materials = array();
1069 while (
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
1090 $query = sprintf(
"SELECT title, category_id FROM survey_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
1091 $this->ilias->db->quote($categorytext .
""),
1092 $this->ilias->db->quote($neutral .
""),
1093 $this->ilias->db->quote($ilUser->getId() .
"")
1095 $result = $this->ilias->db->query($query);
1101 while ($row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT))
1103 if (strcmp($row->title, $categorytext) == 0)
1105 $returnvalue = $row->category_id;
1116 $query = sprintf(
"INSERT INTO survey_category (category_id, title, neutral, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
1117 $this->ilias->db->quote($categorytext .
""),
1118 $this->ilias->db->quote($neutral .
""),
1119 $this->ilias->db->quote($ilUser->getId() .
"")
1121 $result = $this->ilias->db->query($query);
1122 $returnvalue = $this->ilias->db->getLastInsertId();
1124 return $returnvalue;
1138 $additional_table_name = $this->getAdditionalTableName();
1139 $query = sprintf(
"DELETE FROM $additional_table_name WHERE question_fi = %s",
1140 $ilDB->quote($question_id .
"")
1142 $result = $ilDB->query($query);
1153 function delete($question_id)
1155 if ($question_id < 1)
1158 $query = sprintf(
"SELECT obj_fi FROM survey_question WHERE question_id = %s",
1159 $this->ilias->db->quote($question_id)
1161 $result = $this->ilias->db->query($query);
1162 if ($result->numRows() == 1)
1164 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1172 $query = sprintf(
"DELETE FROM survey_answer WHERE question_fi = %s",
1173 $this->ilias->db->quote($question_id)
1175 $result = $this->ilias->db->query($query);
1177 $query = sprintf(
"SELECT constraint_id FROM survey_constraint WHERE question_fi = %s",
1178 $this->ilias->db->quote($question_id)
1180 $result = $this->ilias->db->query($query);
1181 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
1183 $query = sprintf(
"DELETE FROM survey_question_constraint WHERE constraint_fi = %s",
1184 $this->ilias->db->quote($row->constraint_id)
1186 $delresult = $this->ilias->db->query($query);
1189 $query = sprintf(
"DELETE FROM survey_constraint WHERE question_fi = %s",
1190 $this->ilias->db->quote($question_id)
1192 $result = $this->ilias->db->query($query);
1194 $query = sprintf(
"SELECT constraint_fi FROM survey_question_constraint WHERE question_fi = %s",
1195 $this->ilias->db->quote($question_id)
1197 $result = $this->ilias->db->query($query);
1198 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
1200 $query = sprintf(
"DELETE FROM survey_constraint WHERE constraint_id = %s",
1201 $this->ilias->db->quote($row->constraint_fi)
1203 $delresult = $this->ilias->db->query($query);
1205 $query = sprintf(
"DELETE FROM survey_question_constraint WHERE question_fi = %s",
1206 $this->ilias->db->quote($question_id)
1208 $result = $this->ilias->db->query($query);
1210 $query = sprintf(
"DELETE FROM survey_question_material WHERE question_fi = %s",
1211 $this->ilias->db->quote($question_id)
1213 $result = $this->ilias->db->query($query);
1215 $query = sprintf(
"DELETE FROM survey_questionblock_question WHERE question_fi = %s",
1216 $this->ilias->db->quote($question_id)
1218 $result = $this->ilias->db->query($query);
1220 $query = sprintf(
"DELETE FROM survey_question_obligatory WHERE question_fi = %s",
1221 $this->ilias->db->quote($question_id)
1223 $result = $this->ilias->db->query($query);
1225 $query = sprintf(
"DELETE FROM survey_survey_question WHERE question_fi = %s",
1226 $this->ilias->db->quote($question_id)
1228 $result = $this->ilias->db->query($query);
1230 $query = sprintf(
"DELETE FROM survey_variable WHERE question_fi = %s",
1231 $this->ilias->db->quote($question_id)
1233 $result = $this->ilias->db->query($query);
1235 $query = sprintf(
"DELETE FROM survey_question WHERE question_id = %s",
1236 $this->ilias->db->quote($question_id)
1238 $result = $this->ilias->db->query($query);
1242 $query = sprintf(
"DELETE FROM survey_material WHERE question_fi = %s",
1243 $this->ilias->db->quote($question_id)
1245 $result = $this->ilias->db->query($query);
1246 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1249 $directory = CLIENT_WEB_DIR .
"/survey/" .
$obj_id .
"/$question_id";
1250 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1252 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1256 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1262 foreach(
$mobs as $mob)
1283 if ($question_id < 1)
1286 $query = sprintf(
"SELECT type_tag FROM survey_question, survey_questiontype WHERE survey_question.question_id = %s AND survey_question.questiontype_fi = survey_questiontype.questiontype_id",
1287 $ilDB->quote($question_id)
1289 $result = $ilDB->query($query);
1290 if ($result->numRows() == 1)
1292 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
1293 return $data->type_tag;
1314 if ($question_id < 1)
return "";
1316 $query = sprintf(
"SELECT title FROM survey_question WHERE survey_question.question_id = %s",
1317 $ilDB->quote($question_id)
1319 $result = $ilDB->query($query);
1320 if ($result->numRows() == 1)
1322 $data = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1323 return $data[
"title"];
1343 $query = sprintf(
"SELECT * FROM survey_question WHERE question_id = %s",
1344 $ilDB->quote($question_id .
"")
1346 $result = $ilDB->query($query);
1347 if ($result->numRows() > 0)
1349 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1350 if ($row[
"original_id"] > 0)
1352 return $row[
"original_id"];
1356 return $row[
"question_id"];
1369 $query = sprintf(
"SELECT ref_id FROM object_reference WHERE obj_id=%s",
1373 $result = $ilDB->query($query);
1374 if ($result->numRows())
1376 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1377 return $row[
"ref_id"];
1384 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1385 $query = sprintf(
"DELETE FROM survey_material WHERE question_fi = %s",
1386 $this->ilias->db->quote($this->original_id .
"")
1388 $result = $this->ilias->db->query($query);
1390 if (strlen($this->material[
"internal_link"]))
1392 $query = sprintf(
"INSERT INTO survey_material (material_id, question_fi, internal_link, import_id, material_title, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
1393 $this->ilias->db->quote($this->original_id .
""),
1394 $this->ilias->db->quote($this->material[
"internal_link"] .
""),
1395 $this->ilias->db->quote($this->material[
"import_id"] .
""),
1396 $this->ilias->db->quote($this->material[
"title"] .
"")
1398 $this->ilias->db->query($query);
1399 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
1416 $query = sprintf(
"SELECT title FROM survey_phrase WHERE phrase_id = %s",
1417 $this->ilias->db->quote($phrase_id)
1419 $result = $this->ilias->db->query($query);
1420 if ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
1422 return $row[
"title"];
1440 $query = sprintf(
"SELECT phrase_id FROM survey_phrase WHERE title = %s AND owner_fi = %s",
1441 $this->ilias->db->quote(
$title),
1442 $this->ilias->db->quote($ilUser->id)
1444 $result = $this->ilias->db->query($query);
1445 if ($result->numRows() == 0)
1468 if ($question_id < 1)
1473 $query = sprintf(
"SELECT question_id FROM survey_question WHERE question_id = %s",
1474 $ilDB->quote($question_id)
1476 $result = $ilDB->query($query);
1477 if ($result->numRows() == 1)
1496 function setMaterial($material_id =
"", $is_import =
false, $material_title =
"")
1498 if (strcmp($material_id,
"") != 0)
1503 $import_id = $material_id;
1506 if (strcmp($material_title,
"") == 0)
1508 if (preg_match(
"/il__(\w+)_(\d+)/", $material_id, $matches))
1510 $type = $matches[1];
1512 $material_title = $this->lng->txt(
"obj_$type") .
": ";
1516 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1518 $cont_obj = $cont_obj_gui->object;
1519 $material_title .= $cont_obj->getTitle();
1522 include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
1523 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1525 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1527 $cont_obj = $cont_obj_gui->object;
1529 $material_title .= $pg_obj->getTitle();
1532 include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
1533 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1535 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1537 $cont_obj = $cont_obj_gui->object;
1539 $material_title .= $st_obj->getTitle();
1542 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1550 $this->material = array(
1551 "internal_link" => $material_id,
1552 "import_id" => $import_id,
1553 "title" => $material_title
1560 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
1562 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1563 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
1564 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1565 switch ($matches[2])
1583 if (strcmp($resolved_link,
"") == 0)
1585 $resolved_link = $internal_link;
1590 $resolved_link = $internal_link;
1592 return $resolved_link;
1599 $query = sprintf(
"SELECT * FROM survey_material WHERE question_fi = %s",
1600 $ilDB->quote($question_id .
"")
1602 $result = $ilDB->query($query);
1603 if ($result->numRows())
1605 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
1607 $internal_link = $row[
"internal_link"];
1608 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1610 if (strcmp($internal_link, $resolved_link) != 0)
1613 $queryupdate = sprintf(
"UPDATE survey_material SET internal_link = %s WHERE material_id = %s",
1614 $ilDB->quote($resolved_link),
1615 $ilDB->quote($row[
"material_id"] .
"")
1617 $updateresult = $ilDB->query($queryupdate);
1627 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1630 $query = sprintf(
"SELECT * FROM survey_material WHERE question_fi = %s",
1631 $ilDB->quote($question_id .
"")
1633 $result = $ilDB->query($query);
1634 if ($result->numRows())
1636 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
1638 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $row[
"internal_link"], $matches))
1651 "lm" =>
"LearningModule",
1652 "pg" =>
"PageObject",
1653 "st" =>
"StructureObject",
1654 "git" =>
"GlossaryItem",
1655 "mob" =>
"MediaObject"
1658 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
1660 $type = $matches[1];
1662 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1663 switch($linktypes[$matches[1]])
1665 case "LearningModule":
1669 case "StructureObject":
1672 case "GlossaryItem":
1697 if (($question_id < 1) || ($user_id < 1))
1702 $query = sprintf(
"SELECT obj_fi FROM survey_question WHERE question_id = %s",
1703 $ilDB->quote($question_id .
"")
1705 $result = $ilDB->query($query);
1706 if ($result->numRows() == 1)
1708 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1709 $qpl_object_id = $row[
"obj_fi"];
1710 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1730 $query = sprintf(
"SELECT questiontype_id FROM survey_questiontype WHERE type_tag = %s",
1731 $ilDB->quote($this->getQuestionType())
1733 $result = $ilDB->query($query);
1736 $row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC);
1737 return $row[
"questiontype_id"];
1767 $type = $question_type;
1768 if ($gui) $type .=
"GUI";
1769 if (file_exists(
"./Modules/SurveyQuestionPool/classes/class.".$type.
".php"))
1771 include_once
"./Modules/SurveyQuestionPool/classes/class.".$type.
".php";
1776 global $ilPluginAdmin;
1777 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
1778 foreach ($pl_names as $pl_name)
1781 if (strcmp($pl->getQuestionType(), $question_type) == 0)
1783 $pl->includeClass(
"class.".$type.
".php");
1799 if (file_exists(
"./Modules/SurveyQuestionPool/classes/class.".$type_tag.
".php"))
1802 return $lng->txt($type_tag);
1806 global $ilPluginAdmin;
1807 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
1808 foreach ($pl_names as $pl_name)
1811 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
1813 return $pl->getQuestionTypeTranslation();
1832 $question =
new $question_type();
1833 $question->loadFromDb($question_id);
1848 $guitype = $question_type .
"GUI";
1849 $question =
new $guitype($question_id);
1863 if (preg_match(
"/<[^>]*?>/", $a_text))
1883 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
1885 $material = $a_material->getMaterial($i);
1886 if (strcmp(
$material[
"type"],
"mattext") == 0)
1890 if (strcmp(
$material[
"type"],
"matimage") == 0)
1893 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
1896 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
1897 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
1912 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
1914 include_once
"./Services/RTE/classes/class.ilRTE.php";
1915 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1917 $a_xml_writer->xmlStartTag(
"material");
1919 "type" =>
"text/plain"
1921 if ($this->
isHTML($a_material))
1923 $attrs[
"type"] =
"text/xhtml";
1930 foreach (
$mobs as $mob)
1934 "label" =>
"il_" . IL_INST_ID .
"_mob_" . $mob,
1935 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
1937 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
1940 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
1951 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1980 array_push($a_array, $this->
getTitle());
2096 include_once (
"./classes/class.ilExcelUtils.php");
2100 $worksheet->write($row, 3, $eval_data[
"USERS_ANSWERED"]);
2101 $worksheet->write($row, 4, $eval_data[
"USERS_SKIPPED"]);
2104 $worksheet->write($row, 7, $eval_data[
"MODE_NR_OF_SELECTIONS"]);
2106 $worksheet->write($row, 9, $eval_data[
"ARITHMETIC_MEAN"]);
2126 array_push($csvrow, $this->
getTitle());
2128 array_push($csvrow, $this->lng->txt($eval_data[
"QUESTION_TYPE"]));
2129 array_push($csvrow, $eval_data[
"USERS_ANSWERED"]);
2130 array_push($csvrow, $eval_data[
"USERS_SKIPPED"]);
2131 array_push($csvrow, $eval_data[
"MODE"]);
2132 array_push($csvrow, $eval_data[
"MODE_NR_OF_SELECTIONS"]);
2133 array_push($csvrow, $eval_data[
"MEDIAN"]);
2134 array_push($csvrow, $eval_data[
"ARITHMETIC_MEAN"]);
2229 $this->original_id = $original_id;
2234 return $this->original_id;