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");
 
  359                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_import_question.html", 
"Modules/SurveyQuestionPool");
 
  360                 $this->tpl->setCurrentBlock(
"adm_content");
 
  361                 $this->tpl->setVariable(
"TEXT_IMPORT_QUESTION", $this->lng->txt(
"import_question"));
 
  362                 $this->tpl->setVariable(
"TEXT_SELECT_FILE", $this->lng->txt(
"select_file"));
 
  363                 $this->tpl->setVariable(
"TEXT_UPLOAD", $this->lng->txt(
"upload"));
 
  364                 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
 
  365                 $this->tpl->parseCurrentBlock();
 
  374                 $source = $_FILES[
"qtidoc"][
"tmp_name"];
 
  376                 if (($source == 
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK)
 
  381                 if (strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !== FALSE)
 
  389                         $this->
object->createImportDirectory();
 
  392                         $full_path = $this->
object->getImportDirectory().
"/".$_FILES[
"qtidoc"][
"name"];
 
  394                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  396                                 $_FILES[
"qtidoc"][
"name"], $full_path);
 
  397                         $source = $full_path;
 
  398                         $this->
object->importObject($source, TRUE);
 
  401                 $this->ctrl->redirect($this, 
"questions");
 
  406                 include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
 
  408                 $table_gui->writeFilterToSession();
 
  409                 $this->ctrl->redirect($this, 
'questions');
 
  414                 include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
 
  416                 $table_gui->resetFilter();
 
  417                 $this->ctrl->redirect($this, 
'questions');
 
  429                 $this->
object->purgeQuestions();
 
  433                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
'ref_id']))
 
  435                         include_once 
"Services/Form/classes/class.ilSelectInputGUI.php";
 
  437                         $qtypes->setValue($ilUser->getPref(
"svy_lastquestiontype"));
 
  438                         $ilToolbar->addInputItem($qtypes);
 
  441                         foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => 
$data)
 
  447                         $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
 
  448                         $ilToolbar->addFormButton($this->lng->txt(
"svy_create_question"), 
"createQuestion");
 
  450                         $ilToolbar->addSeparator();
 
  452                         $ilToolbar->addFormButton($this->lng->txt(
'import'), 
'importQuestions');
 
  455                 include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
 
  457                 $table_gui->
setEditable($rbacsystem->checkAccess(
'write', 
$_GET[
'ref_id']));
 
  458                 $arrFilter = array();
 
  459                 foreach ($table_gui->getFilterItems() as $item)
 
  461                         if ($item->getValue() !== 
false)
 
  463                                 $arrFilter[$item->getPostVar()] = $item->getValue();
 
  466                 $table_gui->setData($this->object->getQuestionsData($arrFilter));
 
  467                 $this->tpl->setContent($table_gui->getHTML());                  
 
  472                 $this->update = $this->
object->update();
 
  482                         "&baseClass=ilObjSurveyQuestionPoolGUI");
 
  492                 $ilToolbar->addButton($this->lng->txt(
'create_export_file'),
 
  493                         $this->ctrl->getLinkTarget($this, 
'createExportFile'));
 
  495                 include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
 
  497                 $export_dir = $this->
object->getExportDirectory();
 
  498                 $export_files = $this->
object->getExportFiles($export_dir);
 
  500                 foreach ($export_files as $exp_file)
 
  502                         $file_arr = explode(
"__", $exp_file);
 
  505                 $table_gui->setData(
$data);
 
  506                 $this->tpl->setContent($table_gui->getHTML());  
 
  516                 if ($rbacsystem->checkAccess(
"write", $this->ref_id))
 
  518                         include_once(
"./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
 
  520                         $survey_exp->buildExportFile($questions);
 
  521                         $this->ctrl->redirect($this, 
"export");
 
  534                 if(!isset(
$_POST[
"file"]))
 
  537                         $this->ctrl->redirect($this, 
"export");
 
  540                 if (count(
$_POST[
"file"]) > 1)
 
  543                         $this->ctrl->redirect($this, 
"export");
 
  547                 $export_dir = $this->
object->getExportDirectory();
 
  548                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  560                 if(!isset(
$_POST[
"file"]))
 
  563                         $this->ctrl->redirect($this, 
"export");
 
  567                 include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
 
  569                 $export_dir = $this->
object->getExportDirectory();
 
  571                 foreach (
$_POST[
'file'] as $exp_file)
 
  573                         $file_arr = explode(
"__", $exp_file);
 
  576                 $table_gui->setData(
$data);
 
  577                 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());  
 
  587                 $this->ctrl->redirect($this, 
"export");
 
  595                 $export_dir = $this->
