64 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $item) {
68 $answers = implode(
' / ', $answers);
71 $this->
lng->txt(
'ass_cloze_gap_fb_gap_label'),
80 $this->
lng->txt(
'ass_cloze_gap_fb_txt_match_label'),
88 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_txt_nomatch_label'), $gapIndex + 1);
93 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_txt_empty_label'), $gapIndex + 1);
99 $this->
lng->txt(
'ass_cloze_gap_fb_sel_opt_label'),
107 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_sel_empty_label'), $gapIndex + 1);
112 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_num_valuehit_label'), $gapIndex + 1);
117 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_num_rangehit_label'), $gapIndex + 1);
122 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_num_toolow_label'), $gapIndex + 1);
127 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_num_toohigh_label'), $gapIndex + 1);
132 return sprintf($this->
lng->txt(
'ass_cloze_gap_fb_num_empty_label'), $gapIndex + 1);
137 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
139 $header->setTitle($this->
lng->txt(
'feedback_answers'));
143 $this->
lng->txt(
'ass_cloze_fb_mode'),
150 $this->
lng->txt(
'ass_cloze_fb_mode_gap_qst'),
151 self::FB_MODE_GAP_QUESTION,
152 $this->
lng->txt(
'ass_cloze_fb_mode_gap_qst_info')
155 $feedbackMode->addOption($fbModeGapQuestion);
158 $this->
lng->txt(
'ass_cloze_fb_mode_gap_answ'),
159 self::FB_MODE_GAP_ANSWERS,
160 $this->
lng->txt(
'ass_cloze_fb_mode_gap_answ_info')
163 $feedbackMode->addOption($fbModeGapAnswers);
169 foreach ($this->questionOBJ->getGaps() as $gapIndex => $gap) {
170 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
179 $this->questionOBJ->isAdditionalContentEditingModePageObject()
187 foreach ($this->questionOBJ->getGaps() as $gapIndex => $gap) {
188 switch ($gap->getType()) {
209 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $answerIndex => $item) {
210 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
215 $propertyPostVar =
"feedback_answer_{$gapIndex}_{$answerIndex}";
220 $this->questionOBJ->isAdditionalContentEditingModePageObject()
224 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
229 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_TEXT_GAP_NOMATCH_INDEX;
234 $this->questionOBJ->isAdditionalContentEditingModePageObject()
237 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
242 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_TEXT_GAP_EMPTY_INDEX;
247 $this->questionOBJ->isAdditionalContentEditingModePageObject()
253 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $optIndex => $item) {
254 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
259 $propertyPostVar =
"feedback_answer_{$gapIndex}_{$optIndex}";
264 $this->questionOBJ->isAdditionalContentEditingModePageObject()
268 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
273 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_SELECT_GAP_EMPTY_INDEX;
278 $this->questionOBJ->isAdditionalContentEditingModePageObject()
289 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
294 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_NUMERIC_GAP_VALUE_HIT_INDEX;
299 $this->questionOBJ->isAdditionalContentEditingModePageObject()
303 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
308 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_NUMERIC_GAP_RANGE_HIT_INDEX;
313 $this->questionOBJ->isAdditionalContentEditingModePageObject()
317 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
322 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_NUMERIC_GAP_TOO_LOW_INDEX;
327 $this->questionOBJ->isAdditionalContentEditingModePageObject()
330 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
335 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_NUMERIC_GAP_TOO_HIGH_INDEX;
340 $this->questionOBJ->isAdditionalContentEditingModePageObject()
343 $propertyLabel = $this->questionOBJ->prepareTextareaOutput(
348 $propertyPostVar =
"feedback_answer_{$gapIndex}_" . self::FB_NUMERIC_GAP_EMPTY_INDEX;
353 $this->questionOBJ->isAdditionalContentEditingModePageObject()
359 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
362 $fbMode->setValue($this->questionOBJ->getFeedbackMode());
364 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
368 switch ($this->questionOBJ->getFeedbackMode()) {
369 case self::FB_MODE_GAP_QUESTION:
374 case self::FB_MODE_GAP_ANSWERS:
385 foreach ($this->questionOBJ->getGaps() as $gapIndex => $gap) {
393 foreach ($this->questionOBJ->getGaps() as $gapIndex => $gap) {
394 switch ($gap->getType()) {
415 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $answerIndex => $item) {
432 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $optIndex => $item) {
470 if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
473 if ($fbMode != $this->questionOBJ->getFeedbackMode()) {
479 switch ($this->questionOBJ->getFeedbackMode()) {
480 case self::FB_MODE_GAP_QUESTION:
485 case self::FB_MODE_GAP_ANSWERS:
495 foreach ($this->questionOBJ->getGaps() as $gapIndex => $gap) {
500 $this->questionOBJ->getId(),
502 self::SINGLE_GAP_FB_ANSWER_INDEX,
510 foreach ($this->questionOBJ->getGaps() as $gapIndex => $gap) {
511 switch ($gap->getType()) {
532 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $answerIndex => $item) {
536 $this->questionOBJ->getId(),
546 $this->questionOBJ->getId(),
548 self::FB_TEXT_GAP_NOMATCH_INDEX,
555 $this->questionOBJ->getId(),
557 self::FB_TEXT_GAP_EMPTY_INDEX,
564 foreach ($gap->
getItems($this->randomGroup()->dontShuffle()) as $optIndex => $item) {
568 $this->questionOBJ->getId(),
578 $this->questionOBJ->getId(),
580 self::FB_SELECT_GAP_EMPTY_INDEX,
590 $this->questionOBJ->getId(),
592 self::FB_NUMERIC_GAP_VALUE_HIT_INDEX,
600 $this->questionOBJ->getId(),
602 self::FB_NUMERIC_GAP_RANGE_HIT_INDEX,
610 $this->questionOBJ->getId(),
612 self::FB_NUMERIC_GAP_TOO_LOW_INDEX,
619 $this->questionOBJ->getId(),
621 self::FB_NUMERIC_GAP_TOO_HIGH_INDEX,
628 $this->questionOBJ->getId(),
630 self::FB_NUMERIC_GAP_EMPTY_INDEX,
639 parent::duplicateSpecificFeedback($originalQuestionId, $duplicateQuestionId);
644 $res = $this->db->queryF(
645 "SELECT feedback_mode FROM {$this->questionOBJ->getAdditionalTableName()} WHERE question_fi = %s",
647 array($sourceQuestionId)
650 $row = $this->db->fetchAssoc(
$res);
653 $this->questionOBJ->getAdditionalTableName(),
654 array(
'feedback_mode' => array(
'text', $row[
'feedback_mode']) ),
655 array(
'question_fi' => array(
'integer', $targetQuestionId) )
662 parent::syncSpecificFeedback($originalQuestionId, $duplicateQuestionId);
671 $this->questionOBJ->setFeedbackMode($feedbackMode);
674 $this->questionOBJ->getAdditionalTableName(),
675 array(
'feedback_mode' => array(
'text', $feedbackMode)),
676 array(
'question_fi' => array(
'integer', $questionId))
682 return "feedback_answer_{$gapIndex}";
687 return "feedback_answer_{$gapIndex}_{$answerIndex}";
692 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
694 $this->questionOBJ->getId(),
704 $value = $this->questionOBJ->prepareTextareaOutput(
715 case self::FB_MODE_GAP_QUESTION:
719 case self::FB_MODE_GAP_ANSWERS:
723 default: $feedbackIds = array();
734 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssSpecificFeedbackIdentifierList.php';
736 $feedbackIdentifiers->load($this->questionOBJ->getId());
738 $feedbackIds = array();
740 foreach ($feedbackIdentifiers as $identifier) {
741 if ($identifier->getAnswerIndex() != self::SINGLE_GAP_FB_ANSWER_INDEX) {
745 $feedbackIds[] = $identifier->getFeedbackId();
756 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssSpecificFeedbackIdentifierList.php';
758 $feedbackIdentifiers->load($this->questionOBJ->getId());
760 $feedbackIds = array();
762 foreach ($feedbackIdentifiers as $identifier) {
763 if ($identifier->getAnswerIndex() == self::SINGLE_GAP_FB_ANSWER_INDEX) {
767 $feedbackIds[] = $identifier->getFeedbackId();
775 if ($this->questionOBJ->getFeedbackMode() === self::FB_MODE_GAP_QUESTION) {
781 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
782 $all_feedback_content =
'';
783 foreach ($feedback_ids as $feedback_id) {
789 return trim(strip_tags($all_feedback_content)) !==
'';
800 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
801 foreach ($feedbackIds as $fbId) {
806 $IN_feedbackIds = $this->db->in(
'feedback_id', $feedbackIds,
false,
'integer');
807 $this->db->manipulate(
"DELETE FROM {$this->getSpecificFeedbackTableName()} WHERE {$IN_feedbackIds}");
812 if ($this->questionOBJ->getFeedbackMode() == self::FB_MODE_GAP_QUESTION) {
814 $this->questionOBJ->getId(),
816 self::SINGLE_GAP_FB_ANSWER_INDEX
828 if (!strlen($answerValue)) {
829 return self::FB_TEXT_GAP_EMPTY_INDEX;
834 foreach ($items as $answerIndex => $answer) {
837 if ($answer->getAnswertext() == $answerValue) {
842 return self::FB_TEXT_GAP_NOMATCH_INDEX;
846 if (strlen($answerValue)) {
850 return self::FB_SELECT_GAP_EMPTY_INDEX;
855 if (!strlen($answerValue)) {
856 return self::FB_NUMERIC_GAP_EMPTY_INDEX;
861 $item = current($gap->
getItems($this->randomGroup()->dontShuffle()));
863 if ($answerValue == $item->getAnswertext()) {
864 return self::FB_NUMERIC_GAP_VALUE_HIT_INDEX;
867 require_once
'Services/Math/classes/class.EvalMath.php';
871 $lowerBound = $math->evaluate($item->getLowerBound());
872 $upperBound = $math->evaluate($item->getUpperBound());
873 $preciseValue = $math->evaluate($item->getAnswertext());
875 $solutionValue = $math->evaluate($answerValue);
877 if ($solutionValue == $preciseValue) {
878 return self::FB_NUMERIC_GAP_VALUE_HIT_INDEX;
879 } elseif ($solutionValue >= $lowerBound && $solutionValue <= $upperBound) {
880 return self::FB_NUMERIC_GAP_RANGE_HIT_INDEX;
881 } elseif ($solutionValue < $lowerBound) {
882 return self::FB_NUMERIC_GAP_TOO_LOW_INDEX;
886 return self::FB_NUMERIC_GAP_TOO_HIGH_INDEX;
895 return $DIC->refinery()->random();
getSpecificAnswerFeedbackContent(int $questionId, int $questionIndex, int $answerIndex)
deleteSpecificAnswerFeedbacksByIds(array $feedbackIds)
buildPostVarForFbFieldPerGapQuestion(int $gapIndex)
cleanupSpecificAnswerFeedbacks(string $fbMode)
const FB_NUMERIC_GAP_TOO_HIGH_INDEX
saveFbPropsForSelectGap(ilPropertyFormGUI $form, assClozeGap $gap, int $gapIndex)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildGapFeedbackLabel(int $gapIndex, assClozeGap $gap)
builds an answer option label from given (mixed type) index and answer (overwrites parent method from...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initFbPropsForSelectGap(ilPropertyFormGUI $form, assClozeGap $gap, int $gapIndex)
initFeedbackFieldsPerGapAnswers(ilPropertyFormGUI $form)
buildSelectGapEmptyFeedbackLabel(int $gapIndex)
ensurePageObjectDeleted(string $pageObjectType, int $pageObjectId)
syncSpecificFeedbackSetting(int $sourceQuestionId, int $targetQuestionId)
initFeedbackFieldsPerGapQuestion(ilPropertyFormGUI $form)
completeFormPropsForFeedbackModeGapQuestion(ilRadioOption $fbModeOpt)
const FB_NUMERIC_GAP_VALUE_HIT_INDEX
getSpecificAnswerFeedbackPageObjectType()
const CLOZE_TEXT
Cloze question constants.
initFbPropsForNumericGap(ilPropertyFormGUI $form, int $gapIndex, assClozeGap $gap)
saveSpecificFeedbackMode(int $questionId, string $feedbackMode)
saves the given specific feedback mode for the given question id to the db.
completeFbPropsForSelectGap(ilRadioOption $fbModeOpt, assClozeGap $gap, int $gapIndex)
buildTextGapWrongAnswerFeedbackLabel(int $gapIndex)
completeFormPropsForFeedbackModeGapAnswers(ilRadioOption $fbModeOpt)
isSpecificAnswerFeedbackAvailable(int $question_id)
completeFbPropsForNumericGap(ilRadioOption $fbModeOpt, assClozeGap $gap, int $gapIndex)
getSpecificAnswerFeedbackPageObjectId(int $questionId, int $questionIndex, int $answerIndex)
returns a useable page object id for specific answer feedback page objects for the given question id ...
Class for cloze question gaps.
const FB_NUMERIC_GAP_TOO_LOW_INDEX
getSpecificAnswerFeedbackTestPresentation(int $questionId, int $questionIndex, int $answerIndex)
returns the html of SPECIFIC feedback for the given question id and answer index for test presentatio...
saveSpecificFormProperties(ilPropertyFormGUI $form)
initSpecificFormProperties(ilPropertyFormGUI $form)
const FB_NUMERIC_GAP_RANGE_HIT_INDEX
syncSpecificFeedback(int $originalQuestionId, int $duplicateQuestionId)
getSpecificFeedbackContentForFeedbackIds(array $feedback_ids)
determineTestOutputGapFeedback(int $gapIndex, int $answerIndex)
getItems(Transformation $shuffler, ?int $gap_index=null)
Gets the items of a cloze gap.
buildNumericGapValueHitFeedbackLabel(int $gapIndex)
saveFbPropsForTextGap(ilPropertyFormGUI $form, assClozeGap $gap, int $gapIndex)
buildNumericGapEmptyFeedbackLabel(int $gapIndex)
completeSpecificFormProperties(ilPropertyFormGUI $form)
determineAnswerIndexForAnswerValue(assClozeGap $gap, string $answerValue)
buildSelectGapOptionFeedbackLabel(int $gapIndex, assAnswerCloze $item)
completeFbPropsForTextGap(ilRadioOption $fbModeOpt, assClozeGap $gap, int $gapIndex)
const FB_NUMERIC_GAP_EMPTY_INDEX
getPageObjectXML(string $pageObjectType, int $pageObjectId)
buildTextGapGivenAnswerFeedbackLabel(int $gapIndex, assAnswerCloze $item)
buildFeedbackContentFormProperty(string $label, string $postVar, bool $asNonEditable)
builds and returns a form property gui object with the given label and postvar that is addable to pro...
getPageObjectNonEditableValueHTML(string $pageObjectType, int $pageObjectId)
returns html content to be used as value for non editable value form properties in feedback editing f...
fetchFeedbackIdsForGapAnswersMode()
initFbPropsForTextGap(ilPropertyFormGUI $form, assClozeGap $gap, int $gapIndex)
const FB_TEXT_GAP_NOMATCH_INDEX
getSpecificAnswerFeedbackFormValue(int $gapIndex, int $answerIndex)
saveFbPropsForNumericGap(ilPropertyFormGUI $form, assClozeGap $gap, int $gapIndex)
buildNumericGapRangeHitFeedbackLabel(int $gapIndex)
const FB_TEXT_GAP_EMPTY_INDEX
constants for answer indexes in case of FB_MODE_GAP_ANSWERS
duplicateSpecificFeedback(int $originalQuestionId, int $duplicateQuestionId)
getAnswertext()
Gets the answer text.
const FB_MODE_GAP_ANSWERS
const FB_SELECT_GAP_EMPTY_INDEX
saveFeedbackFieldsPerGapQuestion(ilPropertyFormGUI $form)
buildTextGapEmptyFeedbackLabel(int $gapIndex)
buildNumericGapTooHighFeedbackLabel(int $gapIndex)
getItem($a_index)
Gets the item with a given index.
saveFeedbackFieldsPerGapAnswers(ilPropertyFormGUI $form)
fetchFeedbackIdsForGapQuestionMode()
const FB_MODE_GAP_QUESTION
constants for different feedback modes (per gap or per gap-answers/options)
isSaveableInPageObjectEditingMode()
buildPostVarForFbFieldPerGapAnswers(int $gapIndex, int $answerIndex)
saveSpecificAnswerFeedbackContent(int $questionId, int $questionIndex, int $answerIndex, string $feedbackContent)
const SINGLE_GAP_FB_ANSWER_INDEX
buildNumericGapTooLowFeedbackLabel(int $gapIndex)