From 2c16801a25d7bfae0c255349e6ce3c9077ee46a4 Mon Sep 17 00:00:00 2001 From: Felix Sun Date: Tue, 25 Jun 2013 10:26:59 -0400 Subject: [PATCH] Properly fomatted the tab-based UX for hint-voting. Chiseled a little at writing template tests. --- .../xmodule/tests/test_crowdsource_hinter.py | 20 ++++++++ common/templates/hinter_display.html | 50 ++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py b/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py index b70c490644..350abe9c8f 100644 --- a/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py +++ b/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py @@ -281,6 +281,26 @@ class CrowdsourceHinterTest(unittest.TestCase): self.assertTrue('Another random hint' in out) + def test_template_feedback(self): + """ + Test the templates for get_feedback. + """ + m = CHModuleFactory.create() + + def fake_get_feedback(get): + index_to_answer = {'0': '42.0', '1': '9000.01'} + index_to_hints = {'0': [('A hint for 42', 12), + ('Another hint for 42', 14)], + '1': [('A hint for 9000.01', 32)]} + return {'index_to_hints': index_to_hints, 'index_to_answer': index_to_answer} + + m.get_feedback = fake_get_feedback + json_in = {'problem_name': '42.5'} + out = json.loads(m.handle_ajax('get_feedback', json_in))['contents'] + + + + diff --git a/common/templates/hinter_display.html b/common/templates/hinter_display.html index e1f9a5fafb..a253f9f639 100644 --- a/common/templates/hinter_display.html +++ b/common/templates/hinter_display.html @@ -18,6 +18,53 @@ <%def name="get_feedback()"> + + Participation in the hinting system is strictly optional, and will not influence your grade.
@@ -33,6 +80,7 @@ % for index, answer in index_to_answer.items():
+
% if index in index_to_hints and len(index_to_hints[index]) > 0: Which hint was most helpful when you got the wrong answer of ${answer}?
@@ -53,7 +101,7 @@ What would you say to help someone who got this wrong answer? -
+
% endfor