34 include_once
"./Services/Object/classes/class.ilObject.php";
54 parent::__construct($a_id,$a_call_by_reference);
78 if (!parent::update())
103 function cloneObject($a_target_id,$a_copy_id = 0, $a_omit_tree =
false)
106 $newObj = parent::cloneObject($a_target_id,$a_copy_id, $a_omit_tree);
111 if(!$cp_options->isRootNode($this->getRefId()))
119 foreach ($questions as $question_id)
121 $newObj->copyQuestion($question_id, $newObj->getId());
125 include_once
"./Services/MetaData/classes/class.ilMD.php";
127 $new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
130 $newObj->updateMetaData();
136 if ((!$question_type)
and ($question_id > 0))
141 include_once
"./Modules/SurveyQuestionPool/classes/class.".$question_type.
"GUI.php";
142 $question_type_gui = $question_type .
"GUI";
143 $question =
new $question_type_gui();
145 if ($question_id > 0)
147 $question->object->loadFromDb($question_id);
163 if ($question_gui->object->getObjId() == $questionpool_to)
171 $newtitle = $question_gui->object->getTitle();
172 if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to))
175 while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() .
" ($counter)", $questionpool_to))
179 $newtitle = $question_gui->object->getTitle() .
" ($counter)";
181 $question_gui->object->copyObject($this->
getId(), $newtitle);
194 $result = $ilDB->queryF(
"SELECT * FROM svy_qpl WHERE obj_fi = %s",
216 $result = $ilDB->queryF(
"SELECT * FROM svy_qpl WHERE obj_fi = %s",
222 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
223 array(
'text',
'integer',
'integer'),
229 $next_id = $ilDB->nextId(
'svy_qpl');
230 $query = $ilDB->manipulateF(
"INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
231 array(
'integer',
'text',
'integer',
'integer'),
245 $remove = parent::delete();
264 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
268 $found_questions =
array();
276 $directory = $spl_data_dir.
"/spl_".$this->
getId();
277 if (is_dir($directory))
291 if ($question_id < 1)
return;
292 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
294 $question->delete($question_id);
307 if ($question_id < 1)
return;
308 $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",
315 return $data[
"type_tag"];
334 $result = $ilDB->queryF(
"SELECT answer_id FROM svy_answer WHERE question_fi = %s",
338 $answered =
$result->numRows();
341 $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",
345 $inserted =
$result->numRows();
346 if (($inserted + $answered) == 0)
350 $result_array =
array();
353 array_push($result_array,
$row);
355 return $result_array;
379 $result_array =
array();
380 $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'));
387 array_push($result_array,
$row);
392 array_push($result_array,
$row);
395 return $result_array;
407 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
411 while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
414 if (
$counter > 1) $suffix =
" ($counter)";
418 $question->setObjId($obj_id);
420 $question->duplicate(
false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
433 if (is_array($arrFilter))
435 foreach ($arrFilter as $key => $value)
437 $arrFilter[$key] = str_replace(
'%',
'', $arrFilter[$key]);
439 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
441 $where .=
" AND " . $ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
443 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
445 $where .=
" AND " . $ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
447 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
449 $where .=
" AND " . $ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
451 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
453 $where .=
" AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
456 $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,
461 if ($query_result->numRows())
463 while (
$row = $ilDB->fetchAssoc($query_result))
469 array_push($rows,
$row);
474 array_push($rows,
$row);
492 if(!is_writable($spl_data_dir))
494 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
495 throw new ilSurveyException(
"Survey Questionpool Data Directory (".$spl_data_dir.
") not writeable.");
499 $spl_dir = $spl_data_dir.
"/spl_".$this->
getId();
501 if(!@is_dir($spl_dir))
503 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
504 throw new ilSurveyException(
"Creation of Survey Questionpool Directory failed.");
507 $export_dir = $spl_dir.
"/export";
509 if(!@is_dir($export_dir))
511 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
512 throw new ilSurveyException(
"Creation of Survey Questionpool Export Directory failed.");
531 if (!@is_dir($dir)
or 544 while ($entry = $dir->read())
548 preg_match(
"/^[0-9]{10}__[0-9]+__(spl_)*[0-9]+\.[A-Za-z]{3}$/", $entry))
575 if(!is_writable($spl_data_dir))
577 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
578 throw new ilSurveyException(
"Survey Questionpool Data Directory (".$spl_data_dir.
") not writeable.");
582 $spl_dir = $spl_data_dir.
"/spl_".$this->
getId();
584 if(!@is_dir($spl_dir))
586 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
587 throw new ilSurveyException(
"Creation of Survey Questionpool Directory failed.");
591 $import_dir = $spl_dir.
"/import";
593 if(!@is_dir($import_dir))
595 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
596 throw new ilSurveyException(
"Creation of Survey Questionpool Import Directory failed.");
606 "/spl_".$this->getId().
"/import";
607 if(@is_dir($import_dir))
622 if (!is_array($questions))
626 if (count($questions) == 0)
632 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
637 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
638 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd" 640 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
642 "id" =>
"qpl_" . $this->
getId(),
646 $a_xml_writer->xmlStartTag(
"surveyquestions", $attrs);
647 $a_xml_writer->xmlElement(
"dummy", NULL,
"dummy");
649 $a_xml_writer->xmlStartTag(
"metadata");
650 $a_xml_writer->xmlStartTag(
"metadatafield");
651 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"SCORM");
652 include_once
"./Services/MetaData/classes/class.ilMD.php";
656 $metadata = $writer->xmlDumpMem();
657 $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
658 $a_xml_writer->xmlEndTag(
"metadatafield");
659 $a_xml_writer->xmlEndTag(
"metadata");
661 $a_xml_writer->xmlEndTag(
"surveyquestions");
662 $a_xml_writer->xmlEndTag(
"surveyobject");
664 $xml = $a_xml_writer->xmlDumpMem(FALSE);
667 foreach ($questions as $key => $value)
670 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
672 $question =
new $questiontype();
673 $question->loadFromDb($value);
674 $questionxml .= $question->toXML(
false);
677 $xml = str_replace(
"<dummy>dummy</dummy>", $questionxml, $xml);
684 $questions =
array();
685 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
693 array_push($questions,
$row[
"question_id"]);
707 if (is_file($source))
709 $isZip = (strcmp(strtolower(substr($source, -3)),
'zip') == 0);
716 $subdir = basename($source,
".zip");
717 $source = dirname($source).
"/".$subdir.
"/".$subdir.
".xml";
720 $fh = fopen($source,
"r")
or die(
"");
721 $xml = fread(
$fh, filesize($source));
722 fclose(
$fh)
or die(
"");
725 $subdir = basename($source,
".zip");
726 if (@is_dir(dirname($source).
"/".$subdir))
731 if (strpos($xml,
"questestinterop") > 0)
733 include_once(
"./Modules/Survey/exceptions/class.ilInvalidSurveyImportFileException.php");
746 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
748 $import->setXMLContent($xml);
749 $import->startParsing();
754 public static function _setOnline($a_obj_id, $a_online_status)
759 switch ($a_online_status)
763 $status =
"$a_online_status";
766 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
767 array(
'text',
'integer'),
768 array($status, $a_obj_id)
781 switch ($a_online_status)
785 $this->online = $a_online_status;
795 if (strcmp($this->online,
"") == 0) $this->online =
"0";
803 $result = $ilDB->queryF(
"SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
810 return $row[
"isonline"];
829 foreach ($refs as $ref)
850 $lng->loadLanguageModule(
"survey");
852 $query_result = $ilDB->query(
"SELECT * FROM svy_qtype ORDER BY type_tag");
853 while (
$row = $ilDB->fetchAssoc($query_result))
856 if (
$row[
"plugin"] == 0)
858 $types[$lng->txt(
$row[
"type_tag"])] =
$row;
862 global $ilPluginAdmin;
863 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
864 foreach ($pl_names as $pl_name)
867 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
869 $types[$pl->getQuestionTypeTranslation()] =
$row;
879 $default_sorting = array_flip(
array(
880 "SurveySingleChoiceQuestion",
881 "SurveyMultipleChoiceQuestion",
882 "SurveyMatrixQuestion",
883 "SurveyMetricQuestion",
888 $idx =
sizeof($default_sorting);
889 foreach($types as $caption => $item)
891 $type = $item[
"type_tag"];
892 $item[
"caption"] = $caption;
895 if(array_key_exists(
$type, $default_sorting))
897 $sorted[$default_sorting[
$type]] = $item;
902 $sorted[$idx] = $item;
910 foreach($sorted as $item)
912 $types[$item[
"caption"]] = $item;
923 global $ilPluginAdmin;
925 $lng->loadLanguageModule(
"survey");
926 $result = $ilDB->query(
"SELECT * FROM svy_qtype");
930 if (
$row[
"plugin"] == 0)
932 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
936 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq");
937 foreach ($pl_names as $pl_name)
940 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
942 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
962 $result_array =
array();
966 $result = $ilDB->query(
"SELECT obj_fi, isonline FROM svy_qpl");
969 $allqpls[
$row[
'obj_fi']] = $row[
'isonline'];
974 if ($could_be_offline || $allqpls[$obj_id] == 1)
978 $result_array[$obj_id] = $titles[
$ref_id];
986 return $result_array;
997 global $ilPluginAdmin;
998 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname))
1019 $query_result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
1020 "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1021 "AND svy_question.tstamp > 0 AND " . $ilDB->in(
'svy_question.question_id', $question_ids,
false,
'integer') .
" " .
1022 "ORDER BY svy_question.title");
1023 if ($query_result->numRows() > 0)
1025 while (
$data = $ilDB->fetchAssoc($query_result))
1027 if (in_array(
$data[
"question_id"], $question_ids))
1029 array_push($found,
array(
'id' =>
$data[
"question_id"],
1030 'title' =>
$data[
"title"],
1031 'description' =>
$data[
"description"],
1032 'type_tag' =>
$data[
"type_tag"]));
1046 $result = $ilDB->queryF(
"SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
1047 array(
"integer",
"integer"),
1048 array($ilUser->getId(), 0)
1063 if (!array_key_exists(
"spl_clipboard",
$_SESSION))
1067 $_SESSION[
"spl_clipboard"][$question_id] =
array(
"question_id" => $question_id,
"action" =>
"copy");
1077 if (!array_key_exists(
"spl_clipboard",
$_SESSION))
1081 $_SESSION[
"spl_clipboard"][$question_id] =
array(
"question_id" => $question_id,
"action" =>
"move");
1091 if (array_key_exists(
"spl_clipboard",
$_SESSION))
1093 foreach (
$_SESSION[
"spl_clipboard"] as $question_object)
1095 if (strcmp($question_object[
"action"],
"move") == 0)
1097 $result = $ilDB->queryF(
"SELECT obj_fi FROM svy_question WHERE question_id = %s",
1099 array($question_object[
"question_id"])
1104 $source_questionpool =
$row[
"obj_fi"];
1105 if ($this->
getId() != $source_questionpool)
1108 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1109 array(
'integer',
'integer'),
1110 array($this->
getId(), $question_object[
"question_id"])
1114 $source_path = CLIENT_WEB_DIR .
"/survey/" . $source_questionpool .
"/" . $question_object[
"question_id"] .
"/";
1115 if (@is_dir($source_path))
1117 $target_path = CLIENT_WEB_DIR .
"/survey/" . $this->
getId() .
"/";
1118 if (!@is_dir($target_path))
1122 @rename($source_path, $target_path . $question_object[
"question_id"]);
1154 $status = (int)(in_array($question_id, $obligatory_questions));
1156 $ilDB->manipulate(
"UPDATE svy_question".
1157 " SET obligatory = ".$ilDB->quote($status,
"integer").
1158 " WHERE question_id = ".$ilDB->quote($question_id,
"integer"));
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupOnline($a_obj_id)
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
isInUse($question_id)
Checks if a question is in use by a survey.
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _prepareCloneSelection($a_ref_ids, $new_type, $show_path=true)
Prepare copy wizard object selection.
getQuestionInfos($question_ids)
Returns title, description and type for an array of question id's.
updateMetaData()
update meta data entry
Class ilObject Basic functions for all objects.
getQuestiontype($question_id)
Returns the question type of a question with a given id.
createImportDirectory()
creates data directory for import files (data_dir/spl_data/spl_<id>/import, depending on data directo...
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.
getExportDirectory()
get export directory of survey
copyQuestion($question_id, $questionpool_to)
Copies a question into another question pool.
createMetaData()
create meta data entry
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
update()
update object data
getImportDirectory()
get import directory of survey
Survey Question Import Parser.
static _getAvailableQuestionpools($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
Returns the available question pools for the active user.
static _getQuestionTypeTranslations()
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
create($a_upload=false)
create question pool object
static _getAllReferences($a_id)
get all reference ids of object
read()
read object data from db into object public
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
static _lookupObjectId($a_ref_id)
lookup object id
setOnline($a_online_status)
Sets the questionpool online status.
getQuestionsData($arrFilter)
Calculates the data for the output of the questionpool.
duplicateQuestion($question_id, $obj_id="")
Duplicates a question for a questionpool.
importObject($source, $spl_exists=FALSE)
Imports survey questions into ILIAS.
static _setOnline($a_obj_id, $a_online_status)
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getId()
get object id public
setObligatoryStates($obligatory_questions)
Sets the obligatory states for questions in a survey from the questions form.
moveToClipboard($question_id)
Moves a question to the clipboard.
paste($question_id)
Pastes a question in the question pool.
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Creates a 1:1 copy of the object and places the copy in a given repository.
getTitle()
get object title public
xmlHeader()
Writes xml header public.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
getType()
get object type public
Create styles array
The data for the language used.
toXML($questions)
export questions to xml
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
pasteFromClipboard()
Copies/Moves a question from the clipboard.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
removeQuestion($question_id)
Removes a question from the question pool.
copyToClipboard($question_id)
Copies a question to the clipboard.
static getDataDir()
get data directory (outside webspace)
saveToDb()
Saves a ilObjSurveyQuestionPool object to a database.
& getQuestionsInfo($question_array)
Retrieves the datase entries for questions from a given array.
static _getQuestiontypes()
Creates a list of all available question types.
getExportFiles($dir)
get export files
deleteMetaData()
delete meta data entry
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Class ilInvalidSurveyImportFileException.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
createExportDirectory()
creates data directory for export files (data_dir/spl_data/spl_<id>/export, depending on data directo...
& createQuestion($question_type, $question_id=-1)
loadFromDb()
Loads a ilObjQuestionpool object from a database.