30 protected \ILIAS\Survey\InternalGUIService
$gui;
51 $this->rbacsystem = $DIC->rbac()->system();
52 $this->
user = $DIC->user();
53 $this->
access = $DIC->access();
54 $this->tree = $DIC->repositoryTree();
55 $this->
toolbar = $DIC->toolbar();
56 $lng = $DIC->language();
58 $ilCtrl = $DIC->ctrl();
61 $this->request = $DIC->surveyQuestionPool()
69 $this->
ctrl = $ilCtrl;
70 $this->
ctrl->saveParameter($this,
"q_id");
71 $this->
ctrl->setParameterByClass(
72 $this->
ctrl->getCmdClass(),
74 $this->request->getSelectedQuestionTypes()
76 $this->cumulated = array();
77 $this->
tabs = $DIC->tabs();
82 $this->
object->loadFromDb($a_id);
86 $this->edit_manager = $DIC->surveyQuestionPool()
90 $this->gui = $DIC->survey()->internal()->gui();
93 abstract protected function initObject(): void;
99 $cmd = $this->
ctrl->getCmd();
100 $next_class = $this->
ctrl->getNextClass($this);
101 switch ($next_class) {
103 $ret = $this->$cmd();
106 return (
string) $ret;
114 ?
string $questiontype,
115 int $question_id = -1
117 if ((!$questiontype) and ($question_id > 0)) {
121 $question_type_gui = $questiontype .
"GUI";
122 $question =
new $question_type_gui($question_id);
143 return $this->
object->getQuestionType();
148 $questiontext = $this->
object->getQuestiontext();
149 if (preg_match(
"/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches)) {
150 $questiontext = $matches[1];
152 $template->
setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
153 if ($this->
object->getObligatory()) {
160 $this->parent_url = $a_url;
168 $this->
ctrl->setParameterByClass($guiclass,
"sel_question_types", $this->
getQuestionType());
169 $this->
ctrl->setParameterByClass(
172 $this->request->getQuestionId()
175 if ($this->parent_url) {
177 if ($this->request->getNewForSurvey() > 0) {
178 $addurl =
"&new_id=" . $this->request->getQuestionId();
180 $ilTabs->setBackTarget($this->
lng->txt(
"menubacktosurvey"), $this->parent_url . $addurl);
182 $ilTabs->setBackTarget($this->
lng->txt(
"spl"), $this->
ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
184 if ($this->request->getQuestionId()) {
185 $ilTabs->addNonTabbedLink(
187 $this->
lng->txt(
"preview"),
188 $this->
ctrl->getLinkTargetByClass($guiclass,
"preview")
192 if ($rbacsystem->
checkAccess(
'edit', $this->request->getRefId())) {
195 $this->
lng->txt(
"properties"),
196 $this->
ctrl->getLinkTargetByClass($guiclass,
"editQuestion")
199 if (stripos($guiclass,
"matrix") !==
false) {
202 $this->
lng->txt(
"layout"),
203 $this->
ctrl->getLinkTargetByClass($guiclass,
"layout")
208 if ($this->
object->getId() > 0) {
209 $title = $this->
lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
214 $this->tpl->setVariable(
"HEADER", $title);
225 $form->setFormAction($this->
ctrl->getFormAction($this,
"save"));
226 $form->setTitle($this->
lng->txt($this->getQuestionType()));
227 $form->setMultipart(
false);
228 $form->setTableWidth(
"100%");
233 $title->setMaxLength(200);
234 $title->setRequired(
true);
235 $form->addItem($title);
239 $label->setInfo($this->
lng->txt(
"label_info"));
240 $title->setMaxLength(255);
241 $label->setRequired(
false);
242 $form->addItem($label);
246 $author->setRequired(
true);
247 $title->setMaxLength(100);
248 $form->addItem($author);
251 $description =
new ilTextInputGUI($this->
lng->txt(
"description"),
"description");
252 $description->setRequired(
false);
253 $title->setMaxLength(200);
254 $form->addItem($description);
259 $question->setRows(10);
260 $question->setCols(80);
262 $question->setUseRte(
true);
264 $question->addPlugin(
"latex");
265 $question->addButton(
"latex");
266 $question->addButton(
"pastelatex");
267 $question->setRTESupport($this->
object->getId(),
"spl",
"survey");
269 $form->addItem($question);
273 $shuffle->setValue(1);
274 $shuffle->setRequired(
false);
275 $form->addItem($shuffle);
282 $title->setValue($this->
object->getTitle());
283 $label->setValue($this->
object->label);
284 $author->setValue($this->
object->getAuthor());
285 $description->setValue($this->
object->getDescription());
286 $question->setValue($this->
object->prepareTextareaOutput($this->object->getQuestiontext()));
287 $shuffle->setChecked($this->
object->getObligatory());
312 $this->tpl->setContent($a_form->getHTML());
317 $this->
save($this->request->getReturn(),
true);
329 $this->
object->setTitle($form->getInput(
"title"));
330 $this->
object->label = ($form->getInput(
"label"));
331 $this->
object->setAuthor($form->getInput(
"author"));
332 $this->
object->setDescription($form->getInput(
"description"));
333 $this->
object->setQuestiontext($form->getInput(
"question"));
334 $this->
object->setObligatory($form->getInput(
"obligatory"));
339 $this->
object->saveToDb();
344 $form->setValuesByPost();
350 bool $a_return =
false,
359 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"survey_error_insert_incomplete_question"));
364 $ilUser->setPref(
"svy_lastquestiontype", $this->
object->getQuestionType());
365 $ilUser->writePref(
"svy_lastquestiontype", $this->
object->getQuestionType());
368 $this->
ctrl->setParameter($this,
"q_id", $this->
object->getId());
372 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
373 $this->
ctrl->redirect($this,
'copySyncForm');
374 } elseif ($originalexists &&
378 $this->
ctrl->setParameter($this,
'rtrn', 1);
380 $this->
ctrl->redirect($this,
'originalSyncForm');
383 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
396 $this->tpl->setContent($tbl->getHTML());
404 $qids = $this->request->getQuestionIds();
405 if (count($qids) === 0) {
406 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
"select_one"));
411 foreach ($this->
object->getCopyIds(
true) as $survey_id => $questions) {
415 foreach ($ref_ids as
$ref_id) {
416 if ($ilAccess->checkAccess(
"edit",
"", $ref_id)) {
423 foreach ($questions as $qid) {
424 if (in_array($qid, $qids)) {
425 $id = $this->
object->getId();
427 $this->
object->setId($qid);
428 $this->
object->setOriginalId(
$id);
429 $this->
object->saveToDb();
431 $this->
object->setId(
$id);
432 $this->
object->setOriginalId(null);
441 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"survey_sync_success"),
true);
451 $this->
ctrl->saveParameter($this,
"rtrn");
454 $cgui->setHeaderText($this->
lng->txt(
"confirm_sync_questions"));
456 $cgui->setFormAction($this->
ctrl->getFormAction($this,
"confirmRemoveQuestions"));
457 $cgui->setCancel($this->
lng->txt(
"no"),
"cancelSync");
458 $cgui->setConfirm($this->
lng->txt(
"yes"),
"sync");
460 $this->tpl->setContent($cgui->getHTML());
463 protected function sync(): void
465 $original_id = $this->
object->original_id;
467 $this->
object->syncWithOriginal();
470 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
476 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"question_changed_in_survey_only"),
true);
484 bool $a_return =
false 489 if ($this->parent_url) {
491 if ($this->request->getNewForSurvey() > 0) {
492 $addurl =
"&new_id=" . $this->request->getQuestionId();
498 $this->
ctrl->redirectByClass(
"ilObjSurveyQuestionPoolGUI",
"questions");
503 $this->
ctrl->setParameterByClass(
504 $this->
ctrl->getCmdClass(),
506 $this->
object->getId()
508 $this->
ctrl->setParameterByClass(
509 $this->
ctrl->getCmdClass(),
510 "sel_question_types",
511 $this->request->getSelectedQuestionTypes()
513 $this->
ctrl->setParameterByClass(
514 $this->
ctrl->getCmdClass(),
516 $this->request->getNewForSurvey()
518 $this->
ctrl->redirectByClass($this->
ctrl->getCmdClass(),
"editQuestion");
524 if ($this->parent_url) {
527 $this->
ctrl->redirectByClass(
"ilobjsurveyquestionpoolgui",
"questions");
541 int $question_title = 1,
542 bool $show_questiontext =
true,
543 ?
int $survey_id = null,
544 ?array $working_data = null
548 int $question_title = 1
551 switch ($question_title) {
556 #19448 get rid of showing only the label without title 563 if (trim($this->
object->getLabel())) {
574 int $question_title_mode = 1
577 switch ($question_title_mode) {
579 $title = $this->
object->getTitle();
583 $title = $this->
object->getTitle();
584 if (trim($this->
object->getLabel())) {
585 $title .=
' <span class="questionLabel">(' .
586 $this->
object->getLabel()
600 $tpl =
new ilTemplate(
"tpl.il_svy_qpl_preview.html",
true,
true,
"Modules/SurveyQuestionPool");
602 if ($this->
object->getObligatory()) {
604 $tpl->
setVariable(
"TEXT_REQUIRED", $this->
lng->txt(
"required_field"));
610 $f = $this->gui->ui()->factory();
611 $r = $this->gui->ui()->renderer();
612 $p =
$f->panel()->standard(
614 $f->legacy($tpl->
get())
617 $this->tpl->setContent(
$r->render($p));
626 array $working_data = null,
627 int $question_title = 1,
628 bool $show_questiontext =
true,
629 string $error_message =
"",
630 int $survey_id = null,
631 bool $compress_view =
false 641 $html[] =
'<div class="ilTableOuter table-responsive">';
642 $html[] =
'<table class="table table-striped">';
646 foreach ($a_head as $col) {
649 $html[] = ($col !=
"") ? $col :
" ";
653 $html[] =
"</thead>";
656 foreach ($a_rows as $row) {
658 foreach ($row as $col) {
661 $html[] = ($col !=
"") ? $col :
" ";
666 $html[] =
"</tbody>";
671 foreach ($a_foot as $col) {
674 $html[] = ($col !=
"") ? $col :
" ";
678 $html[] =
"</tfoot>";
681 $html[] =
"</table>";
683 return implode(
"\n", $html);
getQuestionTitle(int $question_title_mode=1)
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPrintViewQuestionTitle(int $question_title=1)
static _getAllReferences(int $id)
get all reference ids for object ID
EditManager $edit_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
getQuestionType()
Returns the question type string.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
setBackUrl(string $a_url)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
renderStatisticsDetailsTable(array $a_head, array $a_rows, array $a_foot=null)
getPrintView(int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
outQuestionText(ilTemplate $template)
static _isWriteable(int $question_id, int $user_id)
is question writeable by a certain user
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
EditingGUIRequest $request
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
static _isComplete(int $question_id)
Checks whether the question is complete or not.
setVariable($variable, $value='')
Sets a variable value.
setQuestionTabsForClass(string $guiclass)
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addFieldsToEditForm(ilPropertyFormGUI $a_form)
validateEditForm(ilPropertyFormGUI $a_form)
ilGlobalTemplateInterface $tpl
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
static _getClassNameForQType(string $q_type)
static _getGUIClassNameForId(int $a_q_id)
ILIAS Survey InternalGUIService $gui
static redirect(string $a_script)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
importEditFormValues(ilPropertyFormGUI $a_form)
activateTab(string $a_id)
save(bool $a_return=false, bool $a_sync=false)
addCommandButtons(ilPropertyFormGUI $a_form)
Manages editing processes/repos.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
editQuestion(ilPropertyFormGUI $a_form=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
static _lookupType(int $id, bool $reference=false)
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
getWorkingForm(array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
static _questionExists(int $question_id)