ILIAS  release_4-4 Revision
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 
4 require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssMultiOptionQuestionFeedback.php';
5 
19 {
30  {
31  if( !$this->questionOBJ->getSelfAssessmentEditingMode() )
32  {
33  $header = new ilFormSectionHeaderGUI();
34  $header->setTitle($this->lng->txt('feedback_answers'));
35  $form->addItem($header);
36 
37  require_once './Services/Form/classes/class.ilRadioGroupInputGUI.php';
38  require_once './Services/Form/classes/class.ilRadioOption.php';
39 
40  $feedback = new ilRadioGroupInputGUI($this->lng->txt('feedback_setting'), 'feedback_setting');
41  $feedback->addOption(new ilRadioOption($this->lng->txt('feedback_all'), 1), true);
42  $feedback->addOption(new ilRadioOption($this->lng->txt('feedback_checked'), 2));
43  $feedback->addOption(new ilRadioOption($this->lng->txt('feedback_correct'), 3));
44  $form->addItem($feedback);
45 
46  foreach( $this->getAnswerOptionsByAnswerIndex() as $index => $answer )
47  {
48  $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
49  $this->buildAnswerOptionLabel($index, $answer), true
50  );
51 
52  $propertyPostVar = "feedback_answer_$index";
53 
55  $propertyLabel , $propertyPostVar, $this->questionOBJ->isAdditionalContentEditingModePageObject()
56  ));
57  }
58  }
59  }
60 
71  {
72  if (!$this->questionOBJ->getSelfAssessmentEditingMode())
73  {
74  $form->getItemByPostVar('feedback_setting')->setValue(
75  $this->questionOBJ->getSpecificFeedbackSetting()
76  );
77 
78  foreach( $this->getAnswerOptionsByAnswerIndex() as $index => $answer )
79  {
80  if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
81  {
82  $value = $this->getPageObjectNonEditableValueHTML(
84  $this->getSpecificAnswerFeedbackPageObjectId($this->questionOBJ->getId(), $index)
85  );
86  }
87  else
88  {
89  $value = $this->questionOBJ->prepareTextareaOutput(
90  $this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), $index)
91  );
92  }
93 
94  $form->getItemByPostVar("feedback_answer_$index")->setValue($value);
95  }
96  }
97  }
98 
109  {
110  if( !$this->questionOBJ->isAdditionalContentEditingModePageObject() )
111  {
112  $this->saveSpecificFeedbackSetting($this->questionOBJ->getId(), $form->getInput('feedback_setting'));
113 
114  foreach( $this->getAnswerOptionsByAnswerIndex() as $index => $answer )
115  {
117  $this->questionOBJ->getId(), $index, $form->getInput("feedback_answer_$index")
118  );
119  }
120  }
121  }
122 
131  {
132  return true;
133  }
134 
142  public function saveSpecificFeedbackSetting($questionId, $specificFeedbackSetting)
143  {
144  $this->db->update($this->getSpecificQuestionTableName(),
145  array('feedback_setting' => array('integer', $specificFeedbackSetting)),
146  array('question_fi' => array('integer', $questionId))
147  );
148  }
149 
160  protected function duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId)
161  {
162  // sync specific feedback setting to duplicated question
163 
164  $this->syncSpecificFeedbackSetting($originalQuestionId, $duplicateQuestionId);
165 
166  // sync specific answer feedback to duplicated question
167 
168  $res = $this->db->queryF(
169  "SELECT * FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s", array('integer'), array($originalQuestionId)
170  );
171 
172  while( $row = $this->db->fetchAssoc($res) )
173  {
174  $nextId = $this->db->nextId($this->getSpecificFeedbackTableName());
175 
176  $this->db->insert($this->getSpecificFeedbackTableName(), array(
177  'feedback_id' => array('integer', $nextId),
178  'question_fi' => array('integer', $duplicateQuestionId),
179  'answer' => array('integer', $row['answer']),
180  'feedback' => array('text', $row['feedback']),
181  'tstamp' => array('integer', time())
182  ));
183 
184  if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
185  {
186  $pageObjectType = $this->getSpecificAnswerFeedbackPageObjectType();
187  $this->duplicatePageObject($pageObjectType, $row['feedback_id'], $nextId, $duplicateQuestionId);
188  }
189  }
190  }
191 
201  protected function syncSpecificFeedback($originalQuestionId, $duplicateQuestionId)
202  {
203  // sync specific feedback setting to the original
204  $this->syncSpecificFeedbackSetting($duplicateQuestionId, $originalQuestionId);
205 
206  // delete specific feedback of the original
207  $this->db->manipulateF(
208  "DELETE FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s",
209  array('integer'), array($originalQuestionId)
210  );
211 
212  // get specific feedback of the actual question
213  $res = $this->db->queryF(
214  "SELECT * FROM {$this->getSpecificFeedbackTableName()} WHERE question_fi = %s",
215  array('integer'), array($duplicateQuestionId)
216  );
217 
218  // save specific feedback to the original
219  while( $row = $this->db->fetchAssoc($res) )
220  {
221  $nextId = $this->db->nextId($this->getSpecificFeedbackTableName());
222 
223  $this->db->insert($this->getSpecificFeedbackTableName(), array(
224  'feedback_id' => array('integer', $nextId),
225  'question_fi' => array('integer', $originalQuestionId),
226  'answer' => array('integer',$row['answer']),
227  'feedback' => array('text',$row['feedback']),
228  'tstamp' => array('integer',time())
229  ));
230  }
231  }
232 
233  private function syncSpecificFeedbackSetting($sourceQuestionId, $targetQuestionId)
234  {
235  $res = $this->db->queryF(
236  "SELECT feedback_setting FROM {$this->getSpecificQuestionTableName()} WHERE question_fi = %s",
237  array('integer'), array($sourceQuestionId)
238  );
239 
240  $row = $this->db->fetchAssoc($res);
241 
242  $this->db->update( $this->getSpecificQuestionTableName(),
243  array( 'feedback_setting' => array('integer', $row['feedback_setting']) ),
244  array( 'question_fi' => array('integer', $targetQuestionId) )
245  );
246  }
247 }
This class represents an option in a radio group.
getAnswerOptionsByAnswerIndex()
returns the answer options mapped by answer index (can be overwritten by concrete question type class...
getItemByPostVar($a_post_var)
Get Item by POST variable.
getPageObjectNonEditableValueHTML($pageObjectType, $pageObjectId)
returns html content to be used as value for non editable value form properties in feedback editing f...
This class represents a property form user interface.
saveSpecificAnswerFeedbackContent($questionId, $answerIndex, $feedbackContent)
saves SPECIFIC answer feedback content for the given question id and answer index to the database...
getSpecificAnswerFeedbackPageObjectType()
returns the type for specific feedback page objects defined in local constant
This class represents a section header in a property form.
getSpecificFeedbackTableName()
returns the table name for specific feedback
completeSpecificFormProperties(ilPropertyFormGUI $form)
completes a given form object with the specific form properties required by this question type ...
addItem($a_item)
Add Item (Property, SectionHeader).
buildAnswerOptionLabel($index, $answer)
builds an answer option label from given (mixed type) index and answer (can be overwritten by concret...
This class represents a property in a property form.
addOption($a_option)
Add Option.
syncSpecificFeedback($originalQuestionId, $duplicateQuestionId)
syncs the SPECIFIC feedback from a duplicated question back to the original question ...
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 ...
saveSpecificFormProperties(ilPropertyFormGUI $form)
saves a given form object&#39;s specific form properties relating to this question type ...
duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId)
duplicates the SPECIFIC feedback relating to the given original question id and saves it for the give...
duplicatePageObject($pageObjectType, $originalPageObjectId, $duplicatePageObjectId, $duplicatePageObjectParentId)
duplicates the page object with given type and original id to new page object with same type and give...
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
initSpecificFormProperties(ilPropertyFormGUI $form)
initialises a given form object&#39;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...
buildFeedbackContentFormProperty($label, $postVar, $asNonEditable)
builds and returns a form property gui object with the given label and postvar that is addable to pro...
saveSpecificFeedbackSetting($questionId, $specificFeedbackSetting)
saves the given specific feedback setting for the given question id to the db.