ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAssConfigurableMultiOptionQuestionFeedback.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssMultiOptionQuestionFeedback.php';
5
19{
23
29 abstract protected function getSpecificQuestionTableName();
30
41 {
42 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
44 $header->setTitle($this->lng->txt('feedback_answers'));
45 $form->addItem($header);
46
47 require_once './Services/Form/classes/class.ilRadioGroupInputGUI.php';
48 require_once './Services/Form/classes/class.ilRadioOption.php';
49
50 $feedback = new ilRadioGroupInputGUI($this->lng->txt('feedback_setting'), 'feedback_setting');
51 $feedback->addOption(
52 new ilRadioOption($this->lng->txt('feedback_all'), self::FEEDBACK_SETTING_ALL),
53 true
54 );
55 $feedback->addOption(
56 new ilRadioOption($this->lng->txt('feedback_checked'), self::FEEDBACK_SETTING_CHECKED)
57 );
58 $feedback->addOption(
59 new ilRadioOption($this->lng->txt($this->questionOBJ->getSpecificFeedbackAllCorrectOptionLabel()), self::FEEDBACK_SETTING_CORRECT)
60 );
61
62 $feedback->setRequired(true);
63 $form->addItem($feedback);
64
65 foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
66 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
67 $this->buildAnswerOptionLabel($index, $answer),
68 true
69 );
70
71 $propertyPostVar = "feedback_answer_$index";
72
74 $propertyLabel,
75 $propertyPostVar,
76 $this->questionOBJ->isAdditionalContentEditingModePageObject()
77 ));
78 }
79 }
80 }
81
92 {
93 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
94 $form->getItemByPostVar('feedback_setting')->setValue(
95 $this->questionOBJ->getSpecificFeedbackSetting()
96 );
97
98 foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
99 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
100 $value = $this->getPageObjectNonEditableValueHTML(
102 $this->getSpecificAnswerFeedbackPageObjectId($this->questionOBJ->getId(), $index)
103 );
104 } else {
105 $value = $this->questionOBJ->prepareTextareaOutput(
106 $this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), $index)
107 );
108 }
109
110 $form->getItemByPostVar("feedback_answer_$index")->setValue($value);
111 }
112 }
113 }
114
125 {
126 $this->saveSpecificFeedbackSetting($this->questionOBJ->getId(), $form->getInput('feedback_setting'));
127
128 if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
129 foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
131 $this->questionOBJ->getId(),
132 $index,
133 $form->getInput("feedback_answer_$index")
134 );
135 }
136 }
137 }
138
147 {
148 return true;
149 }
150
158 public function saveSpecificFeedbackSetting($questionId, $specificFeedbackSetting)
159 {
160 $this->db->update(
162 array('feedback_setting' => array('integer', $specificFeedbackSetting)),
163 array('question_fi' => array('integer', $questionId))
164 );
165 }
166
177 protected function duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId)
178 {
179 // sync specific feedback setting to duplicated question
180
181 $this->syncSpecificFeedbackSetting($originalQuestionId, $duplicateQuestionId);
182
183 // sync specific answer feedback to duplicated question
184
185 $res = $this->db->queryF(
186 "SELECT * FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s",
187 array('integer'),
188 array($originalQuestionId)
189 );
190
191 while ($row = $this->db->fetchAssoc($res)) {
192 $nextId = $this->db->nextId($this->getSpecificFeedbackTableName());
193
194 $this->db->insert($this->getSpecificFeedbackTableName(), array(
195 'feedback_id' => array('integer', $nextId),
196 'question_fi' => array('integer', $duplicateQuestionId),
197 'answer' => array('integer', $row['answer']),
198 'feedback' => array('text', $row['feedback']),
199 'tstamp' => array('integer', time())
200 ));
201
202 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
203 $pageObjectType = $this->getSpecificAnswerFeedbackPageObjectType();
204 $this->duplicatePageObject($pageObjectType, $row['feedback_id'], $nextId, $duplicateQuestionId);
205 }
206 }
207 }
208
218 protected function syncSpecificFeedback($originalQuestionId, $duplicateQuestionId)
219 {
220 // sync specific feedback setting to the original
221 $this->syncSpecificFeedbackSetting($duplicateQuestionId, $originalQuestionId);
222
223 // delete specific feedback of the original
224 $this->db->manipulateF(
225 "DELETE FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s",
226 array('integer'),
227 array($originalQuestionId)
228 );
229
230 // get specific feedback of the actual question
231 $res = $this->db->queryF(
232 "SELECT * FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s",
233 array('integer'),
234 array($duplicateQuestionId)
235 );
236
237 // save specific feedback to the original
238 while ($row = $this->db->fetchAssoc($res)) {
239 $nextId = $this->db->nextId($this->getSpecificFeedbackTableName());
240
241 $this->db->insert($this->getSpecificFeedbackTableName(), array(
242 'feedback_id' => array('integer', $nextId),
243 'question_fi' => array('integer', $originalQuestionId),
244 'answer' => array('integer',$row['answer']),
245 'feedback' => array('text',$row['feedback']),
246 'tstamp' => array('integer',time())
247 ));
248 }
249 }
250
251 private function syncSpecificFeedbackSetting($sourceQuestionId, $targetQuestionId)
252 {
253 $res = $this->db->queryF(
254 "SELECT feedback_setting FROM {$this->getSpecificQuestionTableName()} WHERE question_fi = %s",
255 array('integer'),
256 array($sourceQuestionId)
257 );
258
259 $row = $this->db->fetchAssoc($res);
260
261 $this->db->update(
263 array( 'feedback_setting' => array('integer', $row['feedback_setting']) ),
264 array( 'question_fi' => array('integer', $targetQuestionId) )
265 );
266 }
267}
An exception for terminatinating execution or to throw for unit testing.
initSpecificFormProperties(ilPropertyFormGUI $form)
initialises a given form object's specific form properties relating to this question type
syncSpecificFeedback($originalQuestionId, $duplicateQuestionId)
syncs the SPECIFIC feedback from a duplicated question back to the original question
isSaveableInPageObjectEditingMode()
returns the fact that the feedback editing form is saveable in page object editing mode,...
saveSpecificFeedbackSetting($questionId, $specificFeedbackSetting)
saves the given specific feedback setting for the given question id to the db.
getSpecificQuestionTableName()
returns the name of question specific table
duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId)
duplicates the SPECIFIC feedback relating to the given original question id and saves it for the give...
completeSpecificFormProperties(ilPropertyFormGUI $form)
completes a given form object with the specific form properties required by this question type
saveSpecificFormProperties(ilPropertyFormGUI $form)
saves a given form object's specific form properties relating to this question type
getSpecificAnswerFeedbackContent($questionId, $answerIndex)
returns the SPECIFIC answer feedback content for a given question id and answer index.
getSpecificAnswerFeedbackPageObjectId($questionId, $answerIndex)
returns a useable page object id for specific answer feedback page objects for the given question id ...
getAnswerOptionsByAnswerIndex()
returns the answer options mapped by answer index (can be overwritten by concrete question type class...
getSpecificFeedbackTableName()
returns the table name for specific feedback
saveSpecificAnswerFeedbackContent($questionId, $answerIndex, $feedbackContent)
saves SPECIFIC answer feedback content for the given question id and answer index to the database.
buildAnswerOptionLabel($index, $answer)
builds an answer option label from given (mixed type) index and answer (can be overwritten by concret...
getPageObjectNonEditableValueHTML($pageObjectType, $pageObjectId)
returns html content to be used as value for non editable value form properties in feedback editing f...
duplicatePageObject($pageObjectType, $originalPageObjectId, $duplicatePageObjectId, $duplicatePageObjectParentId)
duplicates the page object with given type and original id to new page object with same type and give...
getSpecificAnswerFeedbackPageObjectType()
returns the type for specific feedback page objects defined in local constant
buildFeedbackContentFormProperty($label, $postVar, $asNonEditable)
builds and returns a form property gui object with the given label and postvar that is addable to pro...
This class represents a section header in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
$index
Definition: metadata.php:60
if(isset($_POST['submit'])) $form
foreach($_POST as $key=> $value) $res