30 protected \ILIAS\Survey\InternalDomainService
$domain;
31 protected \ILIAS\Survey\InternalGUIService
$gui;
52 $this->rbacsystem =
$DIC->rbac()->system();
53 $this->
user = $DIC->user();
54 $this->
access = $DIC->access();
55 $this->tree =
$DIC->repositoryTree();
56 $this->
toolbar = $DIC->toolbar();
59 $ilCtrl =
$DIC->ctrl();
62 $this->request =
$DIC->surveyQuestionPool()
70 $this->
ctrl = $ilCtrl;
71 $this->
ctrl->saveParameter($this,
"q_id");
72 $this->
ctrl->setParameterByClass(
73 $this->
ctrl->getCmdClass(),
75 $this->request->getSelectedQuestionTypes()
77 $this->cumulated = array();
78 $this->
tabs = $DIC->tabs();
83 $this->
object->loadFromDb($a_id);
87 $this->edit_manager =
$DIC->surveyQuestionPool()
91 $this->gui =
$DIC->survey()->internal()->gui();
92 $this->domain =
$DIC->survey()->internal()->domain();
101 $cmd = $this->
ctrl->getCmd();
102 $next_class = $this->
ctrl->getNextClass($this);
103 switch ($next_class) {
105 $ret = $this->$cmd();
108 return (
string) $ret;
116 ?
string $questiontype,
117 int $question_id = -1
119 if ((!$questiontype) and ($question_id > 0)) {
123 $question_type_gui = $questiontype .
"GUI";
124 $question =
new $question_type_gui($question_id);
145 return $this->
object->getQuestionType();
150 $questiontext = $this->
object->getQuestiontext();
151 if (preg_match(
"/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches)) {
152 $questiontext = $matches[1];
154 $template->
setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
155 if ($this->
object->getObligatory()) {
162 $this->parent_url = $a_url;
167 $rbacsystem = $this->rbacsystem;
168 $ilTabs = $this->tabs;
170 $this->
ctrl->setParameterByClass($guiclass,
"sel_question_types", $this->getQuestionType());
171 $this->
ctrl->setParameterByClass(
174 $this->request->getQuestionId()
177 if ($this->parent_url) {
179 if ($this->request->getNewForSurvey() > 0) {
180 $addurl =
"&new_id=" . $this->request->getQuestionId();
182 $ilTabs->setBackTarget($this->
lng->txt(
"menubacktosurvey"), $this->parent_url . $addurl);
184 $ilTabs->setBackTarget($this->
lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
186 if ($this->request->getQuestionId()) {
187 $ilTabs->addNonTabbedLink(
189 $this->
lng->txt(
"preview"),
190 $this->ctrl->getLinkTargetByClass($guiclass,
"preview")
194 if ($rbacsystem->
checkAccess(
'edit', $this->request->getRefId())) {
197 $this->
lng->txt(
"properties"),
198 $this->ctrl->getLinkTargetByClass($guiclass,
"editQuestion")
201 if (stripos($guiclass,
"matrix") !==
false) {
204 $this->
lng->txt(
"layout"),
205 $this->ctrl->getLinkTargetByClass($guiclass,
"layout")
210 if ($this->
object->getId() > 0) {
211 $title = $this->
lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
213 $title = $this->
lng->txt(
"create_new") .
" " . $this->
lng->txt($this->getQuestionType());
216 $this->tpl->setVariable(
"HEADER", $title);
227 $form->setFormAction($this->
ctrl->getFormAction($this,
"save"));
228 $form->setTitle($this->
lng->txt($this->getQuestionType()));
229 $form->setMultipart(
false);
230 $form->setTableWidth(
"100%");
235 $title->setMaxLength(200);
236 $title->setRequired(
true);
237 $form->addItem($title);
241 $label->setInfo($this->
lng->txt(
"label_info"));
242 $title->setMaxLength(255);
243 $label->setRequired(
false);
244 $form->addItem($label);
248 $author->setRequired(
true);
249 $title->setMaxLength(100);
250 $form->addItem($author);
253 $description =
new ilTextInputGUI($this->
lng->txt(
"description"),
"description");
254 $description->setRequired(
false);
255 $title->setMaxLength(200);
256 $form->addItem($description);
260 $question->setRequired(
true);
261 $question->setRows(10);
262 $question->setCols(80);
264 $question->setUseRte(
true);
265 $question->setRteTagSet(
"mini");
267 $form->addItem($question);
271 $shuffle->setValue(1);
272 $shuffle->setRequired(
false);
273 $form->addItem($shuffle);
275 $this->addFieldsToEditForm($form);
277 $this->addCommandButtons($form);
280 $title->setValue($this->
object->getTitle());
281 $label->setValue($this->
object->label);
282 $author->setValue($this->
object->getAuthor());
283 $description->setValue($this->
object->getDescription());
284 $question->setValue($this->
object->prepareTextareaOutput($this->object->getQuestiontext()));
285 $shuffle->setChecked($this->
object->getObligatory());
303 $ilTabs = $this->tabs;
305 $ilTabs->activateTab(
"edit_properties");
308 $a_form = $this->initEditForm();
310 $this->tpl->setContent($a_form->getHTML());
315 $this->save($this->request->getReturn(),
true);
325 $form = $this->initEditForm();
326 if ($form->checkInput() && $this->validateEditForm($form)) {
327 $this->
object->setTitle($form->getInput(
"title"));
328 $this->
object->label = ($form->getInput(
"label"));
329 $this->
object->setAuthor($form->getInput(
"author"));
330 $this->
object->setDescription($form->getInput(
"description"));
333 $question = $form->getInput(
"question");
335 $question = $purifier->purify($question);
337 $this->
object->setQuestiontext($question);
338 $this->
object->setObligatory($form->getInput(
"obligatory"));
340 $this->importEditFormValues($form);
343 $this->
object->saveToDb();
348 $form->setValuesByPost();
349 $this->editQuestion($form);
354 bool $a_return =
false,
357 $ilUser = $this->
user;
359 if ($this->saveForm()) {
363 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"survey_error_insert_incomplete_question"));
364 $this->editQuestion();
368 $ilUser->setPref(
"svy_lastquestiontype", $this->
object->getQuestionType());
369 $ilUser->writePref(
"svy_lastquestiontype", $this->
object->getQuestionType());
372 $this->
ctrl->setParameter($this,
"q_id", $this->
object->getId());
376 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
377 $this->
ctrl->redirect($this,
'copySyncForm');
378 } elseif ($originalexists &&
382 $this->
ctrl->setParameter($this,
'rtrn', 1);
384 $this->
ctrl->redirect($this,
'originalSyncForm');
388 if ($this->request->getNewForSurvey() > 0) {
389 $survey =
new ilObjSurvey($this->request->getNewForSurvey());
390 $this->domain->sequence(
391 $survey->getSurveyId(),
393 )->appendQuestion($this->
object->getId());
396 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
397 $this->redirectAfterSaving($a_return);
403 $ilTabs = $this->tabs;
405 $ilTabs->activateTab(
"edit_properties");
409 $this->tpl->setContent($tbl->getHTML());
415 $ilAccess = $this->access;
417 $qids = $this->request->getQuestionIds();
418 if (count($qids) === 0) {
419 $this->tpl->setOnScreenMessage(
'failure',
$lng->txt(
"select_one"));
420 $this->copySyncForm();
424 foreach ($this->
object->getCopyIds(
true) as $survey_id => $questions) {
428 foreach ($ref_ids as
$ref_id) {
429 if ($ilAccess->checkAccess(
"edit",
"",
$ref_id)) {
436 foreach ($questions as $qid) {
437 if (in_array($qid, $qids)) {
438 $id = $this->
object->getId();
440 $this->
object->setId($qid);
441 $this->
object->setOriginalId(
$id);
442 $this->
object->saveToDb();
444 $this->
object->setId(
$id);
445 $this->
object->setOriginalId(
null);
454 $this->tpl->setOnScreenMessage(
'success',
$lng->txt(
"survey_sync_success"),
true);
455 $this->redirectAfterSaving($this->request->getReturn());
460 $ilTabs = $this->tabs;
462 $ilTabs->activateTab(
"edit_properties");
464 $this->
ctrl->saveParameter($this,
"rtrn");
467 $cgui->setHeaderText($this->
lng->txt(
"confirm_sync_questions"));
469 $cgui->setFormAction($this->
ctrl->getFormAction($this,
"confirmRemoveQuestions"));
470 $cgui->setCancel($this->
lng->txt(
"no"),
"cancelSync");
471 $cgui->setConfirm($this->
lng->txt(
"yes"),
"sync");
473 $this->tpl->setContent($cgui->getHTML());
476 protected function sync(): void
478 $original_id = $this->
object->original_id;
480 $this->
object->syncWithOriginal();
483 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
484 $this->redirectAfterSaving($this->request->getReturn());
489 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"question_changed_in_survey_only"),
true);
490 $this->redirectAfterSaving($this->request->getReturn());
497 bool $a_return =
false
502 if ($this->parent_url) {
504 if ($this->request->getNewForSurvey() > 0) {
505 $addurl =
"&new_id=" . $this->request->getQuestionId();
511 $this->
ctrl->redirectByClass(
"ilObjSurveyQuestionPoolGUI",
"questions");
516 $this->
ctrl->setParameterByClass(
517 $this->
ctrl->getCmdClass(),
519 $this->object->getId()
521 $this->
ctrl->setParameterByClass(
522 $this->
ctrl->getCmdClass(),
523 "sel_question_types",
524 $this->request->getSelectedQuestionTypes()
526 $this->
ctrl->setParameterByClass(
527 $this->
ctrl->getCmdClass(),
529 $this->request->getNewForSurvey()
531 $this->
ctrl->redirectByClass($this->
ctrl->getCmdClass(),
"editQuestion");
537 if ($this->parent_url) {
540 $this->
ctrl->redirectByClass(
"ilobjsurveyquestionpoolgui",
"questions");
554 int $question_title = 1,
555 bool $show_questiontext =
true,
556 ?
int $survey_id =
null,
557 ?array $working_data =
null
561 int $question_title = 1
564 switch ($question_title) {
569 #19448 get rid of showing only the label without title
576 if (trim($this->
object->getLabel())) {
587 int $question_title_mode = 1
590 switch ($question_title_mode) {
592 $title = $this->
object->getTitle();
596 $title = $this->
object->getTitle();
597 if (trim($this->
object->getLabel())) {
598 $title .=
' <span class="questionLabel">(' .
599 $this->
object->getLabel()
609 $ilTabs = $this->tabs;
611 $ilTabs->activateTab(
"preview");
613 $tpl =
new ilTemplate(
"tpl.il_svy_qpl_preview.html",
true,
true,
"components/ILIAS/SurveyQuestionPool");
615 if ($this->
object->getObligatory()) {
617 $tpl->
setVariable(
"TEXT_REQUIRED", $this->
lng->txt(
"required_field"));
621 $tpl->
setVariable(
"QUESTION_OUTPUT", $this->getWorkingForm());
623 $f = $this->gui->ui()->factory();
624 $r = $this->gui->ui()->renderer();
625 $p =
$f->panel()->standard(
627 $f->legacy()->content($tpl->
get())
630 $this->tpl->setContent($r->render($p));
639 ?array $working_data =
null,
640 int $question_title = 1,
641 bool $show_questiontext =
true,
642 string $error_message =
"",
643 ?
int $survey_id =
null,
644 bool $compress_view =
false
651 ?array $a_foot =
null
654 $html[] =
'<div class="ilTableOuter table-responsive">';
655 $html[] =
'<table class="table table-striped">';
659 foreach ($a_head as $col) {
662 $html[] = ($col !=
"") ? $col :
" ";
666 $html[] =
"</thead>";
669 foreach ($a_rows as $row) {
671 foreach ($row as $col) {
674 $html[] = ($col !=
"") ? $col :
" ";
679 $html[] =
"</tbody>";
684 foreach ($a_foot as $col) {
687 $html[] = ($col !=
"") ? $col :
" ";
691 $html[] =
"</tfoot>";
694 $html[] =
"</table>";
696 return implode(
"\n", $html);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setVariable($variable, $value='')
Sets a variable value.
Manages editing processes/repos.
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
renderStatisticsDetailsTable(array $a_head, array $a_rows, ?array $a_foot=null)
getPrintViewQuestionTitle(int $question_title=1)
setBackUrl(string $a_url)
ilGlobalTemplateInterface $tpl
save(bool $a_return=false, bool $a_sync=false)
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.
ILIAS Survey InternalDomainService $domain
outQuestionText(ilTemplate $template)
addFieldsToEditForm(ilPropertyFormGUI $a_form)
getQuestionTitle(int $question_title_mode=1)
getWorkingForm(?array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", ?int $survey_id=null, bool $compress_view=false)
addCommandButtons(ilPropertyFormGUI $a_form)
ILIAS Survey InternalGUIService $gui
EditManager $edit_manager
editQuestion(?ilPropertyFormGUI $a_form=null)
getQuestionType()
Returns the question type string.
validateEditForm(ilPropertyFormGUI $a_form)
static _getGUIClassNameForId(int $a_q_id)
EditingGUIRequest $request
getPrintView(int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
static _getClassNameForQType(string $q_type)
setQuestionTabsForClass(string $guiclass)
importEditFormValues(ilPropertyFormGUI $a_form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _isWriteable(int $question_id, int $user_id)
is question writeable by a certain user
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
static _questionExists(int $question_id)
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
static _isComplete(int $question_id)
Checks whether the question is complete or not.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
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 ...
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...
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static redirect(string $a_script)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
if(!file_exists('../ilias.ini.php'))