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" &&
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) {
279 $txt = $data[
"title"] .
" (" .
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"));
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();
764 $ctrl = $DIC->ctrl();
765 $ilAccess = $DIC->access();
766 $lng = $DIC->language();
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"),
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
confirmDeleteQuestionsObject()
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...
setContent(string $a_html)
Sets content for standard template.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
propertiesObject(?ilPropertyFormGUI $a_form=null)
Edit question pool properties.
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()
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
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
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
Last visited history for repository items.
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.
infoScreenForward()
show information screen
filterQuestionBrowserObject()
__construct(Container $dic, ilPlugin $plugin)
static _getQuestiontypes()
Get all available question types.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
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.