24 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
175 $this->cumulated = array();
178 $this->author = $this->ilias->account->fullname;
181 if ($this->owner == -1)
183 $this->owner = $this->ilias->account->id;
186 $this->survey_id = -1;
187 $this->obligatory = 1;
188 $this->orientation = 0;
189 $this->materials = array();
190 $this->material = array();
191 register_shutdown_function(array(&$this,
'_SurveyQuestion'));
206 $this->complete = ($a_complete) ? 1 : 0;
233 if (strcmp($questionpool_object,
"") != 0)
235 $refwhere = sprintf(
" AND obj_fi = %s",
236 $ilDB->quote($questionpool_object,
'integer')
239 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE title = %s$refwhere",
243 return (
$result->numRows() > 0) ?
true :
false;
303 $this->survey_id =
$id;
329 if (empty($materials_name))
331 $materials_name = $materials_file;
333 if ((!empty($materials_name))&&(!array_key_exists($materials_name, $this->materials)))
335 $this->materials[$materials_name] = $materials_file;
346 function setMaterialsfile($materials_filename, $materials_tempfilename=
"", $materials_name=
"")
348 if (!empty($materials_filename))
350 include_once
"./Services/Utilities/classes/class.ilUtil.php";
352 if (!file_exists($materialspath))
358 $materialspath.$materials_filename))
360 print
"image not uploaded!!!! ";
364 $this->
addMaterials($materials_filename, $materials_name);
378 foreach ($this->materials as
$key => $value)
380 if (strcmp(
$key, $materials_name)==0)
386 unset($this->materials[
$key]);
399 $this->materials = array();
413 $author = $this->ilias->account->fullname;
478 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s AND question_fi = %s",
479 array(
'integer',
'integer'),
485 return (
$row[
"obligatory"]) ? 1 : 0;
489 return ($this->obligatory) ? 1 : 0;
494 return ($this->obligatory) ? 1 : 0;
519 switch ($this->orientation)
526 $this->orientation = 0;
542 return (strlen($this->description)) ? $this->description : NULL;
554 return (strlen($this->author)) ? $this->author : NULL;
578 return (strlen($this->questiontext)) ? $this->questiontext : NULL;
611 if ($this->
getId() <= 0)
618 $original_id = $this->
getId();
634 $clone->saveToDb($original_id);
641 $clone->duplicateMaterials($original_id);
643 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
644 return $clone->getId();
654 if ($this->
getId() <= 0)
662 $source_questionpool = $this->
getObjId();
663 $clone->setObjId($target_questionpool);
672 $clone->duplicateMaterials($original_id);
674 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
675 return $clone->getId();
686 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
688 foreach (
$mobs as $mob)
704 $result = $ilDB->queryF(
"SELECT * FROM svy_material WHERE question_fi = %s",
706 array($this->
getId())
708 $this->material = array();
711 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
715 $mat->type =
$row[
'material_type'];
716 $mat->internal_link =
$row[
'internal_link'];
717 $mat->title =
$row[
'material_title'];
718 $mat->import_id =
$row[
'import_id'];
719 $mat->text_material =
$row[
'text_material'];
720 $mat->external_link =
$row[
'external_link'];
721 $mat->file_material =
$row[
'file_material'];
722 array_push($this->material, $mat);
737 $result = $ilDB->queryF(
"SELECT complete FROM svy_question WHERE question_id = %s",
744 if (
$row[
"complete"] == 1)
761 $question_id = $this->
getId();
762 if (strlen($original_id))
764 $question_id = $original_id;
767 if ($this->
getId() > 0)
770 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
771 array(
'text',
'integer',
'integer'),
772 array($this->
isComplete(), time(), $question_id)
788 include_once(
"./Services/RTE/classes/class.ilRTE.php");
791 if ($this->
getId() == -1)
794 $next_id = $ilDB->nextId(
'svy_question');
795 $affectedRows = $ilDB->insert(
"svy_question", array(
796 "question_id" => array(
"integer", $next_id),
798 "obj_fi" => array(
"integer", $this->
getObjId()),
799 "owner_fi" => array(
"integer", $this->
getOwner()),
800 "title" => array(
"text", $this->
getTitle()),
802 "author" => array(
"text", $this->
getAuthor()),
805 "complete" => array(
"text", $this->
isComplete()),
806 "created" => array(
"integer", time()),
807 "original_id" => array(
"integer", ($original_id) ? $original_id : NULL),
808 "tstamp" => array(
"integer", time())
810 $this->
setId($next_id);
815 $affectedRows = $ilDB->update(
"svy_question", array(
816 "title" => array(
"text", $this->
getTitle()),
818 "author" => array(
"text", $this->
getAuthor()),
821 "complete" => array(
"text", $this->
isComplete()),
822 "tstamp" => array(
"integer", time())
824 "question_id" => array(
"integer", $this->
getId())
827 return $affectedRows;
837 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
838 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_material WHERE question_fi = %s",
840 array($this->
getId())
846 $next_id = $ilDB->nextId(
'svy_material');
847 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_material " .
848 "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
849 "text_material, external_link, file_material, material_type) ".
850 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
851 array(
'integer',
'integer',
'text',
'text',
'text',
'integer',
'text',
'text',
'text',
'integer'),
853 $next_id, $this->
getId(), $material->internal_link, $material->import_id,
854 $material->title, time(), $material->text_material, $material->external_link,
855 $material->file_material, $material->type)
857 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches))
872 global
$ilDB, $ilUser;
877 $next_id = $ilDB->nextId(
'svy_question');
878 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_question (question_id, questiontype_fi, " .
879 "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
880 "created, original_id, tstamp) VALUES " .
881 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
882 array(
'integer',
'integer',
'integer',
'integer',
'text',
'text',
'text',
'text',
883 'text',
'text',
'integer',
'integer',
'integer'),
900 $this->
setId($next_id);
902 return $this->
getId();
923 return CLIENT_WEB_DIR .
"/survey/$this->obj_id/$this->id/images/";
934 return CLIENT_WEB_DIR .
"/survey/$this->obj_id/$this->id/materials/";
945 include_once
"./Services/Utilities/classes/class.ilUtil.php";
958 include_once
"./Services/Utilities/classes/class.ilUtil.php";
973 global $ilUser,
$ilDB;
975 $result = $ilDB->queryF(
"SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
976 array(
'text',
'text',
'integer'),
977 array($categorytext, $neutral, $ilUser->getId())
986 if (strcmp(
$row[
"title"], $categorytext) == 0)
988 $returnvalue =
$row[
"category_id"];
999 $next_id = $ilDB->nextId(
'svy_category');
1000 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
1001 array(
'integer',
'text',
'text',
'integer',
'integer'),
1002 array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
1004 $returnvalue = $next_id;
1006 return $returnvalue;
1018 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->getAdditionalTableName() .
" WHERE question_fi = %s",
1030 function delete($question_id)
1034 if ($question_id < 1)
return;
1036 $result = $ilDB->queryF(
"SELECT obj_fi FROM svy_question WHERE question_id = %s",
1050 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE question_fi = %s",
1055 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE question_fi = %s",
1060 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
1066 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
1068 array(
$row->constraint_fi)
1072 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE question_fi = %s",
1077 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE question_fi = %s",
1081 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_oblig WHERE question_fi = %s",
1085 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy_qst WHERE question_fi = %s",
1089 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
1093 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_question WHERE question_id = %s",
1100 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_material WHERE question_fi = %s",
1104 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1107 $directory = CLIENT_WEB_DIR .
"/survey/" .
$obj_id .
"/$question_id";
1108 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1110 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1114 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1120 foreach(
$mobs as $mob)
1139 if ($question_id < 1)
return "";
1141 $result = $ilDB->queryF(
"SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
1148 return $data[
"type_tag"];
1167 if ($question_id < 1)
return "";
1169 $result = $ilDB->queryF(
"SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1176 return $data[
"title"];
1194 $result = $ilDB->queryF(
"SELECT * FROM svy_question WHERE question_id = %s",
1201 if (
$row[
"original_id"] > 0)
1203 return $row[
"original_id"];
1207 return $row[
"question_id"];
1232 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1233 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_material WHERE question_fi = %s",
1238 if (strlen($this->material[
"internal_link"]))
1240 $next_id = $ilDB->nextId(
'svy_material');
1241 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
1242 array(
'integer',
'integer',
'text',
'text',
'text',
'integer'),
1243 array($next_id, $this->
getOriginalId(), $this->material[
"internal_link"], $this->material[
"import_id"], $this->material[
"title"], time())
1245 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
1263 $result = $ilDB->queryF(
"SELECT title FROM svy_phrase WHERE phrase_id = %s",
1269 return $row[
"title"];
1283 global $ilUser,
$ilDB;
1285 $result = $ilDB->queryF(
"SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1286 array(
'text',
'integer'),
1287 array(
$title, $ilUser->getId())
1289 return (
$result->numRows() == 0) ?
false :
true;
1303 if ($question_id < 1)
1308 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE question_id = %s",
1312 return (
$result->numRows() == 1) ?
true :
false;
1317 if (strlen($material_id))
1319 if (strcmp($material_title,
"") == 0)
1321 if (preg_match(
"/il__(\w+)_(\d+)/", $material_id, $matches))
1323 $type = $matches[1];
1325 $material_title = $this->lng->txt(
"obj_$type") .
": ";
1329 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1331 $cont_obj = $cont_obj_gui->object;
1332 $material_title .= $cont_obj->getTitle();
1335 include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
1336 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1338 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1340 $cont_obj = $cont_obj_gui->object;
1342 $material_title .= $pg_obj->getTitle();
1345 include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
1346 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1348 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1350 $cont_obj = $cont_obj_gui->object;
1352 $material_title .= $st_obj->getTitle();
1355 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1363 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
1366 $mat->internal_link = $material_id;
1367 $mat->title = $material_title;
1380 foreach ($a_array as $idx)
1382 unset($this->material[$idx]);
1384 $this->material = array_values($this->material);
1399 $materialspath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $materialspath);
1400 if (!file_exists($materialspath))
1402 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1405 if (!copy($materialspath_original . $filename, $materialspath . $filename))
1407 print
"material could not be duplicated!!!! ";
1414 array_push($this->material, $obj_material);
1424 function setMaterial($material_id =
"", $is_import =
false, $material_title =
"")
1426 if (strcmp($material_id,
"") != 0)
1431 $import_id = $material_id;
1434 if (strcmp($material_title,
"") == 0)
1436 if (preg_match(
"/il__(\w+)_(\d+)/", $material_id, $matches))
1438 $type = $matches[1];
1440 $material_title = $this->lng->txt(
"obj_$type") .
": ";
1444 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1446 $cont_obj = $cont_obj_gui->object;
1447 $material_title .= $cont_obj->getTitle();
1450 include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
1451 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1453 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1455 $cont_obj = $cont_obj_gui->object;
1457 $material_title .= $pg_obj->getTitle();
1460 include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
1461 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1463 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1465 $cont_obj = $cont_obj_gui->object;
1467 $material_title .= $st_obj->getTitle();
1470 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1478 $this->material = array(
1479 "internal_link" => $material_id,
1480 "import_id" => $import_id,
1481 "title" => $material_title
1489 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
1491 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1492 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
1493 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1494 switch ($matches[2])
1512 if (strcmp($resolved_link,
"") == 0)
1514 $resolved_link = $internal_link;
1519 $resolved_link = $internal_link;
1521 return $resolved_link;
1528 $result = $ilDB->queryF(
"SELECT * FROM svy_material WHERE question_fi = %s",
1536 $internal_link =
$row[
"internal_link"];
1537 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1539 if (strcmp($internal_link, $resolved_link) != 0)
1542 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
1543 array(
'text',
'integer',
'integer'),
1544 array($resolved_link, time(),
$row[
"material_id"])
1555 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1558 $result = $ilDB->queryF(
"SELECT * FROM svy_material WHERE question_fi = %s",
1566 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/",
$row[
"internal_link"], $matches))
1579 "lm" =>
"LearningModule",
1580 "pg" =>
"PageObject",
1581 "st" =>
"StructureObject",
1582 "git" =>
"GlossaryItem",
1583 "mob" =>
"MediaObject"
1586 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
1588 $type = $matches[1];
1590 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1591 switch($linktypes[$matches[1]])
1593 case "LearningModule":
1597 case "StructureObject":
1600 case "GlossaryItem":
1623 if (($question_id < 1) || ($user_id < 1))
1628 $result = $ilDB->queryF(
"SELECT obj_fi FROM svy_question WHERE question_id = %s",
1635 $qpl_object_id =
$row[
"obj_fi"];
1636 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1654 $result = $ilDB->queryF(
"SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1661 return $row[
"questiontype_id"];
1689 $type = $question_type;
1690 if ($gui)
$type .=
"GUI";
1691 if (file_exists(
"./Modules/SurveyQuestionPool/classes/class.".
$type.
".php"))
1693 include_once
"./Modules/SurveyQuestionPool/classes/class.".$type.
".php";
1698 global $ilPluginAdmin;
1699 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
1700 foreach ($pl_names as $pl_name)
1703 if (strcmp($pl->getQuestionType(), $question_type) == 0)
1705 $pl->includeClass(
"class.".
$type.
".php");
1721 if (file_exists(
"./Modules/SurveyQuestionPool/classes/class.".$type_tag.
".php"))
1724 return $lng->txt($type_tag);
1728 global $ilPluginAdmin;
1729 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
1730 foreach ($pl_names as $pl_name)
1733 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
1735 return $pl->getQuestionTypeTranslation();
1754 $question =
new $question_type();
1755 $question->loadFromDb($question_id);
1770 $guitype = $question_type .
"GUI";
1771 $question =
new $guitype($question_id);
1785 if (preg_match(
"/<[^>]*?>/", $a_text))
1805 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
1807 $material = $a_material->getMaterial($i);
1808 if (strcmp(
$material[
"type"],
"mattext") == 0)
1812 if (strcmp(
$material[
"type"],
"matimage") == 0)
1815 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
1818 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
1819 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
1834 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
1836 include_once
"./Services/RTE/classes/class.ilRTE.php";
1837 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1839 $a_xml_writer->xmlStartTag(
"material");
1841 "type" =>
"text/plain"
1843 if ($this->
isHTML($a_material))
1845 $attrs[
"type"] =
"text/xhtml";
1852 foreach (
$mobs as $mob)
1856 "label" =>
"il_" . IL_INST_ID .
"_mob_" . $mob,
1857 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
1859 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
1862 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
1873 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1898 array_push($a_array, $this->
getTitle());
1998 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
2002 $worksheet->write(
$row, 3, $eval_data[
"USERS_ANSWERED"]);
2003 $worksheet->write(
$row, 4, $eval_data[
"USERS_SKIPPED"]);
2006 $worksheet->write(
$row, 7, $eval_data[
"MODE_NR_OF_SELECTIONS"]);
2008 $worksheet->write(
$row, 9, $eval_data[
"ARITHMETIC_MEAN"]);
2026 array_push($csvrow, $this->
getTitle());
2028 array_push($csvrow, $this->lng->txt($eval_data[
"QUESTION_TYPE"]));
2029 array_push($csvrow, $eval_data[
"USERS_ANSWERED"]);
2030 array_push($csvrow, $eval_data[
"USERS_SKIPPED"]);
2031 array_push($csvrow, $eval_data[
"MODE"]);
2032 array_push($csvrow, $eval_data[
"MODE_NR_OF_SELECTIONS"]);
2033 array_push($csvrow, $eval_data[
"MEDIAN"]);
2034 array_push($csvrow, $eval_data[
"ARITHMETIC_MEAN"]);
2117 $this->original_id = $original_id;
2122 return $this->original_id;
2153 if (count($this->cumulated) == 0)
2155 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
2157 $this->cumulated =& $this->getCumulatedResults(
$survey_id, $nr_of_users);
2172 include_once
"./Services/Utilities/classes/class.ilStr.php";
2178 'counter' => $counter,
2181 'users_answered' =>
$cumulated[
'USERS_ANSWERED'],
2182 'users_skipped' =>
$cumulated[
'USERS_SKIPPED'],
2183 'question_type' => $this->lng->txt(
$cumulated[
"QUESTION_TYPE"]),
2185 'mode_nr_of_selections' =>
$cumulated[
"MODE_NR_OF_SELECTIONS"],
2187 'arithmetic_mean' =>
$cumulated[
"ARITHMETIC_MEAN"]