34 protected \ILIAS\Survey\InternalGUIService
$gui;
47 $this->nav_history = $DIC[
"ilNavigationHistory"];
48 $this->
toolbar = $DIC->toolbar();
49 $this->
help = $DIC[
"ilHelp"];
51 $this->edit_request = $DIC->surveyQuestionPool()
56 $this->edit_manager = $DIC->surveyQuestionPool()
65 $this->edit_request->getRefId(),
69 $this->
lng->loadLanguageModule(
"survey");
70 $this->
ctrl->saveParameter($this, array(
"ref_id"));
72 $this->gui = $DIC->survey()->internal()->gui();
86 $ilNavigationHistory->addItem(
88 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=" . $this->ref_id,
96 $cmd = $this->
ctrl->getCmd(
"questions");
97 $next_class = $this->
ctrl->getNextClass($this);
98 if ($cmd !==
"cancel") {
99 $this->
ctrl->setReturn($this,
"questions");
102 if ($this->edit_request->getQuestionId() < 1) {
103 $q_type = $this->edit_request->getSelectedQuestionTypes();
106 $this->log->debug(
"- cmd=" . $cmd .
" next_class=" . $next_class);
107 switch ($next_class) {
108 case 'ilobjectmetadatagui':
111 $this->
ctrl->forwardCommand($md_gui);
114 case 'ilpermissiongui':
116 $this->
ctrl->forwardCommand($perm_gui);
119 case 'ilobjectcopygui':
122 $this->
ctrl->forwardCommand($cp);
125 case 'ilinfoscreengui':
129 case "ilcommonactiondispatchergui":
131 $this->
ctrl->forwardCommand($gui);
142 $this->edit_request->getQuestionId()
144 $this->log->debug(
"- This is the switch/case default, going to question id =" . $this->edit_request->getQuestionId());
145 $q_gui->setQuestionTabs();
146 $this->
ctrl->forwardCommand($q_gui);
149 if ($q_gui->object->isComplete()) {
150 $this->tpl->setTitle($this->
lng->txt(
"question") .
": " . $q_gui->object->getTitle());
154 if (strtolower($this->edit_request->getBaseClass()) !==
"iladministrationgui" &&
156 $this->tpl->printToStdout();
165 $form->setFormAction($this->
ctrl->getFormAction($this,
'properties'));
166 $form->setTitle($this->
lng->txt(
"properties"));
167 $form->setMultipart(
false);
168 $form->setId(
"properties");
172 $title->setSubmitFormOnEnter(
true);
173 $title->setValue($this->
object->getTitle());
176 $title->setRequired(
true);
177 $form->addItem($title);
184 $form->addItem($desc);
188 $online->setInfo($this->
lng->txt(
"spl_online_property_description"));
189 $online->setChecked($this->
object->getOnline());
190 $form->addItem($online);
193 $section->setTitle($this->
lng->txt(
'obj_presentation'));
194 $form->addItem($section);
197 $obj_service->commonSettings()->legacyForm($form, $this->
object)->addTileImage();
199 $form->addCommandButton(
"saveProperties", $this->
lng->txt(
"save"));
213 $this->tpl->setVariable(
"ADM_CONTENT", $a_form->getHTML());
220 if ($form->checkInput()) {
221 $this->
object->setTitle($form->getInput(
"title"));
222 $this->
object->setDescription($form->getInput(
"desc"));
223 $this->
object->setOnline((
int) $form->getInput(
"online"));
225 $this->
object->saveToDb();
228 $obj_service->commonSettings()->legacyForm($form, $this->
object)->saveTileImage();
230 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"),
true);
231 $this->
ctrl->redirect($this,
"properties");
234 $form->setValuesByPost();
244 $qids = $this->edit_request->getQuestionIds();
245 if (count($qids) > 0) {
246 foreach ($qids as
$key => $value) {
247 $this->
object->copyToClipboard($value);
249 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_copy_insert_clipboard"),
true);
251 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_copy_select_none"),
true);
253 $this->
ctrl->redirect($this,
"questions");
261 $qids = $this->edit_request->getQuestionIds();
262 if (count($qids) > 0) {
263 foreach ($qids as
$key => $value) {
264 $this->
object->moveToClipboard($value);
266 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_move_insert_clipboard"),
true);
268 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_move_select_none"),
true);
270 $this->
ctrl->redirect($this,
"questions");
278 $qids = $this->edit_request->getQuestionIds();
279 if (count($qids) > 0) {
280 $this->createExportFileObject($qids);
282 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_export_select_none"));
295 $checked_questions = $this->edit_request->getQuestionIds();
296 if (count($checked_questions) === 0) {
297 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_delete_select_none"));
303 $cgui->setHeaderText($this->
lng->txt(
"qpl_confirm_delete_questions"));
305 $cgui->setFormAction($this->
ctrl->getFormAction($this));
306 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDeleteQuestions");
307 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmDeleteQuestions");
309 $infos = $this->
object->getQuestionInfos($checked_questions);
310 foreach ($infos as
$data) {
311 $txt = $data[
"title"] .
" (" .
313 if ($data[
"description"]) {
314 $txt .=
"<div class=\"small\">" . $data[
"description"] .
"</div>";
317 $cgui->addItem(
"q_id[]", $data[
"id"],
$txt);
320 $this->tpl->setContent($cgui->getHTML());
326 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"qpl_questions_deleted"),
true);
327 $qids = $this->edit_request->getQuestionIds();
328 foreach ($qids as $q_id) {
329 $this->
object->removeQuestion($q_id);
331 $this->
ctrl->redirect($this,
"questions");
337 $this->
ctrl->redirect($this,
"questions");
345 $clip_questions = $this->edit_manager->getQuestionsFromClipboard();
346 if (count($clip_questions) > 0) {
347 $this->
object->pasteFromClipboard();
349 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_paste_no_objects"),
true);
351 $this->
ctrl->redirect($this,
"questions");
367 $form->setFormAction($this->
ctrl->getFormAction($this,
"uploadQuestions"));
368 $form->setTitle($this->
lng->txt(
"import_question"));
372 $fi->setRequired(
true);
375 $form->addCommandButton(
"uploadQuestions", $this->
lng->txt(
"import"));
376 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
386 if ($form->checkInput()) {
388 $source = $_FILES[
"qtidoc"][
"tmp_name"];
390 if (($source ===
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK) {
394 if (!
$error && strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !==
false) {
400 $this->
object->createImportDirectory();
403 $full_path = $this->
object->getImportDirectory() .
"/" . $_FILES[
"qtidoc"][
"name"];
406 $_FILES[
"qtidoc"][
"tmp_name"],
407 $_FILES[
"qtidoc"][
"name"],
410 $source = $full_path;
411 $this->
object->importObject($source,
true);
414 $this->
ctrl->redirect($this,
"questions");
416 $form->setValuesByPost();
425 $table_gui->writeFilterToSession();
426 $this->
ctrl->redirect($this,
'questions');
432 $table_gui->resetFilter();
433 $this->
ctrl->redirect($this,
'questions');
444 $this->
object->purgeQuestions();
448 $qtypes->setValue($ilUser->getPref(
"svy_lastquestiontype"));
449 $ilToolbar->addInputItem($qtypes);
453 $options[
$data[
"type_tag"]] = $translation;
455 $qtypes->setOptions($options);
457 $ilToolbar->setFormAction($this->
ctrl->getFormAction($this));
460 $this->
lng->txt(
"svy_create_question"),
462 )->submit()->toToolbar();
464 $ilToolbar->addSeparator();
467 $this->
lng->txt(
"import"),
469 )->submit()->toToolbar();
474 $arrFilter = array();
475 foreach ($table_gui->getFilterItems() as $item) {
476 if ($item->getValue() !==
false) {
477 $arrFilter[$item->getPostVar()] = $item->getValue();
480 $table_gui->setData($this->
object->getQuestionsData($arrFilter));
481 $this->tpl->setContent($table_gui->getHTML());
486 $this->update = $this->
object->update();
487 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
493 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_added"),
true);
496 "&baseClass=ilObjSurveyQuestionPoolGUI");
507 $this->
lng->txt(
'create_export_file'),
508 $this->
ctrl->getLinkTarget($this,
'createExportFile')
512 $export_dir = $this->
object->getExportDirectory();
513 $export_files = $this->
object->getExportFiles($export_dir);
515 foreach ($export_files as $exp_file) {
516 $file_arr = explode(
"__", $exp_file);
517 $data[] = array(
'file' => $exp_file,
519 'size' => filesize($export_dir .
"/" . $exp_file)
522 $table_gui->setData(
$data);
523 $this->tpl->setContent($table_gui->getHTML());
529 public function createExportFileObject($questions = null):
void 536 $survey_exp->buildExportFile($questions);
537 $this->
ctrl->redirect($this,
"export");
545 $files = $this->edit_request->getFiles();
546 if (count($files) === 0) {
547 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
548 $this->
ctrl->redirect($this,
"export");
551 if (count($files) > 1) {
552 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"select_max_one_item"),
true);
553 $this->
ctrl->redirect($this,
"export");
557 $export_dir = $this->
object->getExportDirectory();
559 $file = basename($files[0]);
569 $files = $this->edit_request->getFiles();
570 if (count($files) === 0) {
571 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
572 $this->
ctrl->redirect($this,
"export");
575 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
"info_delete_sure"));
577 $export_dir = $this->
object->getExportDirectory();
579 foreach ($files as $exp_file) {
580 $file_arr = explode(
"__", $exp_file);
581 $data[] = array(
'file' => $exp_file,
583 'size' => filesize($export_dir .
"/" . $exp_file)
586 $table_gui->setData(
$data);
587 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
593 $this->
ctrl->redirect($this,
"export");
598 $export_dir = $this->
object->getExportDirectory();
599 $files = $this->edit_request->getFiles();
600 foreach ($files as $file) {
601 $file = basename($file);
603 $exp_file = $export_dir .
"/" . $file;
604 $exp_dir = $export_dir .
"/" . substr($file, 0, -4);
605 if (is_file($exp_file)) {
608 if (is_dir($exp_dir)) {
612 $this->
ctrl->redirect($this,
"export");
617 $form = parent::initImportForm($new_type);
618 $form->getItemByPostVar(
'importfile')->setSuffixes(array(
"zip",
"xml"));
627 $forms = array(self::CFORM_NEW => $this->
initCreateForm($new_type),
628 self::CFORM_IMPORT => $form);
638 $parent_id = $this->edit_request->getRefId();
640 $new_type = $this->edit_request->getNewType();
647 $this->
lng->loadLanguageModule($new_type);
648 $this->
ctrl->setParameter($this,
"new_type", $new_type);
651 if ($form->checkInput()) {
653 $newObj->setType($new_type);
654 $newObj->setTitle(
"dummy");
655 $newObj->create(
true);
658 $newObj->createImportDirectory();
661 $upload = $_FILES[
"importfile"];
662 $file = pathinfo($upload[
"name"]);
663 $full_path = $newObj->getImportDirectory() .
"/" . $upload[
"name"];
671 $newObj->importObject($full_path);
673 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_imported"),
true);
675 "&baseClass=ilObjSurveyQuestionPoolGUI");
679 $form->setValuesByPost();
691 "svy_lastquestiontype",
692 $this->edit_request->getSelectedQuestionTypes()
696 $this->edit_request->getSelectedQuestionTypes()
698 $q_gui->object->setObjId($this->
object->getId());
699 $q_gui->object->createNewQuestion();
701 $this->
ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
702 $this->
ctrl->setParameterByClass(
704 "sel_question_types",
705 $this->edit_request->getSelectedQuestionTypes()
707 $this->
ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
717 $this->edit_request->getPreview()
719 $this->
ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
720 $this->
ctrl->setParameterByClass(get_class($q_gui),
"q_id", $this->edit_request->getPreview());
721 $this->
ctrl->redirectByClass(get_class($q_gui),
"preview");
729 $this->
ctrl->setCmd(
"showSummary");
730 $this->
ctrl->setCmdClass(
"ilinfoscreengui");
744 $info->enablePrivateNotes();
747 $info->addMetaDataSections($this->
object->getId(), 0, $this->
object->getType());
749 $this->
ctrl->forwardCommand($info);
755 switch ($this->
ctrl->getCmd()) {
761 $ilLocator->
addItem($this->
object->getTitle(), $this->
ctrl->getLinkTarget($this,
""),
"", $this->edit_request->getRefId());
764 if ($this->edit_request->getQuestionId() > 0) {
765 $q_id = $this->edit_request->getQuestionId();
770 $this->
ctrl->setParameterByClass($q_type,
"q_id", $q_id);
773 $this->
ctrl->getLinkTargetByClass($q_type,
"editQuestion")
785 $next_class = $this->
ctrl->getNextClass($this);
786 switch ($next_class) {
788 case "ilpermissiongui":
789 case "ilobjectmetadatagui":
796 $force_active = ($this->
ctrl->getCmdClass() ===
"" &&
797 $this->
ctrl->getCmd() !==
"properties" && $this->
ctrl->getCmd() !==
"infoScreen") ||
798 ($this->
ctrl->getCmd() ===
"" || $this->
ctrl->getCmd() === null);
799 if (!$force_active) {
800 $sort = $this->edit_request->getSort();
801 if (count($sort) > 0) {
802 $force_active =
true;
807 $this->tabs_gui->addTarget(
809 $this->
ctrl->getLinkTarget($this,
'questions'),
810 array(
"questions",
"filterQuestionBrowser",
"filter",
"reset",
"createQuestion",
811 "importQuestions",
"deleteQuestions",
"copy",
"paste",
812 "exportQuestions",
"confirmDeleteQuestions",
"cancelDeleteQuestions",
813 "confirmPasteQuestions",
"cancelPasteQuestions",
"uploadQuestions",
814 "editQuestion",
"save",
"cancel",
815 "cancelExplorer",
"linkChilds",
"preview",
816 "moveCategory",
"deleteCategory",
"addCategory",
817 "insertBeforeCategory",
"insertAfterCategory",
"confirmDeleteCategory",
818 "cancelDeleteCategory",
"categories",
"saveCategories" 820 array(
"ilobjsurveyquestionpoolgui"),
825 $this->tabs_gui->addTarget(
827 $this->
ctrl->getLinkTarget($this,
"infoScreen"),
828 array(
"infoScreen",
"showSummary")
834 $this->tabs_gui->addTarget(
836 $this->
ctrl->getLinkTarget($this,
'properties'),
837 array(
"properties",
"saveProperties"),
844 $mdtab = $mdgui->getTab();
846 $this->tabs_gui->addTarget(
855 $this->tabs_gui->addTarget(
857 $this->
ctrl->getLinkTarget($this,
'export'),
858 array(
"export",
"createExportFile",
"confirmDeleteExportFile",
859 "downloadExportFile",
"cancelDeleteExportFile",
"deleteExportFile"),
866 $this->tabs_gui->addTarget(
868 $this->
ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm"),
869 array(
"perm",
"info",
"owner"),
880 $obligatory = $this->edit_request->getObligatory();
881 $this->
object->setObligatoryStates($obligatory);
883 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
884 $this->
ctrl->redirect($this,
"questions");
890 public static function _goto(
string $a_target): void
893 $main_tpl = $DIC->ui()->mainTemplate();
895 $ctrl = $DIC->ctrl();
896 $ilAccess = $DIC->access();
897 $lng = $DIC->language();
899 if ($ilAccess->checkAccess(
"visible",
"", $a_target) ||
900 $ilAccess->checkAccess(
"read",
"", $a_target)) {
904 $main_tpl->setOnScreenMessage(
'failure', sprintf(
905 $lng->
txt(
"msg_no_perm_read_item"),
Class ilObjSurveyQuestionPoolGUI.
cancelDeleteQuestionsObject()
importQuestionsObject()
display the import form to import questions into the question pool
initImportForm(string $new_type)
confirmDeleteQuestionsObject()
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
resetfilterQuestionBrowserObject()
static getLogger(string $a_component_id)
Get component logger.
previewObject()
create preview of object
writePref(string $a_keyword, string $a_value)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ILIAS Survey InternalGUIService $gui
Class ilObjSurveyQuestionPool.
confirmDeleteExportFileObject()
confirmation screen for export file deletion
GUI class for the workflow of copying objects.
copyObject()
Copies checked questions in the questionpool to a clipboard.
exportObject()
list all export files
EditingGUIRequest $edit_request
prepareOutput(bool $show_sub_objects=true)
initCreationForms(string $new_type)
saveObligatoryObject()
Save obligatory states.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type.
static _goto(string $a_target)
Redirect script to call a survey question pool reference id.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
static _getTitle(int $question_id)
Returns the question title of a question with a given id.
ilNavigationHistory $nav_history
ILIAS SurveyQuestionPool Editing EditManager $edit_manager
downloadExportFileObject()
download export file
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
cancelDeleteExportFileObject()
afterSave(ilObject $new_object)
static _lookupObjId(int $ref_id)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
setValue(string $a_value)
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
infoScreenObject()
this one is called from the info button in the repository
ilGlobalTemplateInterface $tpl
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
createQuestionObject()
create new question
setScreenIdComponent(string $a_comp)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectGUI Basic methods of all Output classes.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectService $object_service
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
Last visited history for repository items.
propertiesObject(ilPropertyFormGUI $a_form=null)
Edit question pool properties.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static redirect(string $a_script)
deleteQuestionsObject()
Creates a confirmation form to delete questions from the question pool.
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
infoScreenForward()
show information screen
filterQuestionBrowserObject()
importFileObject(int $parent_id=null)
initCreateForm(string $new_type)
This class represents a text area property in a property form.
static _getQuestiontypes()
Get all available question types.
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
uploadQuestionsObject()
imports question(s) into the questionpool
questionsObject()
list questions of question pool
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
moveObject()
mark one or more question objects for moving
static clear(string $a_var)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
exportQuestionObject()
export a question
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
pasteObject()
paste questions from the clipboard into the question pool
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.