Commit 70e785a3 by Xavier Antoviaque

feedback-icon-only: Only send tips of the submitted MCQ choice

parent 44832e42
...@@ -53,34 +53,23 @@ class MCQBlock(QuestionnaireAbstractBlock): ...@@ -53,34 +53,23 @@ class MCQBlock(QuestionnaireAbstractBlock):
log.debug(u'Received MCQ submission: "%s"', submission) log.debug(u'Received MCQ submission: "%s"', submission)
completed = True completed = True
tips = [] tips_fragments = []
choices = [choice.value for choice in self.custom_choices]
# ensure rating tips are included
if self.type == 'rating':
choices += [str(n) for n in range(1,6)]
for choice in choices:
choice_tips_fragments = []
for tip in self.get_tips(): for tip in self.get_tips():
completed = completed and self.is_tip_completed(tip, submission) completed = completed and self.is_tip_completed(tip, submission)
if choice in tip.display_with_defaults: if submission in tip.display_with_defaults:
choice_tips_fragments.append(tip.render()) tips_fragments.append(tip.render())
tips.append({ formatted_tips = render_template('templates/html/tip_choice_group.html', {
'choice': choice,
'tips': render_template('templates/html/tip_choice_group.html', {
'self': self, 'self': self,
'tips_fragments': choice_tips_fragments, 'tips_fragments': tips_fragments,
'completed': completed, 'completed': completed,
}) })
})
self.student_choice = submission self.student_choice = submission
result = { result = {
'submission': submission, 'submission': submission,
'completed': completed, 'completed': completed,
'tips': tips, 'tips': formatted_tips,
'weight': self.weight, 'weight': self.weight,
'score': 1 if completed else 0, 'score': 1 if completed else 0,
} }
......
...@@ -101,11 +101,8 @@ function MCQBlock(runtime, element, mentoring) { ...@@ -101,11 +101,8 @@ function MCQBlock(runtime, element, mentoring) {
choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation'); choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
} }
var tips = _.find(result.tips, function(obj) { if (result.tips) {
return obj.choice === choiceInputDOM.val(); mentoring.setContent(choiceTipsDOM, result.tips);
});
if (tips) {
mentoring.setContent(choiceTipsDOM, tips.tips);
} }
choiceTipsCloseDOM = $('.close', choiceTipsDOM); choiceTipsCloseDOM = $('.close', choiceTipsDOM);
...@@ -121,14 +118,7 @@ function MCQBlock(runtime, element, mentoring) { ...@@ -121,14 +118,7 @@ function MCQBlock(runtime, element, mentoring) {
'<div class="close icon-remove-sign fa-times-circle"></div>'); '<div class="close icon-remove-sign fa-times-circle"></div>');
} }
else if (result.tips) { else if (result.tips) {
var tips = _.find(result.tips, function(obj) { messageView.showMessage(result.tips);
return obj.choice === result.submission;
});
if (tips) {
messageView.showMessage(tips.tips);
} else {
messageView.clearPopupEvents();
}
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment