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