ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $header = new ilFormSectionHeaderGUI();
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(), 0, $index)
103 );
104 } else {
105 $value = $this->questionOBJ->prepareTextareaOutput(
106 $this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), 0, $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 0,
133 $index,
134 $form->getInput("feedback_answer_$index")
135 );
136 }
137 }
138 }
139
148 {
149 return true;
150 }
151
159 public function saveSpecificFeedbackSetting($questionId, $specificFeedbackSetting)
160 {
161 $this->db->update(
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 parent::duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId);
185 }
186
196 protected function syncSpecificFeedback($originalQuestionId, $duplicateQuestionId)
197 {
198 // sync specific feedback setting to the original
199 $this->syncSpecificFeedbackSetting($duplicateQuestionId, $originalQuestionId);
200
201 parent::syncSpecificFeedback($originalQuestionId, $duplicateQuestionId);
202 }
203
204 private function syncSpecificFeedbackSetting($sourceQuestionId, $targetQuestionId)
205 {
206 $res = $this->db->queryF(
207 "SELECT feedback_setting FROM {$this->getSpecificQuestionTableName()} WHERE question_fi = %s",
208 array('integer'),
209 array($sourceQuestionId)
210 );
211
212 $row = $this->db->fetchAssoc($res);
213
214 $this->db->update(
216 array( 'feedback_setting' => array('integer', $row['feedback_setting']) ),
217 array( 'question_fi' => array('integer', $targetQuestionId) )
218 );
219 }
220}
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, $questionIndex, $answerIndex)
returns the SPECIFIC answer feedback content for a given question id and answer index.
getAnswerOptionsByAnswerIndex()
returns the answer options mapped by answer index (can be overwritten by concrete question type class...
saveSpecificAnswerFeedbackContent($questionId, $questionIndex, $answerIndex, $feedbackContent)
saves SPECIFIC answer feedback content for the given question id and answer index to the database.
getSpecificAnswerFeedbackPageObjectId($questionId, $questionIndex, $answerIndex)
returns a useable page object id for specific answer feedback page objects for the given question id ...
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...
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.
$index
Definition: metadata.php:128
foreach($_POST as $key=> $value) $res