object->getExportDirectory();
 
  598                         $file = basename($file);
 
  600                         $exp_file = $export_dir.
"/".
$file;
 
  601                         $exp_dir = $export_dir.
"/".substr($file, 0, strlen($file) - 4);
 
  602                         if (@is_file($exp_file))
 
  606                         if (@is_dir($exp_dir))
 
  608                                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  612                 $this->ctrl->redirect($this, 
"export");
 
  618                 $form->getItemByPostVar(
'importfile')->setSuffixes(array(
"zip", 
"xml"));
 
  627                 $forms = array(self::CFORM_NEW => $this->
initCreateForm($a_new_type),
 
  628                         self::CFORM_IMPORT => $form);
 
  640                 $parent_id = 
$_GET[
"ref_id"];
 
  646                         $ilErr->raiseError($this->lng->txt(
"no_create_permission"));
 
  649                 $this->lng->loadLanguageModule($new_type);
 
  650                 $this->ctrl->setParameter($this, 
"new_type", $new_type);
 
  653                 if ($form->checkInput())
 
  655                         include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
  657                         $newObj->setType($new_type);
 
  658                         $newObj->setTitle(
"dummy");
 
  659                         $newObj->create(
true);
 
  662                         $newObj->createImportDirectory();
 
  665                         $upload = $_FILES[
"importfile"];
 
  666                         $file = pathinfo($upload[
"name"]);
 
  667                         $full_path = $newObj->getImportDirectory().
"/".$upload[
"name"];
 
  668                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  673                         $qtiresult = $newObj->importObject($full_path);
 
  677                                 "&baseClass=ilObjSurveyQuestionPoolGUI");
 
  681                 $form->setValuesByPost();
 
  682                 $tpl->setContent($form->getHtml());
 
  692                 $ilUser->writePref(
"svy_lastquestiontype", 
$_POST[
"sel_question_types"]);
 
  694                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
  696                 $q_gui->object->setObjId($this->object->getId());
 
  697                 $q_gui->object->createNewQuestion();
 
  699                 $this->ctrl->setParameterByClass(get_class($q_gui), 
"q_id", $q_gui->object->getId());
 
  700                 $this->ctrl->setParameterByClass(get_class($q_gui), 
"sel_question_types", 
$_POST[
"sel_question_types"]);
 
  701                 $this->ctrl->redirectByClass(get_class($q_gui), 
"editQuestion");
 
  709                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
  711                 $this->ctrl->setParameterByClass(get_class($q_gui), 
"sel_question_types", $q_gui->getQuestionType());
 
  712                 $this->ctrl->setParameterByClass(get_class($q_gui), 
"q_id", 
$_GET[
"preview"]);
 
  713                 $this->ctrl->redirectByClass(get_class($q_gui), 
"preview");
 
  723                 $this->ctrl->setCmd(
"showSummary");
 
  724                 $this->ctrl->setCmdClass(
"ilinfoscreengui");
 
  735                 if(!$ilAccess->checkAccess(
"visible", 
"", $this->ref_id))
 
  737                         $ilErr->raiseError($this->lng->txt(
"msg_no_perm_read"));
 
  740                 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
 
  742                 $info->enablePrivateNotes();
 
  745                 $info->addMetaDataSections($this->object->getId(), 0, $this->
object->getType());
 
  747                 $this->ctrl->forwardCommand($info);
 
  753                 switch ($this->ctrl->getCmd())
 
  760                         $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 
""), 
"", 
$_GET[
"ref_id"]);
 
  763                 if ((
int)
$_GET[
"q_id"])
 
  765                         $q_id = (int)
$_GET[
"q_id"];
 
  766                         include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  772                                 $this->ctrl->setParameterByClass($q_type, 
"q_id", $q_id);                       
 
  773                                 $ilLocator->addItem($q_title,
 
  774                                         $this->ctrl->getLinkTargetByClass($q_type, 
"editQuestion"));                    
 
  786                 global $ilAccess, $ilHelp;
 
  788                 $ilHelp->setScreenIdComponent(
"spl");
 
  790                 $next_class = $this->ctrl->getNextClass($this);
 
  794                         case "ilpermissiongui":
 
  795                         case "ilmdeditorgui":
 
  796                         case "ilsurveyphrasesgui":
 
  804                 $force_active = (($this->ctrl->getCmdClass() == 
"" &&
 
  805                         $this->ctrl->getCmd() != 
"properties") ||
 
  806                         $this->ctrl->getCmd() == 
"")
 
  811                         if (is_array(
$_GET[
"sort"]))
 
  813                                 $force_active = 
