34 include_once
"./classes/class.ilObject.php";
35 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
55 $this->
ilObject($a_id,$a_call_by_reference);
79 if (!parent::update())
94 function read($a_force_db =
false)
113 foreach ($questions as $question_id)
115 $newObj->copyQuestion($question_id, $newObj->getId());
119 include_once
"./Services/MetaData/classes/class.ilMD.php";
121 $new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
124 $newObj->updateMetaData();
130 if ((!$question_type) and ($question_id > 0))
135 include_once
"./Modules/SurveyQuestionPool/classes/class.".$question_type.
"GUI.php";
136 $question_type_gui = $question_type .
"GUI";
137 $question =&
new $question_type_gui();
139 if ($question_id > 0)
141 $question->object->loadFromDb($question_id);
157 if ($question_gui->object->getObjId() == $questionpool_to)
165 $newtitle = $question_gui->object->getTitle();
166 if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to))
169 while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() .
" ($counter)", $questionpool_to))
173 $newtitle = $question_gui->object->getTitle() .
" ($counter)";
175 $question_gui->object->copyObject($this->
getId(), $newtitle);
188 $result = $ilDB->queryF(
"SELECT * FROM svy_qpl WHERE obj_fi = %s",
190 array($this->
getId())
208 $result = $ilDB->queryF(
"SELECT * FROM svy_qpl WHERE obj_fi = %s",
210 array($this->
getId())
214 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
215 array(
'text',
'integer',
'integer'),
221 $next_id = $ilDB->nextId(
'svy_qpl');
222 $query = $ilDB->manipulateF(
"INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
223 array(
'integer',
'text',
'integer',
'integer'),
256 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
258 array($this->
getId())
260 $found_questions = array();
267 include_once
"./Services/Utilities/classes/class.ilUtil.php";
269 $directory = $spl_data_dir.
"/spl_".$this->
getId();
270 if (is_dir($directory))
272 include_once
"./Services/Utilities/classes/class.ilUtil.php";
290 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
330 if ($a_node_id==
$_GET[
"ref_id"])
332 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
333 $parent_type = $parent_obj->getType();
334 if($parent_type == $this->
getType())
336 $a_node_id = (int) $tree->getParentId($a_node_id);
340 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
370 if ($question_id < 1)
return;
371 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
373 $question->delete($question_id);
386 if ($question_id < 1)
return;
387 $result = $ilDB->queryF(
"SELECT svy_qtype.type_tag FROM svy_question, svy_qtype WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.question_id = %s",
394 return $data[
"type_tag"];
413 $result = $ilDB->queryF(
"SELECT answer_id FROM svy_answer WHERE question_fi = %s",
417 $answered =
$result->numRows();
420 $result = $ilDB->queryF(
"SELECT svy_svy.* FROM svy_svy, svy_svy_qst WHERE svy_svy_qst.survey_fi = svy_svy.survey_id AND svy_svy_qst.question_fi = %s",
424 $inserted =
$result->numRows();
425 if (($inserted + $answered) == 0)
429 $result_array = array();
432 array_push($result_array,
$row);
434 return $result_array;
458 $result_array = array();
459 $result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin FROM svy_question, svy_qtype WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND " . $ilDB->in(
'svy_question.question_id', $question_array,
false,
'integer'));
466 array_push($result_array,
$row);
471 array_push($result_array,
$row);
474 return $result_array;
486 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
490 while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
493 if ($counter > 1) $suffix =
" ($counter)";
497 $question->setObjId($obj_id);
499 $question->duplicate(
false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
512 if (is_array($arrFilter))
514 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
516 $where .=
" AND " . $ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
518 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
520 $where .=
" AND " . $ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
522 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
524 $where .=
" AND " . $ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
526 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
528 $where .=
" AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
531 $query_result = $ilDB->queryF(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin FROM svy_question, svy_qtype WHERE svy_question.original_id IS NULL AND svy_question.tstamp > 0 AND svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.obj_fi = %s" . $where,
533 array($this->
getId())
536 if ($query_result->numRows())
538 while (
$row = $ilDB->fetchAssoc($query_result))
544 array_push($rows,
$row);
549 array_push($rows,
$row);
563 include_once
"./Services/Utilities/classes/class.ilUtil.php";
566 if(!is_writable($spl_data_dir))
568 $this->ilias->raiseError(
"Survey Questionpool Data Directory (".$spl_data_dir
569 .
") not writeable.",$this->ilias->error_obj->FATAL);
573 $spl_dir = $spl_data_dir.
"/spl_".$this->
getId();
575 if(!@is_dir($spl_dir))
577 $this->ilias->raiseError(
"Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
580 $export_dir = $spl_dir.
"/export";
582 if(!@is_dir($export_dir))
584 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
593 include_once
"./Services/Utilities/classes/class.ilUtil.php";
604 if (!@is_dir(
$dir) or
617 while ($entry =
$dir->read())
619 if ($entry !=
"." and
621 substr($entry, -4) ==
".xml" and
622 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(spl__)*[0-9]+\.xml\$", $entry))
644 include_once
"./Services/Utilities/classes/class.ilUtil.php";
648 if(!is_writable($spl_data_dir))
650 $this->ilias->raiseError(
"Survey Questionpool Data Directory (".$spl_data_dir
651 .
") not writeable.",$this->ilias->error_obj->FATAL);
655 $spl_dir = $spl_data_dir.
"/spl_".$this->
getId();
657 if(!@is_dir($spl_dir))
659 $this->ilias->raiseError(
"Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
663 $import_dir = $spl_dir.
"/import";
665 if(!@is_dir($import_dir))
667 $this->ilias->raiseError(
"Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
676 include_once
"./Services/Utilities/classes/class.ilUtil.php";
678 "/spl_".$this->getId().
"/import";
679 if(@is_dir($import_dir))
694 if (!is_array($questions))
698 if (count($questions) == 0)
704 include_once(
"./classes/class.ilXmlWriter.php");
709 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
710 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_3_8.xsd"
712 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
714 "id" =>
"qpl_" . $this->
getId(),
717 $a_xml_writer->xmlStartTag(
"surveyquestions", $attrs);
718 $a_xml_writer->xmlElement(
"dummy", NULL,
"dummy");
720 $a_xml_writer->xmlStartTag(
"metadata");
721 $a_xml_writer->xmlStartTag(
"metadatafield");
722 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"SCORM");
723 include_once
"./Services/MetaData/classes/class.ilMD.php";
727 $metadata = $writer->xmlDumpMem();
728 $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
729 $a_xml_writer->xmlEndTag(
"metadatafield");
730 $a_xml_writer->xmlEndTag(
"metadata");
732 $a_xml_writer->xmlEndTag(
"surveyquestions");
733 $a_xml_writer->xmlEndTag(
"surveyobject");
735 $xml = $a_xml_writer->xmlDumpMem(FALSE);
738 foreach ($questions as
$key => $value)
741 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
743 $question =
new $questiontype();
744 $question->loadFromDb($value);
745 $questionxml .= $question->toXML(
false);
748 $xml = str_replace(
"<dummy>dummy</dummy>", $questionxml, $xml);
755 $questions = array();
756 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
758 array($this->
getId())
764 array_push($questions,
$row[
"question_id"]);
778 if (is_file($source))
780 $fh = fopen($source,
"r") or die(
"");
781 $xml = fread($fh, filesize($source));
782 fclose($fh) or die(
"");
783 if (strpos($xml,
"questestinterop") > 0)
786 include_once
"./Services/Survey/classes/class.SurveyImportParserPre38.php";
788 $import->setXMLContent($xml);
789 $import->startParsing();
794 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
796 $import->setXMLContent($xml);
797 $import->startParsing();
811 switch ($a_online_status)
815 $this->online = $a_online_status;
825 if (strcmp($this->online,
"") == 0) $this->online =
"0";
833 $result = $ilDB->queryF(
"SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
840 return $row[
"isonline"];
859 foreach ($refs as $ref)
880 $lng->loadLanguageModule(
"survey");
882 $query_result = $ilDB->query(
"SELECT * FROM svy_qtype ORDER BY type_tag");
883 while (
$row = $ilDB->fetchAssoc($query_result))
886 if (
$row[
"plugin"] == 0)
888 $types[$lng->txt(
$row[
"type_tag"])] =
$row;
892 global $ilPluginAdmin;
893 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
894 foreach ($pl_names as $pl_name)
897 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
899 $types[$pl->getQuestionTypeTranslation()] =
$row;
913 global $ilPluginAdmin;
915 $lng->loadLanguageModule(
"survey");
916 $result = $ilDB->query(
"SELECT * FROM svy_qtype");
920 if (
$row[
"plugin"] == 0)
922 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
926 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
927 foreach ($pl_names as $pl_name)
930 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
932 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
952 $result_array = array();
956 $result = $ilDB->query(
"SELECT obj_fi, isonline FROM svy_qpl");
959 $allqpls[
$row[
'obj_fi']] = $row[
'isonline'];
964 if (($could_be_offline) || ($allqpls[$obj_id][
'isonline'] == 1))
968 $result_array[$obj_id] = $titles[
$ref_id];
976 return $result_array;
987 global $ilPluginAdmin;
988 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname))
1009 $query_result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
1010 "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1011 "AND svy_question.tstamp > 0 AND " . $ilDB->in(
'svy_question.question_id', $question_ids,
false,
'integer') .
" " .
1012 "ORDER BY svy_question.title");
1013 if ($query_result->numRows() > 0)
1015 while (
$data = $ilDB->fetchAssoc($query_result))
1017 if (in_array(
$data[
"question_id"], $question_ids))
1019 array_push($found, array(
'title' =>
$data[
"title"],
'description' =>
$data[
"description"],
'type_tag' =>
$data[
"type_tag"]));
1031 global
$ilDB, $ilUser;
1033 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
1034 array(
"integer",
"integer"),
1035 array($ilUser->getId(), 0)
1050 if (!array_key_exists(
"spl_clipboard",
$_SESSION))
1054 $_SESSION[
"spl_clipboard"][$question_id] = array(
"question_id" => $question_id,
"action" =>
"copy");
1064 if (!array_key_exists(
"spl_clipboard",
$_SESSION))
1068 $_SESSION[
"spl_clipboard"][$question_id] = array(
"question_id" => $question_id,
"action" =>
"move");
1078 if (array_key_exists(
"spl_clipboard",
$_SESSION))
1080 foreach (
$_SESSION[
"spl_clipboard"] as $question_object)
1082 if (strcmp($question_object[
"action"],
"move") == 0)
1084 $result = $ilDB->queryF(
"SELECT obj_fi FROM svy_question WHERE question_id = %s",
1086 array($question_object[
"question_id"])
1091 $source_questionpool =
$row[
"obj_fi"];
1092 if ($this->
getId() != $source_questionpool)
1095 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1096 array(
'integer',
'integer'),
1097 array($this->
getId(), $question_object[
"question_id"])
1101 $source_path = CLIENT_WEB_DIR .
"/survey/" . $source_questionpool .
"/" . $question_object[
"question_id"] .
"/";
1102 if (@is_dir($source_path))
1104 $target_path = CLIENT_WEB_DIR .
"/survey/" . $this->
getId() .
"/";
1105 if (!@is_dir($target_path))
1107 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1110 @rename($source_path, $target_path . $question_object[
"question_id"]);