Skip to content

Commit

Permalink
Fix oppia#5691: Calculate answer choices (oppia#5756)
Browse files Browse the repository at this point in the history
* fix oppia#5691

* calculate answer choices locally

* lint

* made reveiw changes
  • Loading branch information
aks681 authored Oct 19, 2018
1 parent b0880a8 commit f234a3a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,46 @@ oppia.directive('stateTranslation', [
$scope.activeHintIndex = null;
$scope.activeAnswerGroupIndex = null;

var currentCustomizationArgs = ExplorationStatesService
.getInteractionCustomizationArgsMemento(stateName);
var interactionId = $scope.stateInteractionId;
if (interactionId) {
// Special cases for multiple choice input and image click input.
if (interactionId === 'MultipleChoiceInput') {
$scope.answerChoices =
currentCustomizationArgs.choices.value.map(
function(val, ind) {
return {
val: ind,
label: val
};
}
);
} else if (interactionId === 'ImageClickInput') {
var _answerChoices = [];
var imageWithRegions =
currentCustomizationArgs.imageAndRegions.value;
for (
var j = 0; j < imageWithRegions.labeledRegions.length; j++) {
_answerChoices.push({
val: imageWithRegions.labeledRegions[j].label,
label: imageWithRegions.labeledRegions[j].label
});
}
$scope.answerChoices = _answerChoices;
} else if (interactionId === 'ItemSelectionInput' ||
interactionId === 'DragAndDropSortInput') {
$scope.answerChoices =
currentCustomizationArgs.choices.value.map(function(val) {
return {
val: val,
label: val
};
});
} else {
$scope.answerChoices = null;
}
}
$scope.onTabClick($scope.TAB_ID_CONTENT);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
ng-class="{'oppia-rule-tab-active': activeAnswerGroupIndex === $index}"
ng-style="contentIdStatusColorStyle(answerGroup.outcome.feedback.getContentId())">
<response-header index="$index"
summary="summarizeAnswerGroup(answerGroup, stateInteractionId, getAnswerChoices(), false)"
short-summary="summarizeAnswerGroup(answerGroup, stateInteractionId, getAnswerChoices(), true)"
summary="summarizeAnswerGroup(answerGroup, stateInteractionId, answerChoices, false)"
short-summary="summarizeAnswerGroup(answerGroup, stateInteractionId, answerChoices, true)"
is-active="$index === activeAnswerGroupIndex"
outcome="answerGroup.outcome"
num-rules="answerGroup.rules.length"
Expand Down

0 comments on commit f234a3a

Please sign in to comment.