Commit 560cd9b0 by Felix Sun Committed by Carlos Andrés Rocha

Fixed bug when user votes w/o permission - now displays a friendly error message…

Fixed bug when user votes w/o permission - now displays a friendly error message instead of failing.

Fixed bug when hinter module displays a hint, then is asked to display nothing.  (Used to not update in this case.)
parent 15317de2
......@@ -227,7 +227,7 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule):
Returns key 'hint_and_votes', a list of (hint_text, #votes) pairs.
"""
if self.user_voted:
return json.dumps({'contents': 'Sorry, but you have already voted!'})
return {}
ans_no = int(get['answer'])
hint_no = str(get['hint'])
answer = self.previous_answers[ans_no][0]
......
......@@ -72,3 +72,5 @@ class @Hinter
JavascriptLoader.executeModuleScripts @el, () =>
@bind()
@$('#previous-answer-0').css('display', 'inline')
else
@el.hide()
......@@ -95,13 +95,17 @@ What would you say to help someone who got this wrong answer?
</%def>
<%def name="show_votes()">
Thank you for voting!
<br />
% for hint, votes in hint_and_votes:
<span style="color:green"> ${votes} votes. </span>
${hint}
<br />
% endfor
% if hint_and_votes is UNDEFINED:
Sorry, but you've already voted!
% else:
Thank you for voting!
<br />
% for hint, votes in hint_and_votes:
<span style="color:green"> ${votes} votes. </span>
${hint}
<br />
% endfor
% endif
</%def>
<%def name="simple_message()">
......@@ -123,3 +127,4 @@ What would you say to help someone who got this wrong answer?
% if op == "vote":
${show_votes()}
% endif
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