true;
 
  816                 $tabs_gui->addTarget(
"survey_questions",
 
  817                          $this->ctrl->getLinkTarget($this,
'questions'),
 
  818                          array(
"questions", 
"filterQuestionBrowser", 
"filter", 
"reset", 
"createQuestion", 
 
  819                          "importQuestions", 
"deleteQuestions", 
"copy", 
"paste", 
 
  820                          "exportQuestions", 
"confirmDeleteQuestions", 
"cancelDeleteQuestions",
 
  821                          "confirmPasteQuestions", 
"cancelPasteQuestions", 
"uploadQuestions",
 
  822                          "editQuestion", 
"addMaterial", 
"removeMaterial", 
"save", 
"cancel",
 
  823                          "cancelExplorer", 
"linkChilds", 
"addGIT", 
"addST", 
"addPG", 
"preview",
 
  824                          "moveCategory", 
"deleteCategory", 
"addPhrase", 
"addCategory", 
"savePhrase",
 
  825                          "addSelectedPhrase", 
"cancelViewPhrase", 
"confirmSavePhrase", 
"cancelSavePhrase",
 
  826                          "insertBeforeCategory", 
"insertAfterCategory", 
"confirmDeleteCategory",
 
  827                          "cancelDeleteCategory", 
"categories", 
"saveCategories", 
 
  828                          "savePhrase", 
"addPhrase" 
  830                          array(
"ilobjsurveyquestionpoolgui", 
"ilsurveyphrasesgui"), 
"", $force_active);
 
  832                 if ($ilAccess->checkAccess(
"visible", 
"", $this->ref_id))
 
  834                         $tabs_gui->addTarget(
"info_short",
 
  835                                  $this->ctrl->getLinkTarget($this, 
"infoScreen"),
 
  836                                 array(
"infoScreen", 
"showSummary"));            
 
  839                 if ($ilAccess->checkAccess(
'write', 
'', $this->ref_id))
 
  842                         $tabs_gui->addTarget(
"settings",
 
  843                          $this->ctrl->getLinkTarget($this,
'properties'),
 
  848                         $tabs_gui->addTarget(
"manage_phrases",
 
  849                                  $this->ctrl->getLinkTargetByClass(
"ilsurveyphrasesgui", 
"phrases"),
 
  850                                  array(
"phrases", 
"deletePhrase", 
"confirmDeletePhrase", 
"cancelDeletePhrase", 
"editPhrase", 
"newPhrase", 
"saveEditPhrase", 
"phraseEditor"),
 
  851                                  "ilsurveyphrasesgui", 
"");
 
  854                         $tabs_gui->addTarget(
"meta_data",
 
  855                                  $this->ctrl->getLinkTargetByClass(
'ilmdeditorgui',
'listSection'),
 
  856                                  "", 
"ilmdeditorgui");
 
  859                         $tabs_gui->addTarget(
"export",
 
  860                                  $this->ctrl->getLinkTarget($this,
'export'),
 
  861                                  array(
"export", 
"createExportFile", 
"confirmDeleteExportFile",
 
  862                                  "downloadExportFile", 
"cancelDeleteExportFile", 
"deleteExportFile"),
 
  866                 if ($ilAccess->checkAccess(
"edit_permission", 
"", $this->ref_id))
 
  868                         $tabs_gui->addTarget(
"perm_settings",
 
  869                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'), 
"perm"), array(
"perm",
"info",
"owner"), 
'ilpermissiongui');
 
  878                 $obligatory = array();
 
  879                 foreach (
$_POST as $key => $value)
 
  881                         if (preg_match(
"/obligatory_(\d+)/", $key, $matches))
 
  883                                 $obligatory[]= $matches[1];
 
  886                 $this->
object->setObligatoryStates($obligatory);
 
  889                 $this->ctrl->redirect($this, 
"questions");
 
  898         public static function _goto($a_target)
 
  901                 if ($ilAccess->checkAccess(
"write", 
"", $a_target))
 
  903                         $_GET[
"baseClass"] = 
"ilObjSurveyQuestionPoolGUI";
 
  904                         $_GET[
"cmd"] = 
"questions";
 
  905                         $_GET[
"ref_id"] = $a_target;
 
  906                         include_once(
"ilias.php");
 
  909                 else if ($ilAccess->checkAccess(
"read", 
"", ROOT_FOLDER_ID))
 
  915                 $ilErr->raiseError($lng->txt(
"msg_no_perm_read_lm"), $ilErr->FATAL);