ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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() )
43 {
44 $header = new ilFormSectionHeaderGUI();
45 $header->setTitle($this->lng->txt('feedback_answers'));
46 $form->addItem($header);
47
48 require_once './Services/Form/classes/class.ilRadioGroupInputGUI.php';
49 require_once './Services/Form/classes/class.ilRadioOption.php';
50
51 $feedback = new ilRadioGroupInputGUI($this->lng->txt('feedback_setting'), 'feedback_setting');
52 $feedback->addOption(
53 new ilRadioOption($this->lng->txt('feedback_all'), self::FEEDBACK_SETTING_ALL), 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('feedback_correct'), self::FEEDBACK_SETTING_CORRECT)
60 );
61 $feedback->setRequired(true);
62 $form->addItem($feedback);
63
64 foreach( $this->getAnswerOptionsByAnswerIndex() as $index => $answer )
65 {
66 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
67 $this->buildAnswerOptionLabel($index, $answer), true
68 );
69
70 $propertyPostVar = "feedback_answer_$index";
71
73 $propertyLabel , $propertyPostVar, $this->questionOBJ->isAdditionalContentEditingModePageObject()
74 ));
75 }
76 }
77 }
78
89 {
90 if (!$this->questionOBJ->getSelfAssessmentEditingMode())
91 {
92 $form->getItemByPostVar('feedback_setting')->setValue(
93 $this->questionOBJ->getSpecificFeedbackSetting()
94 );
95
96 foreach( $this->getAnswerOptionsByAnswerIndex() as $index => $answer )
97 {
98 if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
99 {
100 $value = $this->getPageObjectNonEditableValueHTML(
102 $this->getSpecificAnswerFeedbackPageObjectId($this->questionOBJ->getId(), $index)
103 );
104 }
105 else
106 {
107 $value = $this->questionOBJ->prepareTextareaOutput(
108 $this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), $index)
109 );
110 }
111
112 $form->getItemByPostVar("feedback_answer_$index")->setValue($value);
113 }
114 }
115 }
116
127 {
128 if( !$this->questionOBJ->isAdditionalContentEditingModePageObject() )
129 {
130 $this->saveSpecificFeedbackSetting($this->questionOBJ->getId(), $form->getInput('feedback_setting'));
131
132 foreach( $this->getAnswerOptionsByAnswerIndex() as $index => $answer )
133 {
135 $this->questionOBJ->getId(), $index, $form->getInput("feedback_answer_$index")
136 );
137 }
138 }
139 }
140
149 {
150 return true;
151 }
152
160 public function saveSpecificFeedbackSetting($questionId, $specificFeedbackSetting)
161 {
162 $this->db->update($this->getSpecificQuestionTableName(),
163 array('feedback_setting' => array('integer', $specificFeedbackSetting)),
164 array('question_fi' => array('integer', $questionId))
165 );
166 }
167
178 protected function duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId)
179 {
180 // sync specific feedback setting to duplicated question
181
182 $this->syncSpecificFeedbackSetting($originalQuestionId, $duplicateQuestionId);
183
184 // sync specific answer feedback to duplicated question
185
186 $res = $this->db->queryF(
187 "SELECT * FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s", array('integer'), array($originalQuestionId)
188 );
189
190 while( $row = $this->db->fetchAssoc($res) )
191 {
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 {
204 $pageObjectType = $this->getSpecificAnswerFeedbackPageObjectType();
205 $this->duplicatePageObject($pageObjectType, $row['feedback_id'], $nextId, $duplicateQuestionId);
206 }
207 }
208 }
209
219 protected function syncSpecificFeedback($originalQuestionId, $duplicateQuestionId)
220 {
221 // sync specific feedback setting to the original
222 $this->syncSpecificFeedbackSetting($duplicateQuestionId, $originalQuestionId);
223
224 // delete specific feedback of the original
225 $this->db->manipulateF(
226 "DELETE FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s",
227 array('integer'), 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'), array($duplicateQuestionId)
234 );
235
236 // save specific feedback to the original
237 while( $row = $this->db->fetchAssoc($res) )
238 {
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'), array($sourceQuestionId)
256 );
257
258 $row = $this->db->fetchAssoc($res);
259
260 $this->db->update( $this->getSpecificQuestionTableName(),
261 array( 'feedback_setting' => array('integer', $row['feedback_setting']) ),
262 array( 'question_fi' => array('integer', $targetQuestionId) )
263 );
264 }
265}
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.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a property in a property form.
This class represents an option in a radio group.