40 protected \ILIAS\SurveyQuestionPool\InternalGUIService
$gui;
55 $this->nav_history =
$DIC[
"ilNavigationHistory"];
56 $this->
toolbar = $DIC->toolbar();
57 $this->
help = $DIC[
"ilHelp"];
59 $this->archives =
$DIC->archives();
60 $this->edit_request =
$DIC->surveyQuestionPool()
65 $this->edit_manager =
$DIC->surveyQuestionPool()
74 $this->edit_request->getRefId(),
78 $this->
lng->loadLanguageModule(
"survey");
79 $this->
ctrl->saveParameter($this, array(
"ref_id"));
81 $this->gui =
$DIC->surveyQuestionPool()->internal()->gui();
95 $ilNavigationHistory->addItem(
97 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=" . $this->ref_id,
105 $cmd = $this->
ctrl->getCmd(
"questions");
106 $next_class = $this->
ctrl->getNextClass($this);
107 if ($cmd !==
"cancel") {
108 $this->
ctrl->setReturn($this,
"questions");
111 if ($this->edit_request->getQuestionId() < 1) {
112 $q_type = $this->edit_request->getSelectedQuestionTypes();
115 $this->log->debug(
"- cmd=" . $cmd .
" next_class=" . $next_class);
116 switch ($next_class) {
117 case 'ilobjectmetadatagui':
118 $this->tabs_gui->activateTab(
"meta_data");
121 $this->
ctrl->forwardCommand($md_gui);
124 case 'ilpermissiongui':
126 $this->
ctrl->forwardCommand($perm_gui);
129 case 'ilobjectcopygui':
132 $this->
ctrl->forwardCommand($cp);
135 case 'ilinfoscreengui':
136 $this->tabs_gui->activateTab(
"info_short");
140 case "ilcommonactiondispatchergui":
142 $this->
ctrl->forwardCommand($gui);
145 case strtolower(\
ILIAS\SurveyQuestionPool\Settings\SettingsGUI::class):
147 $this->tabs_gui->activateTab(
"settings");
148 $gui = $this->gui->settings()->settingsGUI(
150 $this->object->getRefId()
152 $this->
ctrl->forwardCommand($gui);
155 case strtolower(ilExportGUI::class):
157 $this->
ctrl->forwardCommand($export);
168 $this->edit_request->getQuestionId()
170 $this->log->debug(
"- This is the switch/case default, going to question id =" . $this->edit_request->getQuestionId());
171 $q_gui->setQuestionTabs();
172 $this->
ctrl->forwardCommand($q_gui);
175 if ($q_gui->object->isComplete()) {
176 $this->tpl->setTitle($this->
lng->txt(
"question") .
": " . $q_gui->object->getTitle());
180 if (strtolower($this->edit_request->getBaseClass()) !==
"iladministrationgui" &&
181 $this->getCreationMode() !==
true) {
182 $this->tpl->printToStdout();
191 $this->
ctrl->redirectByClass(\
ILIAS\SurveyQuestionPool\Settings\SettingsGUI::class);
200 $qids = $this->edit_request->getQuestionIds();
201 if (count($qids) > 0) {
202 foreach ($qids as $key => $value) {
203 $this->
object->copyToClipboard($value);
205 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_copy_insert_clipboard"),
true);
207 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_copy_select_none"),
true);
209 $this->
ctrl->redirect($this,
"questions");
217 $qids = $this->edit_request->getQuestionIds();
218 if (count($qids) > 0) {
219 foreach ($qids as $key => $value) {
220 $this->
object->moveToClipboard($value);
222 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_move_insert_clipboard"),
true);
224 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_move_select_none"),
true);
226 $this->
ctrl->redirect($this,
"questions");
234 $qids = $this->edit_request->getQuestionIds();
235 if (count($qids) > 0) {
236 $this->createExportFileObject($qids);
238 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_export_select_none"));
245 $qids = $this->
http->wrapper()->query()->retrieve(
247 $this->
refinery->custom()->transformation(function (
string $value) {
248 $value = urldecode($value);
249 return explode(
',', $value);
252 $this->createExportFileObject($qids);
263 $checked_questions = $this->edit_request->getQuestionIds();
264 if (count($checked_questions) === 0) {
265 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_delete_select_none"));
271 $cgui->setHeaderText($this->
lng->txt(
"qpl_confirm_delete_questions"));
273 $cgui->setFormAction($this->
ctrl->getFormAction($this));
274 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDeleteQuestions");
275 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmDeleteQuestions");
277 $infos = $this->
object->getQuestionInfos($checked_questions);
278 foreach ($infos as
$data) {
281 if (
$data[
"description"]) {
282 $txt .=
"<div class=\"small\">" .
$data[
"description"] .
"</div>";
285 $cgui->addItem(
"q_id[]",
$data[
"id"],
$txt);
288 $this->tpl->setContent($cgui->getHTML());
294 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"qpl_questions_deleted"),
true);
295 $qids = $this->edit_request->getQuestionIds();
296 foreach ($qids as $q_id) {
297 $this->
object->removeQuestion($q_id);
299 $this->
ctrl->redirect($this,
"questions");
305 $this->
ctrl->redirect($this,
"questions");
313 $clip_questions = $this->edit_manager->getQuestionsFromClipboard();
314 if (count($clip_questions) > 0) {
315 $this->
object->pasteFromClipboard();
317 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_paste_no_objects"),
true);
319 $this->
ctrl->redirect($this,
"questions");
335 $form->setFormAction($this->
ctrl->getFormAction($this,
"uploadQuestions"));
336 $form->setTitle($this->
lng->txt(
"import_question"));
339 $fi->setSuffixes(array(
"xml",
"zip"));
340 $fi->setRequired(
true);
343 $form->addCommandButton(
"uploadQuestions", $this->
lng->txt(
"import"));
344 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
354 if ($form->checkInput()) {
356 $source = $_FILES[
"qtidoc"][
"tmp_name"];
358 if (($source ===
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK) {
362 if (!
$error && strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !==
false) {
368 $this->
object->createImportDirectory();
371 $full_path = $this->
object->getImportDirectory() .
"/" . $_FILES[
"qtidoc"][
"name"];
374 $_FILES[
"qtidoc"][
"tmp_name"],
375 $_FILES[
"qtidoc"][
"name"],
378 $source = $full_path;
379 $this->
object->importObject($source,
true);
382 $this->
ctrl->redirect($this,
"questions");
384 $form->setValuesByPost();
393 $table_gui->writeFilterToSession();
394 $this->
ctrl->redirect($this,
'questions');
400 $table_gui->resetFilter();
401 $this->
ctrl->redirect($this,
'questions');
409 $this->tabs_gui->activateTab(
"survey_questions");
413 $this->
object->purgeQuestions();
417 $qtypes->setValue($ilUser->getPref(
"svy_lastquestiontype"));
418 $ilToolbar->addInputItem($qtypes);
422 $options[
$data[
"type_tag"]] = $translation;
424 $qtypes->setOptions($options);
426 $ilToolbar->setFormAction($this->
ctrl->getFormAction($this));
429 $this->
lng->txt(
"svy_create_question"),
431 )->submit()->toToolbar();
433 $ilToolbar->addSeparator();
444 $arrFilter = array();
445 foreach ($table_gui->getFilterItems() as $item) {
446 if ($item->getValue() !==
false) {
447 $arrFilter[$item->getPostVar()] = $item->getValue();
450 $table_gui->setData($this->
object->getQuestionsData($arrFilter));
451 $this->tpl->setContent($table_gui->getHTML());
456 $this->update = $this->
object->update();
457 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
463 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_added"),
true);
466 "&baseClass=ilObjSurveyQuestionPoolGUI");
475 $export->listExportFiles();
481 public function createExportFileObject($questions =
null): void
488 $survey_exp->buildExportFile($questions);
489 $this->
ctrl->redirect($this,
"export");
497 $files = $this->edit_request->getFiles();
498 if (count($files) === 0) {
499 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
500 $this->
ctrl->redirect($this,
"export");
503 if (count($files) > 1) {
504 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"select_max_one_item"),
true);
505 $this->
ctrl->redirect($this,
"export");
509 $export_dir = $this->
object->getExportDirectory();
511 $file = basename($files[0]);
521 $files = $this->edit_request->getFiles();
522 if (count($files) === 0) {
523 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
524 $this->
ctrl->redirect($this,
"export");
527 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
"info_delete_sure"));
529 $export_dir = $this->
object->getExportDirectory();
531 foreach ($files as $exp_file) {
532 $file_arr = explode(
"__", $exp_file);
533 $data[] = array(
'file' => $exp_file,
535 'size' => filesize($export_dir .
"/" . $exp_file)
538 $table_gui->setData(
$data);
539 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
545 $this->
ctrl->redirect($this,
"export");
550 $export_dir = $this->
object->getExportDirectory();
551 $files = $this->edit_request->getFiles();
552 foreach ($files as $file) {
553 $file = basename($file);
555 $exp_file = $export_dir .
"/" . $file;
556 $exp_dir = $export_dir .
"/" . substr($file, 0, -4);
557 if (is_file($exp_file)) {
560 if (is_dir($exp_dir)) {
564 $this->
ctrl->redirect($this,
"export");
575 "svy_lastquestiontype",
576 $this->edit_request->getSelectedQuestionTypes()
580 $this->edit_request->getSelectedQuestionTypes()
582 $q_gui->object->setObjId($this->
object->getId());
583 $q_gui->object->createNewQuestion();
585 $this->
ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
586 $this->
ctrl->setParameterByClass(
588 "sel_question_types",
589 $this->edit_request->getSelectedQuestionTypes()
591 $this->
ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
601 $this->edit_request->getPreview()
603 $this->
ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
604 $this->
ctrl->setParameterByClass(get_class($q_gui),
"q_id", $this->edit_request->getPreview());
605 $this->
ctrl->redirectByClass(get_class($q_gui),
"preview");
613 $this->
ctrl->redirectByClass(ilInfoScreenGUI::class,
"showSummary");
626 $info->enablePrivateNotes();
629 $info->addMetaDataSections($this->
object->getId(), 0, $this->object->getType());
634 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
636 $unzip = $this->archives->unzip(Streams::ofResource(fopen($file_to_import,
'r')));
637 # If export contains a manifest xml use standard import
638 if (in_array(basename($file_to_import,
".zip") . DIRECTORY_SEPARATOR .
"manifest.xml", iterator_to_array($unzip->getFiles()))) {
639 parent::importFile($file_to_import, $path_to_uploaded_file_in_temp_dir);
645 $newObj->setTitle(
"dummy");
650 $newObj->importObject($file_to_import);
652 if ($path_to_uploaded_file_in_temp_dir !==
''
653 && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
654 $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
658 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_imported"),
true);
660 "&baseClass=ilObjSurveyQuestionPoolGUI");
666 switch ($this->
ctrl->getCmd()) {
672 $ilLocator->addItem($this->
object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"", $this->edit_request->getRefId());
675 if ($this->edit_request->getQuestionId() > 0) {
676 $q_id = $this->edit_request->getQuestionId();
681 $this->
ctrl->setParameterByClass($q_type,
"q_id", $q_id);
684 $this->
ctrl->getLinkTargetByClass($q_type,
"editQuestion")
696 $this->tabs_gui->addTab(
698 $this->
lng->txt(
"survey_questions"),
699 $this->ctrl->getLinkTarget($this,
'questions')
702 $this->tabs_gui->addTab(
704 $this->
lng->txt(
"info_short"),
705 $this->ctrl->getLinkTarget($this,
"infoScreen")
710 $this->tabs_gui->addTab(
712 $this->
lng->txt(
"settings"),
713 $this->ctrl->getLinkTargetByClass(\
ILIAS\SurveyQuestionPool\Settings\SettingsGUI::class)
718 $mdtab = $mdgui->getTab();
720 $this->tabs_gui->addTab(
722 $this->
lng->txt(
"meta_data"),
728 $this->tabs_gui->addTab(
730 $this->
lng->txt(
"export"),
731 $this->ctrl->getLinkTarget($this,
'export')
736 $this->tabs_gui->addTab(
738 $this->
lng->txt(
"perm_settings"),
739 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm")
749 $obligatory = $this->edit_request->getObligatory();
750 $this->
object->setObligatoryStates($obligatory);
752 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
753 $this->
ctrl->redirect($this,
"questions");
759 public static function _goto(
string $a_target): void
762 $main_tpl =
$DIC->ui()->mainTemplate();
765 $ilAccess =
$DIC->access();
768 if ($ilAccess->checkAccess(
"visible",
"", $a_target) ||
769 $ilAccess->checkAccess(
"read",
"", $a_target)) {
773 $main_tpl->setOnScreenMessage(
'failure', sprintf(
774 $lng->
txt(
"msg_no_perm_read_item"),
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
static _getTitle(int $question_id)
Returns the question title of a question with a given id.
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Export User Interface Class.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
setScreenIdComponent(string $a_comp)
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...
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
Last visited history for repository items.
Class ilObjSurveyQuestionPoolGUI.
uploadQuestionsObject()
imports question(s) into the questionpool
saveObligatoryObject()
Save obligatory states.
copyObject()
Copies checked questions in the questionpool to a clipboard.
importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
ILIAS SurveyQuestionPool Editing EditManager $edit_manager
static _goto(string $a_target)
Redirect script to call a survey question pool reference id.
previewObject()
create preview of object
resetfilterQuestionBrowserObject()
afterSave(ilObject $new_object)
Post (successful) object creation hook.
downloadExportFileObject()
download export file
infoScreenObject()
this one is called from the info button in the repository
cancelDeleteExportFileObject()
infoScreenForward()
show information screen
getTabs()
@abstract overwrite in derived GUI class of your object type
pasteObject()
paste questions from the clipboard into the question pool
filterQuestionBrowserObject()
EditingGUIRequest $edit_request
createQuestionObject()
create new question
propertiesObject(?ilPropertyFormGUI $a_form=null)
Edit question pool properties.
ilNavigationHistory $nav_history
importQuestionsObject()
display the import form to import questions into the question pool
exportObject()
list all export files
deleteQuestionsObject()
Creates a confirmation form to delete questions from the question pool.
cancelDeleteQuestionsObject()
exportQuestionObject()
export a question
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
moveObject()
mark one or more question objects for moving
exportQuestionExportTabObject()
confirmDeleteExportFileObject()
confirmation screen for export file deletion
questionsObject()
list questions of question pool
RefineryFactory $refinery
confirmDeleteQuestionsObject()
ILIAS SurveyQuestionPool InternalGUIService $gui
updateObject()
updates object entry in object_data
Class ilObjSurveyQuestionPool.
static _getQuestiontypes()
Get all available question types.
writePref(string $keyword, string $value)
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
deleteUploadedImportFile(string $path_to_uploaded_file_in_temp_dir)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
prepareOutput(bool $show_sub_objects=true)
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static clear(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static redirect(string $a_script)
setContent(string $a_html)
Sets content for standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.