40 protected \ILIAS\SurveyQuestionPool\InternalGUIService
$gui;
56 $this->nav_history = $DIC[
"ilNavigationHistory"];
57 $this->
toolbar = $DIC->toolbar();
58 $this->
help = $DIC[
"ilHelp"];
60 $this->
http = $DIC->http();
61 $this->archives = $DIC->archives();
62 $this->edit_request = $DIC->surveyQuestionPool()
67 $this->edit_manager = $DIC->surveyQuestionPool()
76 $this->edit_request->getRefId(),
80 $this->
lng->loadLanguageModule(
"survey");
81 $this->
ctrl->saveParameter($this, array(
"ref_id"));
83 $this->gui = $DIC->surveyQuestionPool()->internal()->gui();
97 $ilNavigationHistory->addItem(
99 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=" . $this->ref_id,
107 $cmd = $this->
ctrl->getCmd(
"questions");
108 $next_class = $this->
ctrl->getNextClass($this);
109 if ($cmd !==
"cancel") {
110 $this->
ctrl->setReturn($this,
"questions");
113 if ($this->edit_request->getQuestionId() < 1) {
114 $q_type = $this->edit_request->getSelectedQuestionTypes();
117 $this->log->debug(
"- cmd=" . $cmd .
" next_class=" . $next_class);
118 switch ($next_class) {
119 case 'ilobjectmetadatagui':
120 $this->tabs_gui->activateTab(
"meta_data");
123 $this->
ctrl->forwardCommand($md_gui);
126 case 'ilpermissiongui':
128 $this->
ctrl->forwardCommand($perm_gui);
131 case 'ilobjectcopygui':
134 $this->
ctrl->forwardCommand($cp);
137 case 'ilinfoscreengui':
138 $this->tabs_gui->activateTab(
"info_short");
142 case "ilcommonactiondispatchergui":
144 $this->
ctrl->forwardCommand($gui);
147 case strtolower(\
ILIAS\SurveyQuestionPool\
Settings\SettingsGUI::class):
149 $this->tabs_gui->activateTab(
"settings");
150 $gui = $this->gui->settings()->settingsGUI(
152 $this->
object->getRefId()
154 $this->
ctrl->forwardCommand($gui);
157 case strtolower(ilExportGUI::class):
159 $this->
ctrl->forwardCommand($export);
170 $this->edit_request->getQuestionId()
172 $this->log->debug(
"- This is the switch/case default, going to question id =" . $this->edit_request->getQuestionId());
173 $q_gui->setQuestionTabs();
174 $this->
ctrl->forwardCommand($q_gui);
177 if ($q_gui->object->isComplete()) {
178 $this->tpl->setTitle($this->
lng->txt(
"question") .
": " . $q_gui->object->getTitle());
182 if (strtolower($this->edit_request->getBaseClass()) !==
"iladministrationgui" &&
184 $this->tpl->printToStdout();
193 $this->
ctrl->redirectByClass(\
ILIAS\SurveyQuestionPool\
Settings\SettingsGUI::class);
202 $qids = $this->edit_request->getQuestionIds();
203 if (count($qids) > 0) {
204 foreach ($qids as $key => $value) {
205 $this->
object->copyToClipboard($value);
207 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_copy_insert_clipboard"),
true);
209 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_copy_select_none"),
true);
211 $this->
ctrl->redirect($this,
"questions");
219 $qids = $this->edit_request->getQuestionIds();
220 if (count($qids) > 0) {
221 foreach ($qids as $key => $value) {
222 $this->
object->moveToClipboard($value);
224 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_move_insert_clipboard"),
true);
226 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_move_select_none"),
true);
228 $this->
ctrl->redirect($this,
"questions");
236 $qids = $this->edit_request->getQuestionIds();
237 if (count($qids) > 0) {
238 $this->createExportFileObject($qids);
240 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_export_select_none"));
247 $qids = $this->
http->wrapper()->query()->retrieve(
249 $this->
refinery->custom()->transformation(
function (
string $value) {
250 $value = urldecode($value);
251 return explode(
',', $value);
254 $this->createExportFileObject($qids);
265 $checked_questions = $this->edit_request->getQuestionIds();
266 if (count($checked_questions) === 0) {
267 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_delete_select_none"));
273 $cgui->setHeaderText($this->
lng->txt(
"qpl_confirm_delete_questions"));
275 $cgui->setFormAction($this->
ctrl->getFormAction($this));
276 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDeleteQuestions");
277 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmDeleteQuestions");
279 $infos = $this->
object->getQuestionInfos($checked_questions);
280 foreach ($infos as
$data) {
281 $txt = $data[
"title"] .
" (" .
283 if ($data[
"description"]) {
284 $txt .=
"<div class=\"small\">" . $data[
"description"] .
"</div>";
287 $cgui->addItem(
"q_id[]", $data[
"id"],
$txt);
290 $this->tpl->setContent($cgui->getHTML());
296 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"qpl_questions_deleted"),
true);
297 $qids = $this->edit_request->getQuestionIds();
298 foreach ($qids as $q_id) {
299 $this->
object->removeQuestion($q_id);
301 $this->
ctrl->redirect($this,
"questions");
307 $this->
ctrl->redirect($this,
"questions");
315 $clip_questions = $this->edit_manager->getQuestionsFromClipboard();
316 if (count($clip_questions) > 0) {
317 $this->
object->pasteFromClipboard();
319 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"spl_paste_no_objects"),
true);
321 $this->
ctrl->redirect($this,
"questions");
337 $form->setFormAction($this->
ctrl->getFormAction($this,
"uploadQuestions"));
338 $form->setTitle($this->
lng->txt(
"import_question"));
342 $fi->setRequired(
true);
345 $form->addCommandButton(
"uploadQuestions", $this->
lng->txt(
"import"));
346 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
356 if ($form->checkInput()) {
358 $source = $_FILES[
"qtidoc"][
"tmp_name"];
360 if (($source ===
'none') || (!$source) || $_FILES[
"qtidoc"][
"error"] > UPLOAD_ERR_OK) {
364 if (!
$error && strpos(
"xml", $_FILES[
"qtidoc"][
"type"]) !==
false) {
370 $this->
object->createImportDirectory();
373 $full_path = $this->
object->getImportDirectory() .
"/" . $_FILES[
"qtidoc"][
"name"];
376 $_FILES[
"qtidoc"][
"tmp_name"],
377 $_FILES[
"qtidoc"][
"name"],
380 $source = $full_path;
381 $this->
object->importObject($source,
true);
384 $this->
ctrl->redirect($this,
"questions");
386 $form->setValuesByPost();
395 $table_gui->writeFilterToSession();
396 $this->
ctrl->redirect($this,
'questions');
402 $table_gui->resetFilter();
403 $this->
ctrl->redirect($this,
'questions');
411 $this->tabs_gui->activateTab(
"survey_questions");
415 $this->
object->purgeQuestions();
419 $qtypes->setValue($ilUser->getPref(
"svy_lastquestiontype"));
420 $ilToolbar->addInputItem($qtypes);
424 $options[
$data[
"type_tag"]] = $translation;
426 $qtypes->setOptions($options);
428 $ilToolbar->setFormAction($this->
ctrl->getFormAction($this));
431 $this->
lng->txt(
"svy_create_question"),
433 )->submit()->toToolbar();
435 $ilToolbar->addSeparator();
446 $arrFilter = array();
447 foreach ($table_gui->getFilterItems() as $item) {
448 if ($item->getValue() !==
false) {
449 $arrFilter[$item->getPostVar()] = $item->getValue();
452 $table_gui->setData($this->
object->getQuestionsData($arrFilter));
453 $this->tpl->setContent($table_gui->getHTML());
458 $this->update = $this->
object->update();
459 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
465 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_added"),
true);
468 "&baseClass=ilObjSurveyQuestionPoolGUI");
477 $export->listExportFiles();
483 public function createExportFileObject($questions = null):
void 490 $survey_exp->buildExportFile($questions);
491 $this->
ctrl->redirect($this,
"export");
499 $files = $this->edit_request->getFiles();
500 if (count($files) === 0) {
501 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
502 $this->
ctrl->redirect($this,
"export");
505 if (count($files) > 1) {
506 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"select_max_one_item"),
true);
507 $this->
ctrl->redirect($this,
"export");
511 $export_dir = $this->
object->getExportDirectory();
513 $file = basename($files[0]);
523 $files = $this->edit_request->getFiles();
524 if (count($files) === 0) {
525 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
526 $this->
ctrl->redirect($this,
"export");
529 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
"info_delete_sure"));
531 $export_dir = $this->
object->getExportDirectory();
533 foreach ($files as $exp_file) {
534 $file_arr = explode(
"__", $exp_file);
535 $data[] = array(
'file' => $exp_file,
537 'size' => filesize($export_dir .
"/" . $exp_file)
540 $table_gui->setData(
$data);
541 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
547 $this->
ctrl->redirect($this,
"export");
552 $export_dir = $this->
object->getExportDirectory();
553 $files = $this->edit_request->getFiles();
554 foreach ($files as $file) {
555 $file = basename($file);
557 $exp_file = $export_dir .
"/" . $file;
558 $exp_dir = $export_dir .
"/" . substr($file, 0, -4);
559 if (is_file($exp_file)) {
562 if (is_dir($exp_dir)) {
566 $this->
ctrl->redirect($this,
"export");
577 "svy_lastquestiontype",
578 $this->edit_request->getSelectedQuestionTypes()
582 $this->edit_request->getSelectedQuestionTypes()
584 $q_gui->object->setObjId($this->
object->getId());
585 $q_gui->object->createNewQuestion();
587 $this->
ctrl->setParameterByClass(get_class($q_gui),
"q_id", $q_gui->object->getId());
588 $this->
ctrl->setParameterByClass(
590 "sel_question_types",
591 $this->edit_request->getSelectedQuestionTypes()
593 $this->
ctrl->redirectByClass(get_class($q_gui),
"editQuestion");
603 $this->edit_request->getPreview()
605 $this->
ctrl->setParameterByClass(get_class($q_gui),
"sel_question_types", $q_gui->getQuestionType());
606 $this->
ctrl->setParameterByClass(get_class($q_gui),
"q_id", $this->edit_request->getPreview());
607 $this->
ctrl->redirectByClass(get_class($q_gui),
"preview");
615 $this->
ctrl->redirectByClass(ilInfoScreenGUI::class,
"showSummary");
628 $info->enablePrivateNotes();
631 $info->addMetaDataSections($this->
object->getId(), 0, $this->
object->getType());
633 $this->
ctrl->forwardCommand($info);
636 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
638 $unzip = $this->archives->unzip(Streams::ofResource(fopen($file_to_import,
'r')));
639 # If export contains a manifest xml use standard import 640 if (in_array(basename($file_to_import,
".zip") . DIRECTORY_SEPARATOR .
"manifest.xml", iterator_to_array($unzip->getFiles()))) {
641 parent::importFile($file_to_import, $path_to_uploaded_file_in_temp_dir);
647 $newObj->setTitle(
"dummy");
648 $newObj->create(
true);
652 $newObj->importObject($file_to_import);
654 if ($path_to_uploaded_file_in_temp_dir !==
'' 655 && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
656 $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
660 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_imported"),
true);
662 "&baseClass=ilObjSurveyQuestionPoolGUI");
668 switch ($this->
ctrl->getCmd()) {
674 $ilLocator->addItem($this->
object->getTitle(), $this->
ctrl->getLinkTarget($this,
""),
"", $this->edit_request->getRefId());
677 if ($this->edit_request->getQuestionId() > 0) {
678 $q_id = $this->edit_request->getQuestionId();
683 $this->
ctrl->setParameterByClass($q_type,
"q_id", $q_id);
686 $this->
ctrl->getLinkTargetByClass($q_type,
"editQuestion")
698 $this->tabs_gui->addTab(
700 $this->
lng->txt(
"survey_questions"),
701 $this->
ctrl->getLinkTarget($this,
'questions')
704 $this->tabs_gui->addTab(
706 $this->
lng->txt(
"info_short"),
707 $this->
ctrl->getLinkTarget($this,
"infoScreen")
712 $this->tabs_gui->addTab(
714 $this->
lng->txt(
"settings"),
715 $this->
ctrl->getLinkTargetByClass(\
ILIAS\SurveyQuestionPool\
Settings\SettingsGUI::class)
720 $mdtab = $mdgui->getTab();
722 $this->tabs_gui->addTab(
724 $this->
lng->txt(
"meta_data"),
730 $this->tabs_gui->addTab(
732 $this->
lng->txt(
"export"),
733 $this->
ctrl->getLinkTarget($this,
'export')
738 $this->tabs_gui->addTab(
740 $this->
lng->txt(
"perm_settings"),
741 $this->
ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm")
751 $obligatory = $this->edit_request->getObligatory();
752 $this->
object->setObligatoryStates($obligatory);
754 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
755 $this->
ctrl->redirect($this,
"questions");
761 public static function _goto(
string $a_target): void
764 $main_tpl = $DIC->ui()->mainTemplate();
766 $ctrl = $DIC->ctrl();
767 $ilAccess = $DIC->access();
768 $lng = $DIC->language();
770 if ($ilAccess->checkAccess(
"visible",
"", $a_target) ||
771 $ilAccess->checkAccess(
"read",
"", $a_target)) {
775 $main_tpl->setOnScreenMessage(
'failure', sprintf(
776 $lng->
txt(
"msg_no_perm_read_item"),
Class ilObjSurveyQuestionPoolGUI.
cancelDeleteQuestionsObject()
importQuestionsObject()
display the import form to import questions into the question pool
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
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...
Class ilObjSurveyQuestionPool.
confirmDeleteExportFileObject()
confirmation screen for export file deletion
GUI class for the workflow of copying objects.
ILIAS SurveyQuestionPool InternalGUIService $gui
copyObject()
Copies checked questions in the questionpool to a clipboard.
exportObject()
list all export files
EditingGUIRequest $edit_request
prepareOutput(bool $show_sub_objects=true)
Interface Observer Contains several chained tasks and infos about them.
RefineryFactory $refinery
saveObligatoryObject()
Save obligatory states.
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
cancelDeleteExportFileObject()
exportQuestionExportTabObject()
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)
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
deleteUploadedImportFile(string $path_to_uploaded_file_in_temp_dir)
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
static http()
Fetches the global http state from ILIAS.
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...
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()
__construct(Container $dic, ilPlugin $plugin)
static _getQuestiontypes()
Get all available question types.
uploadQuestionsObject()
imports question(s) into the questionpool
questionsObject()
list questions of question pool
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.