24 include_once
"./Services/Object/classes/class.ilObjectGUI.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
56 $lng->loadLanguageModule(
"survey");
58 $this->ctrl->saveParameter($this, array(
"ref_id",
"calling_survey",
"new_for_survey",
"pgov",
"pgov_pos"));
68 global $ilAccess, $ilNavigationHistory,
$ilErr;
70 if($this->ctrl->getCmd(
"questions") !=
"questions")
73 $rbac_ref_id =
$_REQUEST[
"calling_survey"];
76 $rbac_ref_id =
$_REQUEST[
"new_for_survey"];
91 $rbac_ref_id =
$_GET[
"ref_id"];
94 if (!$ilAccess->checkAccess(
"read",
"", $rbac_ref_id) &&
95 !$ilAccess->checkAccess(
"visible",
"", $rbac_ref_id))
98 $ilias->raiseError($this->lng->txt(
"permission_denied"), $ilias->error_obj->MESSAGE);
103 $ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"]))
105 $ilNavigationHistory->addItem(
$_GET[
"ref_id"],
106 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".
$_GET[
"ref_id"],
"spl");
111 $cmd = $this->ctrl->getCmd(
"questions");
112 $next_class = $this->ctrl->getNextClass($this);
113 $this->ctrl->setReturn($this,
"questions");
114 if (
$_GET[
"q_id"] < 1)
116 $q_type = (
$_POST[
"sel_question_types"] !=
"")
117 ?
$_POST[
"sel_question_types"]
118 :
$_GET[
"sel_question_types"];
122 case 'ilmdeditorgui':
123 if(!$ilAccess->checkAccess(
'write',
'',$this->object->getRefId()))
125 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->WARNING);
128 include_once
"./Services/MetaData/classes/class.ilMDEditorGUI.php";
129 $md_gui =&
new ilMDEditorGUI($this->object->getId(), 0, $this->
object->getType());
130 $md_gui->
addObserver($this->
object,
'MDUpdateListener',
'General');
132 $this->ctrl->forwardCommand($md_gui);
135 case 'ilpermissiongui':
136 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
138 $ret =& $this->ctrl->forwardCommand($perm_gui);
141 case "ilsurveyphrasesgui":
142 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
144 $ret =& $this->ctrl->forwardCommand($phrases_gui);
147 case 'ilobjectcopygui':
148 include_once
'./Services/Object/classes/class.ilObjectCopyGUI.php';
151 $this->ctrl->forwardCommand($cp);
154 case 'ilinfoscreengui':
158 case "ilcommonactiondispatchergui":
159 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
161 $this->ctrl->forwardCommand($gui);
170 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
172 $q_gui->object->setObjId($this->object->getId());
173 $q_gui->setQuestionTabs();
174 $ret =& $this->ctrl->forwardCommand($q_gui);
177 if (strtolower(
$_GET[
"baseClass"]) !=
"iladministrationgui" &&
189 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0)) ?
true :
false;
191 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
193 $form->setFormAction($this->ctrl->getFormAction($this,
'properties'));
194 $form->setTitle($this->lng->txt(
"properties"));
195 $form->setMultipart(
false);
196 $form->setId(
"properties");
200 $online->
setInfo($this->lng->txt(
"spl_online_property_description"));
201 $online->setChecked($this->object->getOnline());
202 $form->addItem($online);
204 $form->addCommandButton(
"saveProperties", $this->lng->txt(
"save"));
210 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
218 $qpl_online =
$_POST[
"online"];
219 if (strlen($qpl_online) == 0) $qpl_online =
"0";
220 $this->
object->setOnline($qpl_online);
221 $this->
object->saveToDb();
223 $this->ctrl->redirect($this,
"properties");
232 if (count(
$_POST[
"q_id"]) > 0)
234 foreach (
$_POST[
"q_id"] as $key => $value)
236 $this->
object->copyToClipboard($value);
244 $this->ctrl->redirect($this,
"questions");
252 if (count(
$_POST[
"q_id"]) > 0)
254 foreach (
$_POST[
"q_id"] as $key => $value)
256 $this->
object->moveToClipboard($value);
264 $this->ctrl->redirect($this,
"questions");
272 if (is_array(
$_POST[
'q_id']) && count(
$_POST[
'q_id']) > 0)
291 $checked_questions =
$_POST[
'q_id'];
292 if (count($checked_questions) > 0)
294 if (!$rbacsystem->checkAccess(
'write', $this->ref_id))
301 elseif (count($checked_questions) == 0)
308 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
310 $cgui->setHeaderText($this->lng->txt(
"qpl_confirm_delete_questions"));
312 $cgui->setFormAction($this->ctrl->getFormAction($this));
313 $cgui->setCancel($this->lng->txt(
"cancel"),
"cancelDeleteQuestions");
314 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmDeleteQuestions");
316 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
317 $infos = $this->
object->getQuestionInfos($checked_questions);
318 foreach ($infos as
$data)
320 $txt = $data[
"title"].
" (".
322 if($data[
"description"])
324 $txt .=
"<div class=\"small\">".$data[
"description"].
"</div>";
327 $cgui->addItem(
"q_id[]", $data[
"id"], $txt);
330 $this->tpl->setContent($cgui->getHTML());
340 foreach (
$_POST[
'q_id'] as $q_id)
342 $this->
object->removeQuestion($q_id);
344 $this->ctrl->redirect($this,
"questions");
353 $this->ctrl->redirect($this,
"questions");
361 if (array_key_exists(
"spl_clipboard",
$_SESSION))
363 $this->
object->pasteFromClipboard();
369 $this->ctrl->redirect($this,
"questions");
377 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_import_question.html",
"Modules/SurveyQuestionPool");
378 $this->tpl->setCurrentBlock(
"adm_content");
379 $this->tpl->setVariable(
"TEXT_IMPORT_QUESTION", $this->lng->txt(
"import_question"));
380 $this->tpl->setVariable(
"TEXT_SELECT_FILE", $this->lng->txt(
"select_file"));
381 $this->tpl->setVariable(
"TEXT_UPLOAD", $this->lng->txt(
"upload"));
382 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
383 $this->tpl->parseCurrentBlock();
392 $source = $_FILES[
"qtidoc"][
"tmp_name"];
394 if (($source ==
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK)
399 if (strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !== FALSE)
407 $this->
object->createImportDirectory();
410 $full_path = $this->
object->getImportDirectory().
"/".$_FILES[
"qtidoc"][
"name"];
412 include_once
"./Services/Utilities/classes/class.ilUtil.php";
414 $_FILES[
"qtidoc"][
"name"], $full_path);
415 $source = $full_path;
416 $this->
object->importObject($source, TRUE);
419 $this->ctrl->redirect($this,
"questions");
424 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
426 $table_gui->writeFilterToSession();
427 $this->ctrl->redirect($this,
'questions');
432 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
434 $table_gui->resetFilter();
435 $this->ctrl->redirect($this,
'questions');
447 if(get_class($this->
object) ==
"ilObjSurvey")
449 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
454 if (strlen(
$_GET[
"new_for_survey"]))
456 $addurl =
"&new_id=" .
$_GET[
"q_id"];
460 $addurl .=
"&pgov=".$_REQUEST[
"pgov"];
461 $addurl .=
"&pgov_pos=".$_REQUEST[
"pgov_pos"];
468 $this->
object->purgeQuestions();
472 if ($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']))
474 include_once
"Services/Form/classes/class.ilSelectInputGUI.php";
476 $qtypes->setValue($ilUser->getPref(
"svy_lastquestiontype"));
477 $ilToolbar->addInputItem($qtypes);
480 foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation =>
$data)
482 $options[
$data[
"type_tag"]] = $translation;
484 $qtypes->setOptions($options);
486 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
487 $ilToolbar->addFormButton($this->lng->txt(
"create"),
"createQuestion");
489 $ilToolbar->addSeparator();
491 $ilToolbar->addFormButton($this->lng->txt(
'import'),
'importQuestions');
494 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
496 $table_gui->
setEditable($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']));
497 $arrFilter = array();
498 foreach ($table_gui->getFilterItems() as $item)
500 if ($item->getValue() !==
false)
502 $arrFilter[$item->getPostVar()] = $item->getValue();
505 $table_gui->setData($this->object->getQuestionsData($arrFilter));
506 $this->tpl->setContent($table_gui->getHTML());
511 $this->update = $this->
object->update();
521 "&baseClass=ilObjSurveyQuestionPoolGUI");
531 $ilToolbar->addButton($this->lng->txt(
'create_export_file'),
532 $this->ctrl->getLinkTarget($this,
'createExportFile'));
534 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
536 $export_dir = $this->
object->getExportDirectory();
537 $export_files = $this->
object->getExportFiles($export_dir);
539 foreach ($export_files as $exp_file)
541 $file_arr = explode(
"__", $exp_file);
544 $table_gui->setData(
$data);
545 $this->tpl->setContent($table_gui->getHTML());
555 if ($rbacsystem->checkAccess(
"write", $this->ref_id))
557 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
559 $survey_exp->buildExportFile($questions);
560 $this->ctrl->redirect($this,
"export");
573 if(!isset(
$_POST[
"file"]))
576 $this->ctrl->redirect($this,
"export");
579 if (count(
$_POST[
"file"]) > 1)
582 $this->ctrl->redirect($this,
"export");
586 $export_dir = $this->
object->getExportDirectory();
587 include_once
"./Services/Utilities/classes/class.ilUtil.php";
599 if(!isset(
$_POST[
"file"]))
602 $this->ctrl->redirect($this,
"export");
606 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
608 $export_dir = $this->
object->getExportDirectory();
610 foreach (
$_POST[
'file'] as $exp_file)
612 $file_arr = explode(
"__", $exp_file);
615 $table_gui->setData(
$data);
616 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
626 $this->ctrl->redirect($this,
"export");
634 $export_dir = $this->
object->getExportDirectory();
637 $file = basename($file);
639 $exp_file = $export_dir.
"/".
$file;
640 $exp_dir = $export_dir.
"/".substr($file, 0, strlen($file) - 4);
641 if (@is_file($exp_file))
645 if (@is_dir($exp_dir))
647 include_once
"./Services/Utilities/classes/class.ilUtil.php";
651 $this->ctrl->redirect($this,
"export");
657 $form->getItemByPostVar(
'importfile')->setSuffixes(array(
"zip",
"xml"));
666 $forms = array(self::CFORM_NEW => $this->
initCreateForm($a_new_type),
667 self::CFORM_IMPORT => $form);
679 $parent_id =
$_GET[
"ref_id"];
685 $ilErr->raiseError($this->lng->txt(
"no_create_permission"));
688 $this->lng->loadLanguageModule($new_type);
689 $this->ctrl->setParameter($this,
"new_type", $new_type);
692 if ($form->checkInput())
694 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
696 $newObj->setType($new_type);
697 $newObj->setTitle(
"dummy");
698 $newObj->create(
true);
701 $newObj->createImportDirectory();
704 $upload = $_FILES[
"importfile"];
705 $file = pathinfo($upload[
"name"]);
706 $full_path = $newObj->getImportDirectory().
"/".$upload[
"name"];
707 include_once
"./Services/Utilities/classes/class.ilUtil.php";
712 $qtiresult = $newObj->importObject($full_path);
716 "&baseClass=ilObjSurveyQuestionPoolGUI");
720 $form->setValuesByPost();
721 $tpl->setContent($form->getHtml());
730 $ilUser->writePref(
"svy_lastquestiontype",
$_POST[
"sel_question_types"]);
731 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
733 $q_gui->object->setObjId($this->object->getId());
734 $q_gui->object->createNewQuestion();
735 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
736 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types",
$_POST[
"sel_question_types"]);
737 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
745 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
747 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
748 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id",
$_GET[
"q_id"]);
749 $this->ctrl->setParameterByClass(get_class($q_gui),
"pgov",
$_GET[
"pgov"]);
750 $this->ctrl->setParameterByClass(get_class($q_gui),
"pgov_pos",
$_GET[
"pgov_pos"]);
751 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
759 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
761 $q_gui->object->createNewQuestion();
762 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
763 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
764 $this->ctrl->setParameterByClass(get_class($q_gui),
"pgov",
$_GET[
"pgov"]);
765 $this->ctrl->setParameterByClass(get_class($q_gui),
"pgov_pos",
$_GET[
"pgov_pos"]);
766 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
774 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
776 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
777 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id",
$_GET[
"preview"]);
778 $this->ctrl->redirectByClass(get_class($q_gui),
"preview");
788 $this->ctrl->setCmd(
"showSummary");
789 $this->ctrl->setCmdClass(
"ilinfoscreengui");
800 if(!$ilAccess->checkAccess(
"visible",
"", $this->ref_id))
802 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_read"));
805 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
807 $info->enablePrivateNotes();
810 $info->addMetaDataSections($this->object->getId(), 0, $this->
object->getType());
812 $this->ctrl->forwardCommand($info);
818 switch ($this->ctrl->getCmd())
825 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$_GET[
"ref_id"]);
828 if (
$_GET[
"q_id"] > 0)
830 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
832 $this->ctrl->setParameterByClass($q_type,
"q_id",
$_GET[
"q_id"]);
844 global $ilAccess, $ilHelp;
846 $ilHelp->setScreenIdComponent(
"spl");
848 $next_class = $this->ctrl->getNextClass($this);
852 case "ilpermissiongui":
853 case "ilmdeditorgui":
854 case "ilsurveyphrasesgui":
860 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
return;
862 $force_active = (($this->ctrl->getCmdClass() ==
"" &&
863 $this->ctrl->getCmd() !=
"properties") ||
864 $this->ctrl->getCmd() ==
"")
869 if (is_array(
$_GET[
"sort"]))
871 $force_active =
true;
874 $tabs_gui->addTarget(
"survey_questions",
875 $this->ctrl->getLinkTarget($this,
'questions'),
876 array(
"questions",
"filterQuestionBrowser",
"filter",
"reset",
"createQuestion",
877 "importQuestions",
"deleteQuestions",
"copy",
"paste",
878 "exportQuestions",
"confirmDeleteQuestions",
"cancelDeleteQuestions",
879 "confirmPasteQuestions",
"cancelPasteQuestions",
"uploadQuestions",
880 "editQuestion",
"addMaterial",
"removeMaterial",
"save",
"cancel",
881 "cancelExplorer",
"linkChilds",
"addGIT",
"addST",
"addPG",
"preview",
882 "moveCategory",
"deleteCategory",
"addPhrase",
"addCategory",
"savePhrase",
883 "addSelectedPhrase",
"cancelViewPhrase",
"confirmSavePhrase",
"cancelSavePhrase",
884 "insertBeforeCategory",
"insertAfterCategory",
"confirmDeleteCategory",
885 "cancelDeleteCategory",
"categories",
"saveCategories",
886 "savePhrase",
"addPhrase"
888 array(
"ilobjsurveyquestionpoolgui",
"ilsurveyphrasesgui"),
"", $force_active);
890 if ($ilAccess->checkAccess(
"visible",
"", $this->ref_id))
892 $tabs_gui->addTarget(
"info_short",
893 $this->ctrl->getLinkTarget($this,
"infoScreen"),
894 array(
"infoScreen",
"showSummary"));
897 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id))
900 $tabs_gui->addTarget(
"settings",
901 $this->ctrl->getLinkTarget($this,
'properties'),
906 $tabs_gui->addTarget(
"manage_phrases",
907 $this->ctrl->getLinkTargetByClass(
"ilsurveyphrasesgui",
"phrases"),
908 array(
"phrases",
"deletePhrase",
"confirmDeletePhrase",
"cancelDeletePhrase",
"editPhrase",
"newPhrase",
"saveEditPhrase",
"phraseEditor"),
909 "ilsurveyphrasesgui",
"");
912 $tabs_gui->addTarget(
"meta_data",
913 $this->ctrl->getLinkTargetByClass(
'ilmdeditorgui',
'listSection'),
914 "",
"ilmdeditorgui");
917 $tabs_gui->addTarget(
"export",
918 $this->ctrl->getLinkTarget($this,
'export'),
919 array(
"export",
"createExportFile",
"confirmDeleteExportFile",
920 "downloadExportFile",
"cancelDeleteExportFile",
"deleteExportFile"),
924 if ($ilAccess->checkAccess(
"edit_permission",
"", $this->ref_id))
926 $tabs_gui->addTarget(
"perm_settings",
927 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm"), array(
"perm",
"info",
"owner"),
'ilpermissiongui');
936 $obligatory = array();
937 foreach (
$_POST as $key => $value)
939 if (preg_match(
"/obligatory_(\d+)/", $key, $matches))
941 $obligatory[]= $matches[1];
944 $this->
object->setObligatoryStates($obligatory);
947 $this->ctrl->redirect($this,
"questions");
956 public static function _goto($a_target)
960 if ($ilAccess->checkAccess(
"write",
"", $a_target))
962 $_GET[
"baseClass"] =
"ilObjSurveyQuestionPoolGUI";
963 $_GET[
"cmd"] =
"questions";
964 $_GET[
"ref_id"] = $a_target;
965 include_once(
"ilias.php");
968 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
974 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);