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.)
This commit is contained in:
committed by
Carlos Andrés Rocha
parent
15317de252
commit
560cd9b068
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user