24 include_once
"./classes/class.ilObjectGUI.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
55 $lng->loadLanguageModule(
"survey");
57 $this->ctrl->saveParameter($this, array(
"ref_id",
"calling_survey",
"new_for_survey"));
67 global $ilAccess, $ilNavigationHistory;
69 if ((!$ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"])) && (!$ilAccess->checkAccess(
"visible",
"",
$_GET[
"ref_id"])))
72 $ilias->raiseError($this->lng->txt(
"permission_denied"), $ilias->error_obj->MESSAGE);
76 $ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"]))
78 $ilNavigationHistory->addItem(
$_GET[
"ref_id"],
79 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".
$_GET[
"ref_id"],
"spl");
84 $cmd = $this->ctrl->getCmd(
"questions");
85 $next_class = $this->ctrl->getNextClass($this);
86 $this->ctrl->setReturn($this,
"questions");
87 if (
$_GET[
"q_id"] < 1)
89 $q_type = (
$_POST[
"sel_question_types"] !=
"")
90 ?
$_POST[
"sel_question_types"]
91 :
$_GET[
"sel_question_types"];
96 include_once
"./Services/MetaData/classes/class.ilMDEditorGUI.php";
97 $md_gui =&
new ilMDEditorGUI($this->object->getId(), 0, $this->
object->getType());
98 $md_gui->
addObserver($this->
object,
'MDUpdateListener',
'General');
100 $this->ctrl->forwardCommand($md_gui);
103 case 'ilpermissiongui':
104 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
106 $ret =& $this->ctrl->forwardCommand($perm_gui);
109 case "ilsurveyphrasesgui":
110 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
112 $ret =& $this->ctrl->forwardCommand($phrases_gui);
115 case 'ilobjectcopygui':
116 include_once
'./Services/Object/classes/class.ilObjectCopyGUI.php';
119 $this->ctrl->forwardCommand($cp);
128 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
130 $q_gui->object->setObjId($this->object->getId());
131 $q_gui->setQuestionTabs();
132 $ret =& $this->ctrl->forwardCommand($q_gui);
135 if (strtolower(
$_GET[
"baseClass"]) !=
"iladministrationgui" &&
158 if (!strlen(
$_POST[
'Fobject'][
'title']))
161 $this->ctrl->setParameter($this,
'new_type',
$_GET[
'new_type']);
162 $this->ctrl->redirect($this,
'create');
172 "&baseClass=ilObjSurveyQuestionPoolGUI");
180 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0)) ?
true :
false;
182 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
184 $form->setFormAction($this->ctrl->getFormAction($this,
'properties'));
185 $form->setTitle($this->lng->txt(
"properties"));
186 $form->setMultipart(
false);
187 $form->setId(
"properties");
191 $online->
setInfo($this->lng->txt(
"spl_online_property_description"));
192 $online->setChecked($this->object->getOnline());
193 $form->addItem($online);
195 $form->addCommandButton(
"saveProperties", $this->lng->txt(
"save"));
201 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
209 $qpl_online =
$_POST[
"online"];
210 if (strlen($qpl_online) == 0) $qpl_online =
"0";
211 $this->
object->setOnline($qpl_online);
212 $this->
object->saveToDb();
214 $this->ctrl->redirect($this,
"properties");
223 if (count(
$_POST[
"q_id"]) > 0)
225 foreach (
$_POST[
"q_id"] as $key => $value)
227 $this->
object->copyToClipboard($value);
235 $this->ctrl->redirect($this,
"questions");
243 if (count(
$_POST[
"q_id"]) > 0)
245 foreach (
$_POST[
"q_id"] as $key => $value)
247 $this->
object->moveToClipboard($value);
255 $this->ctrl->redirect($this,
"questions");
263 if (is_array(
$_POST[
'q_id']) && count(
$_POST[
'q_id']) > 0)
283 $checked_questions =
$_POST[
'q_id'];
284 if (count($checked_questions) > 0)
286 if ($rbacsystem->checkAccess(
'write', $this->ref_id))
297 elseif (count($checked_questions) == 0)
303 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_confirm_delete_questions.html",
"Modules/SurveyQuestionPool");
304 $infos = $this->
object->getQuestionInfos($checked_questions);
305 $colors = array(
"tblrow1",
"tblrow2");
307 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
308 foreach ($infos as
$data)
310 $this->tpl->setCurrentBlock(
"row");
311 $this->tpl->setVariable(
"COLOR_CLASS", $colors[$counter % 2]);
312 $this->tpl->setVariable(
"TXT_TITLE", $data[
"title"]);
313 $this->tpl->setVariable(
"TXT_DESCRIPTION", $data[
"description"]);
315 $this->tpl->parseCurrentBlock();
318 foreach ($checked_questions as $id)
320 $this->tpl->setCurrentBlock(
"hidden");
321 $this->tpl->setVariable(
"HIDDEN_NAME",
"q_id[]");
322 $this->tpl->setVariable(
"HIDDEN_VALUE", $id);
323 $this->tpl->parseCurrentBlock();
326 $this->tpl->setCurrentBlock(
"adm_content");
327 $this->tpl->setVariable(
"TXT_TITLE", $this->lng->txt(
"title"));
328 $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->lng->txt(
"description"));
329 $this->tpl->setVariable(
"TXT_TYPE", $this->lng->txt(
"question_type"));
330 $this->tpl->setVariable(
"BTN_CONFIRM", $this->lng->txt(
"confirm"));
331 $this->tpl->setVariable(
"BTN_CANCEL", $this->lng->txt(
"cancel"));
332 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
333 $this->tpl->parseCurrentBlock();
343 foreach (
$_POST[
'q_id'] as $q_id)
345 $this->
object->removeQuestion($q_id);
347 $this->ctrl->redirect($this,
"questions");
356 $this->ctrl->redirect($this,
"questions");
364 if (array_key_exists(
"spl_clipboard",
$_SESSION))
366 $this->
object->pasteFromClipboard();
372 $this->ctrl->redirect($this,
"questions");
380 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_import_question.html",
"Modules/SurveyQuestionPool");
381 $this->tpl->setCurrentBlock(
"adm_content");
382 $this->tpl->setVariable(
"TEXT_IMPORT_QUESTION", $this->lng->txt(
"import_question"));
383 $this->tpl->setVariable(
"TEXT_SELECT_FILE", $this->lng->txt(
"select_file"));
384 $this->tpl->setVariable(
"TEXT_UPLOAD", $this->lng->txt(
"upload"));
385 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
386 $this->tpl->parseCurrentBlock();
395 $source = $_FILES[
"qtidoc"][
"tmp_name"];
397 if (($source ==
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK)
402 if (strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !== FALSE)
410 $this->
object->createImportDirectory();
413 $full_path = $this->
object->getImportDirectory().
"/".$_FILES[
"qtidoc"][
"name"];
415 include_once
"./Services/Utilities/classes/class.ilUtil.php";
417 $_FILES[
"qtidoc"][
"name"], $full_path);
418 $source = $full_path;
419 $this->
object->importObject($source, TRUE);
422 $this->ctrl->redirect($this,
"questions");
427 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
429 $table_gui->writeFilterToSession();
430 $this->ctrl->redirect($this,
'questions');
435 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
437 $table_gui->resetFilter();
438 $this->ctrl->redirect($this,
'questions');
449 $this->
object->purgeQuestions();
452 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_questionbrowser.html",
"Modules/SurveyQuestionPool");
453 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
455 $table_gui->
setEditable($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']));
456 $arrFilter = array();
457 foreach ($table_gui->getFilterItems() as $item)
459 if ($item->getValue() !==
false)
461 $arrFilter[$item->getPostVar()] = $item->getValue();
464 $data = $this->
object->getQuestionsData($arrFilter);
465 $table_gui->setData(
$data);
466 $this->tpl->setVariable(
'TABLE', $table_gui->getHTML());
468 if ($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']))
470 $this->tpl->setCurrentBlock(
"QTypes");
471 $types =& ilObjSurveyQuestionPool::_getQuestionTypes();
472 $lastquestiontype = $ilUser->getPref(
"svy_lastquestiontype");
473 foreach ($types as $translation =>
$data)
475 if (
$data[
"type_tag"] == $lastquestiontype)
477 $this->tpl->setVariable(
"QUESTION_TYPE_SELECTED",
" selected=\"selected\"");
479 $this->tpl->setVariable(
"QUESTION_TYPE_ID",
$data[
"type_tag"]);
480 $this->tpl->setVariable(
"QUESTION_TYPE", $translation);
481 $this->tpl->parseCurrentBlock();
483 $this->tpl->setVariable(
"QUESTION_ADD", $this->lng->txt(
"create"));
484 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
'questions'));
485 $this->tpl->parseCurrentBlock();
491 $this->update = $this->
object->update();
500 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
502 $export_dir = $this->
object->getExportDirectory();
503 $export_files = $this->
object->getExportFiles($export_dir);
505 foreach ($export_files as $exp_file)
507 $file_arr = explode(
"__", $exp_file);
510 $table_gui->setData(
$data);
511 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
521 if ($rbacsystem->checkAccess(
"write", $this->ref_id))
523 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
525 $survey_exp->buildExportFile($questions);
526 $this->ctrl->redirect($this,
"export");
539 if(!isset(
$_POST[
"file"]))
542 $this->ctrl->redirect($this,
"export");
545 if (count(
$_POST[
"file"]) > 1)
548 $this->ctrl->redirect($this,
"export");
552 $export_dir = $this->
object->getExportDirectory();
553 include_once
"./Services/Utilities/classes/class.ilUtil.php";
563 if(!isset(
$_POST[
"file"]))
566 $this->ctrl->redirect($this,
"export");
570 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
572 $export_dir = $this->
object->getExportDirectory();
574 foreach (
$_POST[
'file'] as $exp_file)
576 $file_arr = explode(
"__", $exp_file);
579 $table_gui->setData(
$data);
580 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
589 session_unregister(
"ilExportFiles");
590 $this->ctrl->redirect($this,
"export");
598 $export_dir = $this->
object->getExportDirectory();
601 $exp_file = $export_dir.
"/".
$file;
602 $exp_dir = $export_dir.
"/".substr($file, 0, strlen($file) - 4);
603 if (@is_file($exp_file))
607 if (@is_dir($exp_dir))
609 include_once
"./Services/Utilities/classes/class.ilUtil.php";
613 $this->ctrl->redirect($this,
"export");
624 if (!$rbacsystem->checkAccess(
"create",
$_GET[
"ref_id"]))
626 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
629 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
630 $this->tpl->setVariable(
"BTN_NAME",
"uploadSpl");
631 $this->tpl->setVariable(
"TXT_UPLOAD", $this->lng->txt(
"upload"));
632 $this->tpl->setVariable(
"TXT_IMPORT_SPL", $this->lng->txt(
"import_spl"));
633 $this->tpl->setVariable(
"TXT_SELECT_MODE", $this->lng->txt(
"select_mode"));
634 $this->tpl->setVariable(
"TXT_SELECT_FILE", $this->lng->txt(
"select_file"));
642 if ($_FILES[
"xmldoc"][
"error"] > UPLOAD_ERR_OK)
648 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
652 $newObj->setType(
$_GET[
"new_type"]);
654 $newObj->setTitle(
"dummy");
656 $newObj->create(
true);
658 $newObj->createReference();
660 $newObj->putInTree(
$_GET[
"ref_id"]);
662 $newObj->setPermissions(
$_GET[
"ref_id"]);
664 $newObj->notify(
"new",
$_GET[
"ref_id"],
$_GET[
"parent_non_rbac_id"],
$_GET[
"ref_id"],$newObj->getRefId());
667 $newObj->createImportDirectory();
670 $file = pathinfo($_FILES[
"xmldoc"][
"name"]);
671 $full_path = $newObj->getImportDirectory().
"/".$_FILES[
"xmldoc"][
"name"];
672 include_once
"./Services/Utilities/classes/class.ilUtil.php";
674 $_FILES[
"xmldoc"][
"name"], $full_path);
677 $qtiresult = $newObj->importObject($full_path);
681 $this->ctrl->redirect($this,
"cancel");
683 return $newObj->getRefId();
693 if (!$rbacsystem->checkAccess(
"create",
$_GET[
"ref_id"], $new_type))
695 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
701 include_once(
"./Modules/Survey/classes/class.ilObjSurvey.php");
703 $this->tpl->setCurrentBlock(
"adm_content");
707 $data[
"fields"] = array();
708 include_once
"./Services/Utilities/classes/class.ilUtil.php";
712 foreach (
$data[
"fields"] as $key => $val)
714 $this->tpl->setVariable(
"TXT_".strtoupper($key), $this->lng->txt($key));
715 $this->tpl->setVariable(strtoupper($key), $val);
717 if ($this->prepare_output)
719 $this->tpl->parseCurrentBlock();
723 $this->ctrl->setParameter($this,
"new_type", $this->type);
724 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
725 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($new_type.
"_new"));
726 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
727 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt($new_type.
"_add"));
728 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
729 $this->tpl->setVariable(
"TARGET",
' target="'.
731 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
733 $this->tpl->setVariable(
"TXT_IMPORT_SPL", $this->lng->txt(
"import_spl"));
734 $this->tpl->setVariable(
"TXT_SPL_FILE", $this->lng->txt(
"spl_upload_file"));
735 $this->tpl->setVariable(
"NEW_TYPE", $this->type);
736 $this->tpl->setVariable(
"TXT_IMPORT", $this->lng->txt(
"import"));
739 $this->tpl->setVariable(
"ALT_IMG",$this->lng->txt(
"obj_spl"));
741 $this->tpl->setVariable(
"ALT_IMG2",$this->lng->txt(
"obj_spl"));
743 $this->tpl->parseCurrentBlock();
752 if (strcmp($_FILES[
"xmldoc"][
"tmp_name"],
"") == 0)
758 $this->ctrl->setParameter($this,
"new_type", $this->type);
764 "&baseClass=ilObjSurveyQuestionPoolGUI");
773 $ilUser->writePref(
"svy_lastquestiontype",
$_POST[
"sel_question_types"]);
774 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
776 $q_gui->object->setObjId($this->object->getId());
777 $q_gui->object->createNewQuestion();
778 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
779 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types",
$_POST[
"sel_question_types"]);
780 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
788 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
790 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
791 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id",
$_GET[
"q_id"]);
792 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
800 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
802 $q_gui->object->createNewQuestion();
803 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
804 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
805 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
813 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
815 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
816 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id",
$_GET[
"preview"]);
817 $this->ctrl->redirectByClass(get_class($q_gui),
"preview");
823 switch ($this->ctrl->getCmd())
830 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$_GET[
"ref_id"]);
833 if (
$_GET[
"q_id"] > 0)
835 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
837 $this->ctrl->setParameterByClass($q_type,
"q_id",
$_GET[
"q_id"]);
851 $next_class = $this->ctrl->getNextClass($this);
855 case "ilpermissiongui":
856 case "ilmdeditorgui":
857 case "ilsurveyphrasesgui":
863 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
return;
865 $force_active = ($this->ctrl->getCmdClass() ==
"" ||
866 $this->ctrl->getCmd() ==
"")
871 if (is_array(
$_GET[
"sort"]))
873 $force_active =
true;
876 $tabs_gui->addTarget(
"survey_questions",
877 $this->ctrl->getLinkTarget($this,
'questions'),
878 array(
"questions",
"filterQuestionBrowser",
"filter",
"reset",
"createQuestion",
879 "importQuestions",
"deleteQuestions",
"copy",
"paste",
880 "exportQuestions",
"confirmDeleteQuestions",
"cancelDeleteQuestions",
881 "confirmPasteQuestions",
"cancelPasteQuestions",
"uploadQuestions",
882 "editQuestion",
"addMaterial",
"removeMaterial",
"save",
"cancel",
883 "cancelExplorer",
"linkChilds",
"addGIT",
"addST",
"addPG",
"preview",
884 "moveCategory",
"deleteCategory",
"addPhrase",
"addCategory",
"savePhrase",
885 "addSelectedPhrase",
"cancelViewPhrase",
"confirmSavePhrase",
"cancelSavePhrase",
886 "insertBeforeCategory",
"insertAfterCategory",
"confirmDeleteCategory",
887 "cancelDeleteCategory",
"categories",
"saveCategories",
888 "savePhrase",
"addPhrase"
890 array(
"ilobjsurveyquestionpoolgui",
"ilsurveyphrasesgui"),
"", $force_active);
892 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id))
895 $tabs_gui->addTarget(
"settings",
896 $this->ctrl->getLinkTarget($this,
'properties'),
901 $tabs_gui->addTarget(
"manage_phrases",
902 $this->ctrl->getLinkTargetByClass(
"ilsurveyphrasesgui",
"phrases"),
903 array(
"phrases",
"deletePhrase",
"confirmDeletePhrase",
"cancelDeletePhrase",
"editPhrase",
"newPhrase",
"saveEditPhrase",
"phraseEditor"),
904 "ilsurveyphrasesgui",
"");
907 $tabs_gui->addTarget(
"meta_data",
908 $this->ctrl->getLinkTargetByClass(
'ilmdeditorgui',
'listSection'),
909 "",
"ilmdeditorgui");
912 $tabs_gui->addTarget(
"export",
913 $this->ctrl->getLinkTarget($this,
'export'),
914 array(
"export",
"createExportFile",
"confirmDeleteExportFile",
915 "downloadExportFile",
"cancelDeleteExportFile",
"deleteExportFile"),
919 if ($ilAccess->checkAccess(
"edit_permission",
"", $this->ref_id))
921 $tabs_gui->addTarget(
"perm_settings",
922 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm"), array(
"perm",
"info",
"owner"),
'ilpermissiongui');
932 public static function _goto($a_target)
935 if ($ilAccess->checkAccess(
"write",
"", $a_target))
937 $_GET[
"baseClass"] =
"ilObjSurveyQuestionPoolGUI";
938 $_GET[
"cmd"] =
"questions";
939 $_GET[
"ref_id"] = $a_target;
940 include_once(
"ilias.php");
943 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
945 $_GET[
"cmd"] =
"frameset";
946 $_GET[
"target"] =
"";
947 $_GET[
"ref_id"] = ROOT_FOLDER_ID;
950 include(
"repository.php");
953 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);