24 include_once
"./Services/Object/classes/class.ilObjectGUI.php";
55 $lng->loadLanguageModule(
"survey");
57 $this->ctrl->saveParameter($this, array(
"ref_id"));
67 global $ilAccess, $ilNavigationHistory,
$ilErr;
69 if (!$ilAccess->checkAccess(
"read",
"", $this->ref_id) &&
70 !$ilAccess->checkAccess(
"visible",
"", $this->ref_id))
73 $ilias->raiseError($this->lng->txt(
"permission_denied"), $ilias->error_obj->MESSAGE);
78 $ilAccess->checkAccess(
"read",
"", $this->ref_id))
80 $ilNavigationHistory->addItem($this->ref_id,
81 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$this->ref_id,
"spl");
87 $cmd = $this->ctrl->getCmd(
"questions");
88 $next_class = $this->ctrl->getNextClass($this);
89 $this->ctrl->setReturn($this,
"questions");
90 if (
$_GET[
"q_id"] < 1)
92 $q_type = (
$_POST[
"sel_question_types"] !=
"")
93 ?
$_POST[
"sel_question_types"]
94 :
$_GET[
"sel_question_types"];
99 if(!$ilAccess->checkAccess(
'write',
'',$this->object->getRefId()))
101 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->WARNING);
104 include_once
"./Services/MetaData/classes/class.ilMDEditorGUI.php";
105 $md_gui =&
new ilMDEditorGUI($this->object->getId(), 0, $this->
object->getType());
106 $md_gui->
addObserver($this->
object,
'MDUpdateListener',
'General');
108 $this->ctrl->forwardCommand($md_gui);
111 case 'ilpermissiongui':
112 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
114 $ret =& $this->ctrl->forwardCommand($perm_gui);
117 case "ilsurveyphrasesgui":
118 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
120 $ret =& $this->ctrl->forwardCommand($phrases_gui);
123 case 'ilobjectcopygui':
124 include_once
'./Services/Object/classes/class.ilObjectCopyGUI.php';
127 $this->ctrl->forwardCommand($cp);
130 case 'ilinfoscreengui':
134 case "ilcommonactiondispatchergui":
135 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
137 $this->ctrl->forwardCommand($gui);
146 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
149 $q_gui->setQuestionTabs();
150 $ret =& $this->ctrl->forwardCommand($q_gui);
153 if($q_gui->object->isComplete())
155 $this->tpl->setTitle($this->lng->txt(
"question").
": ".$q_gui->object->getTitle());
159 if (strtolower(
$_GET[
"baseClass"]) !=
"iladministrationgui" &&
171 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0)) ?
true :
false;
173 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
175 $form->setFormAction($this->ctrl->getFormAction($this,
'properties'));
176 $form->setTitle($this->lng->txt(
"properties"));
177 $form->setMultipart(
false);
178 $form->setId(
"properties");
182 $online->
setInfo($this->lng->txt(
"spl_online_property_description"));
183 $online->setChecked($this->object->getOnline());
184 $form->addItem($online);
186 $form->addCommandButton(
"saveProperties", $this->lng->txt(
"save"));
192 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
200 $qpl_online =
$_POST[
"online"];
201 if (strlen($qpl_online) == 0) $qpl_online =
"0";
202 $this->
object->setOnline($qpl_online);
203 $this->
object->saveToDb();
205 $this->ctrl->redirect($this,
"properties");
214 if (count(
$_POST[
"q_id"]) > 0)
216 foreach (
$_POST[
"q_id"] as $key => $value)
218 $this->
object->copyToClipboard($value);
226 $this->ctrl->redirect($this,
"questions");
234 if (count(
$_POST[
"q_id"]) > 0)
236 foreach (
$_POST[
"q_id"] as $key => $value)
238 $this->
object->moveToClipboard($value);
246 $this->ctrl->redirect($this,
"questions");
254 if (is_array(
$_POST[
'q_id']) && count(
$_POST[
'q_id']) > 0)
273 $checked_questions =
$_POST[
'q_id'];
274 if (count($checked_questions) > 0)
276 if (!$rbacsystem->checkAccess(
'write', $this->ref_id))
283 elseif (count($checked_questions) == 0)
290 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
292 $cgui->setHeaderText($this->lng->txt(
"qpl_confirm_delete_questions"));
294 $cgui->setFormAction($this->ctrl->getFormAction($this));
295 $cgui->setCancel($this->lng->txt(
"cancel"),
"cancelDeleteQuestions");
296 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmDeleteQuestions");
298 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
299 $infos = $this->
object->getQuestionInfos($checked_questions);
300 foreach ($infos as
$data)
302 $txt = $data[
"title"].
" (".
304 if($data[
"description"])
306 $txt .=
"<div class=\"small\">".$data[
"description"].
"</div>";
309 $cgui->addItem(
"q_id[]", $data[
"id"],
$txt);
312 $this->tpl->setContent($cgui->getHTML());
322 foreach (
$_POST[
'q_id'] as $q_id)
324 $this->
object->removeQuestion($q_id);
326 $this->ctrl->redirect($this,
"questions");
335 $this->ctrl->redirect($this,
"questions");
343 if (array_key_exists(
"spl_clipboard",
$_SESSION))
345 $this->
object->pasteFromClipboard();
351 $this->ctrl->redirect($this,
"questions");
361 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
363 $form->setFormAction($this->ctrl->getFormAction($this,
"uploadQuestions"));
364 $form->setTitle($this->lng->txt(
"import_question"));
366 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
367 $fi =
new ilFileInputGUI($this->lng->txt(
"select_file"),
"qtidoc");
369 $fi->setRequired(
true);
372 $form->addCommandButton(
"uploadQuestions", $this->lng->txt(
"import"));
373 $form->addCommandButton(
"questions", $this->lng->txt(
"cancel"));
375 $tpl->setContent($form->getHTML());
384 $source = $_FILES[
"qtidoc"][
"tmp_name"];
386 if (($source ==
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK)
391 if (!$error && strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !== FALSE)
399 $this->
object->createImportDirectory();
402 $full_path = $this->
object->getImportDirectory().
"/".$_FILES[
"qtidoc"][
"name"];
404 include_once
"./Services/Utilities/classes/class.ilUtil.php";
406 $_FILES[
"qtidoc"][
"name"], $full_path);
407 $source = $full_path;
408 $this->
object->importObject($source, TRUE);
411 $this->ctrl->redirect($this,
"questions");
416 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
418 $table_gui->writeFilterToSession();
419 $this->ctrl->redirect($this,
'questions');
424 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
426 $table_gui->resetFilter();
427 $this->ctrl->redirect($this,
'questions');
439 $this->
object->purgeQuestions();
443 if ($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']))
445 include_once
"Services/Form/classes/class.ilSelectInputGUI.php";
447 $qtypes->setValue($ilUser->getPref(
"svy_lastquestiontype"));
448 $ilToolbar->addInputItem($qtypes);
451 foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation =>
$data)
457 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
459 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
461 $button->setCaption(
"svy_create_question");
462 $button->setCommand(
"createQuestion");
463 $ilToolbar->addButtonInstance($button);
465 $ilToolbar->addSeparator();
468 $button->setCaption(
"import");
469 $button->setCommand(
"importQuestions");
470 $ilToolbar->addButtonInstance($button);
473 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
475 $table_gui->
setEditable($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']));
476 $arrFilter = array();
477 foreach ($table_gui->getFilterItems() as $item)
479 if ($item->getValue() !==
false)
481 $arrFilter[$item->getPostVar()] = $item->getValue();
484 $table_gui->setData($this->object->getQuestionsData($arrFilter));
485 $this->tpl->setContent($table_gui->getHTML());
490 $this->update = $this->
object->update();
500 "&baseClass=ilObjSurveyQuestionPoolGUI");
510 $ilToolbar->addButton($this->lng->txt(
'create_export_file'),
511 $this->ctrl->getLinkTarget($this,
'createExportFile'));
513 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
515 $export_dir = $this->
object->getExportDirectory();
516 $export_files = $this->
object->getExportFiles($export_dir);
518 foreach ($export_files as $exp_file)
520 $file_arr = explode(
"__", $exp_file);
523 $table_gui->setData(
$data);
524 $this->tpl->setContent($table_gui->getHTML());
534 if ($rbacsystem->checkAccess(
"write", $this->ref_id))
536 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
538 $survey_exp->buildExportFile($questions);
539 $this->ctrl->redirect($this,
"export");
552 if(!isset(
$_POST[
"file"]))
555 $this->ctrl->redirect($this,
"export");
558 if (count(
$_POST[
"file"]) > 1)
561 $this->ctrl->redirect($this,
"export");
565 $export_dir = $this->
object->getExportDirectory();
566 include_once
"./Services/Utilities/classes/class.ilUtil.php";
578 if(!isset(
$_POST[
"file"]))
581 $this->ctrl->redirect($this,
"export");
585 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
587 $export_dir = $this->
object->getExportDirectory();
589 foreach (
$_POST[
'file'] as $exp_file)
591 $file_arr = explode(
"__", $exp_file);
594 $table_gui->setData(
$data);
595 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
605 $this->ctrl->redirect($this,
"export");
613 $export_dir = $this->
object->getExportDirectory();
616 $file = basename($file);
618 $exp_file = $export_dir.
"/".
$file;
619 $exp_dir = $export_dir.
"/".substr($file, 0, strlen($file) - 4);
620 if (@is_file($exp_file))
624 if (@is_dir($exp_dir))
626 include_once
"./Services/Utilities/classes/class.ilUtil.php";
630 $this->ctrl->redirect($this,
"export");
636 $form->getItemByPostVar(
'importfile')->setSuffixes(array(
"zip",
"xml"));
645 $forms = array(self::CFORM_NEW => $this->
initCreateForm($a_new_type),
646 self::CFORM_IMPORT => $form);
658 $parent_id =
$_GET[
"ref_id"];
664 $ilErr->raiseError($this->lng->txt(
"no_create_permission"));
667 $this->lng->loadLanguageModule($new_type);
668 $this->ctrl->setParameter($this,
"new_type", $new_type);
671 if ($form->checkInput())
673 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
675 $newObj->setType($new_type);
676 $newObj->setTitle(
"dummy");
677 $newObj->create(
true);
680 $newObj->createImportDirectory();
683 $upload = $_FILES[
"importfile"];
684 $file = pathinfo($upload[
"name"]);
685 $full_path = $newObj->getImportDirectory().
"/".$upload[
"name"];
686 include_once
"./Services/Utilities/classes/class.ilUtil.php";
691 $qtiresult = $newObj->importObject($full_path);
695 "&baseClass=ilObjSurveyQuestionPoolGUI");
699 $form->setValuesByPost();
700 $tpl->setContent($form->getHtml());
710 $ilUser->writePref(
"svy_lastquestiontype",
$_POST[
"sel_question_types"]);
712 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
714 $q_gui->object->setObjId($this->object->getId());
715 $q_gui->object->createNewQuestion();
717 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
718 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types",
$_POST[
"sel_question_types"]);
719 $this->ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
727 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
729 $this->ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
730 $this->ctrl->setParameterByClass(get_class($q_gui),
"q_id",
$_GET[
"preview"]);
731 $this->ctrl->redirectByClass(get_class($q_gui),
"preview");
741 $this->ctrl->setCmd(
"showSummary");
742 $this->ctrl->setCmdClass(
"ilinfoscreengui");
753 if(!$ilAccess->checkAccess(
"visible",
"", $this->ref_id))
755 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_read"));
758 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
760 $info->enablePrivateNotes();
763 $info->addMetaDataSections($this->object->getId(), 0, $this->
object->getType());
765 $this->ctrl->forwardCommand($info);
771 switch ($this->ctrl->getCmd())
778 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$_GET[
"ref_id"]);
781 if ((
int)
$_GET[
"q_id"])
783 $q_id = (int)
$_GET[
"q_id"];
784 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
790 $this->ctrl->setParameterByClass($q_type,
"q_id", $q_id);
791 $ilLocator->addItem($q_title,
792 $this->ctrl->getLinkTargetByClass($q_type,
"editQuestion"));
804 global $ilAccess, $ilHelp;
806 $ilHelp->setScreenIdComponent(
"spl");
808 $next_class = $this->ctrl->getNextClass($this);
812 case "ilpermissiongui":
813 case "ilmdeditorgui":
814 case "ilsurveyphrasesgui":
822 $force_active = (($this->ctrl->getCmdClass() ==
"" &&
823 $this->ctrl->getCmd() !=
"properties") ||
824 $this->ctrl->getCmd() ==
"")
829 if (is_array(
$_GET[
"sort"]))
831 $force_active =
true;
834 $tabs_gui->addTarget(
"survey_questions",
835 $this->ctrl->getLinkTarget($this,
'questions'),
836 array(
"questions",
"filterQuestionBrowser",
"filter",
"reset",
"createQuestion",
837 "importQuestions",
"deleteQuestions",
"copy",
"paste",
838 "exportQuestions",
"confirmDeleteQuestions",
"cancelDeleteQuestions",
839 "confirmPasteQuestions",
"cancelPasteQuestions",
"uploadQuestions",
840 "editQuestion",
"addMaterial",
"removeMaterial",
"save",
"cancel",
841 "cancelExplorer",
"linkChilds",
"addGIT",
"addST",
"addPG",
"preview",
842 "moveCategory",
"deleteCategory",
"addPhrase",
"addCategory",
"savePhrase",
843 "addSelectedPhrase",
"cancelViewPhrase",
"confirmSavePhrase",
"cancelSavePhrase",
844 "insertBeforeCategory",
"insertAfterCategory",
"confirmDeleteCategory",
845 "cancelDeleteCategory",
"categories",
"saveCategories",
846 "savePhrase",
"addPhrase"
848 array(
"ilobjsurveyquestionpoolgui",
"ilsurveyphrasesgui"),
"", $force_active);
850 if ($ilAccess->checkAccess(
"visible",
"", $this->ref_id))
852 $tabs_gui->addTarget(
"info_short",
853 $this->ctrl->getLinkTarget($this,
"infoScreen"),
854 array(
"infoScreen",
"showSummary"));
857 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id))
860 $tabs_gui->addTarget(
"settings",
861 $this->ctrl->getLinkTarget($this,
'properties'),
866 $tabs_gui->addTarget(
"manage_phrases",
867 $this->ctrl->getLinkTargetByClass(
"ilsurveyphrasesgui",
"phrases"),
868 array(
"phrases",
"deletePhrase",
"confirmDeletePhrase",
"cancelDeletePhrase",
"editPhrase",
"newPhrase",
"saveEditPhrase",
"phraseEditor"),
869 "ilsurveyphrasesgui",
"");
872 $tabs_gui->addTarget(
"meta_data",
873 $this->ctrl->getLinkTargetByClass(
'ilmdeditorgui',
'listSection'),
874 "",
"ilmdeditorgui");
877 $tabs_gui->addTarget(
"export",
878 $this->ctrl->getLinkTarget($this,
'export'),
879 array(
"export",
"createExportFile",
"confirmDeleteExportFile",
880 "downloadExportFile",
"cancelDeleteExportFile",
"deleteExportFile"),
884 if ($ilAccess->checkAccess(
"edit_permission",
"", $this->ref_id))
886 $tabs_gui->addTarget(
"perm_settings",
887 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm"), array(
"perm",
"info",
"owner"),
'ilpermissiongui');
896 $obligatory = array();
897 foreach (
$_POST as $key => $value)
899 if (preg_match(
"/obligatory_(\d+)/", $key, $matches))
901 $obligatory[]= $matches[1];
904 $this->
object->setObligatoryStates($obligatory);
907 $this->ctrl->redirect($this,
"questions");
916 public static function _goto($a_target)
919 if ($ilAccess->checkAccess(
"write",
"", $a_target))
921 $_GET[
"baseClass"] =
"ilObjSurveyQuestionPoolGUI";
922 $_GET[
"cmd"] =
"questions";
923 $_GET[
"ref_id"] = $a_target;
924 include_once(
"ilias.php");
927 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
933 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);