ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssConfigurableMultiOptionQuestionFeedback.php
Go to the documentation of this file.
1<?php
2
32{
33 public const FEEDBACK_SETTING_ALL = 1;
34 public const FEEDBACK_SETTING_CHECKED = 2;
35 public const FEEDBACK_SETTING_CORRECT = 3;
36
37 abstract protected function getSpecificQuestionTableName(): string;
38
40 {
41 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
42 $header = new ilFormSectionHeaderGUI();
43 $header->setTitle($this->lng->txt('feedback_answers'));
44 $form->addItem($header);
45
46 $feedback = new ilRadioGroupInputGUI($this->lng->txt('feedback_setting'), 'feedback_setting');
47 $feedback->addOption(
48 new ilRadioOption($this->lng->txt('feedback_all'), self::FEEDBACK_SETTING_ALL)
49 );
50 $feedback->addOption(
51 new ilRadioOption($this->lng->txt('feedback_checked'), self::FEEDBACK_SETTING_CHECKED)
52 );
53 $feedback->addOption(
54 new ilRadioOption($this->lng->txt($this->questionOBJ->getSpecificFeedbackAllCorrectOptionLabel()), self::FEEDBACK_SETTING_CORRECT)
55 );
56
57 $feedback->setRequired(true);
58 $form->addItem($feedback);
59
60 foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
62 $this->buildAnswerOptionLabel($index, $answer),
63 true
64 );
65
66 $propertyPostVar = "feedback_answer_$index";
67
69 $propertyLabel,
70 $propertyPostVar,
71 $this->questionOBJ->isAdditionalContentEditingModePageObject()
72 ));
73 }
74 }
75 }
76
77 public function initSpecificFormProperties(ilPropertyFormGUI $form): void
78 {
79 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
80 $form->getItemByPostVar('feedback_setting')->setValue(
81 $this->questionOBJ->getSpecificFeedbackSetting()
82 );
83
84 foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
85 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
88 $this->getSpecificAnswerFeedbackPageObjectId($this->questionOBJ->getId(), 0, $index)
89 );
90 } else {
92 $this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), 0, $index)
93 );
94 }
95
96 $form->getItemByPostVar("feedback_answer_$index")->setValue($value);
97 }
98 }
99 }
100
102 {
103 $feedback_setting = $form->getInput('feedback_setting');
104
105 /* sk 03.03.2023: This avoids Problems with questions in Learning Module
106 * See: https://mantis.ilias.de/view.php?id=34724
107 */
108 if ($feedback_setting === '') {
109 return;
110 }
111
112 $this->saveSpecificFeedbackSetting($this->questionOBJ->getId(), (int) $feedback_setting);
113
114 if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
115 foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
117 $this->questionOBJ->getId(),
118 0,
119 $index,
120 (string) ($form->getInput("feedback_answer_$index") ?? '')
121 );
122 }
123 }
124 }
125
130 public function isSaveableInPageObjectEditingMode(): bool
131 {
132 return true;
133 }
134
139 public function saveSpecificFeedbackSetting(int $questionId, int $specificFeedbackSetting): void
140 {
141 $this->db->update(
143 ['feedback_setting' => ['integer', $specificFeedbackSetting]],
144 ['question_fi' => ['integer', $questionId]]
145 );
146 }
147
148 protected function cloneSpecificFeedback(int $source_question_id, int $target_question_id): void
149 {
150 $this->cloneSpecificFeedbackSetting($source_question_id, $target_question_id);
151 parent::cloneSpecificFeedback($source_question_id, $target_question_id);
152 }
153
154 private function cloneSpecificFeedbackSetting(int $source_question_id, int $target_question_id): void
155 {
156 $res = $this->db->queryF(
157 "SELECT feedback_setting FROM {$this->getSpecificQuestionTableName()} WHERE question_fi = %s",
158 ['integer'],
159 [$source_question_id]
160 );
161
162 $row = $this->db->fetchAssoc($res);
163
164 if ($this->db->numRows($res) < 1) {
165 return;
166 }
167
168 $this->db->update(
170 [ 'feedback_setting' => ['integer', $row['feedback_setting']] ],
171 [ 'question_fi' => ['integer', $target_question_id] ]
172 );
173 }
174}
initSpecificFormProperties(ilPropertyFormGUI $form)
initialises a given form object's specific form properties relating to this question type
isSaveableInPageObjectEditingMode()
returns the fact that the feedback editing form is saveable in page object editing mode,...
cloneSpecificFeedback(int $source_question_id, int $target_question_id)
duplicates the SPECIFIC feedback relating to the given original question id and saves it for the give...
saveSpecificFeedbackSetting(int $questionId, int $specificFeedbackSetting)
saves the given specific feedback setting for the given question id to the db.
completeSpecificFormProperties(ilPropertyFormGUI $form)
completes a given form object with the specific form properties required by this question type
cloneSpecificFeedbackSetting(int $source_question_id, int $target_question_id)
saveSpecificFormProperties(ilPropertyFormGUI $form)
saves a given form object's SPECIFIC form properties relating to this question type
getSpecificAnswerFeedbackContent(int $question_id, int $question_index, int $answer_index)
saveSpecificAnswerFeedbackContent(int $question_id, int $question_index, int $answer_index, string $feedback_content)
getSpecificAnswerFeedbackPageObjectId(int $question_id, int $question_index, int $answer_index)
returns a useable page object id for specific answer feedback page objects for the given question id ...
buildFeedbackContentFormProperty(string $label, string $post_var, bool $as_non_editable)
builds and returns a form property gui object with the given label and postvar that is addable to pro...
getPageObjectNonEditableValueHTML(string $page_object_type, int $page_object_id)
returns html content to be used as value for non editable value form properties in feedback editing f...
This class represents a section header in a property form.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
This class represents a property in a property form.
This class represents an option in a radio group.
$res
Definition: ltiservices.php:69