From 64c91cf2391b2aabf82a7646cda8d45755ede99f Mon Sep 17 00:00:00 2001 From: Felix Sun Date: Wed, 31 Jul 2013 15:17:18 -0400 Subject: [PATCH] UX improvements to hinting. Interface is now less cluttered. Hint submission is hidden behind a link, if there are hints to vote on. --- .../js/src/crowdsource_hinter/display.coffee | 20 ++++--- common/templates/hinter_display.html | 54 ++++++++++--------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/crowdsource_hinter/display.coffee b/common/lib/xmodule/xmodule/js/src/crowdsource_hinter/display.coffee index d973f9a564..a1dc35a604 100644 --- a/common/lib/xmodule/xmodule/js/src/crowdsource_hinter/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/crowdsource_hinter/display.coffee @@ -37,13 +37,14 @@ class @Hinter @$('input.submit-hint').click @submit_hint @$('.custom-hint').click @clear_default_text @$('#answer-tabs').tabs({active: 0}) - @$('.expand-goodhint').click @expand_goodhint + @$('.expand').click @expand - expand_goodhint: => - if @$('.goodhint').css('display') == 'none' - @$('.goodhint').css('display', 'block') + expand: (eventObj) => + target = @$('#' + @$(eventObj.currentTarget).data('target')) + if @$(target).css('display') == 'none' + @$(target).css('display', 'block') else - @$('.goodhint').css('display', 'none') + @$(target).css('display', 'none') vote: (eventObj) => target = @$(eventObj.currentTarget) @@ -53,9 +54,12 @@ class @Hinter @render(response.contents) submit_hint: (eventObj) => - target = @$(eventObj.currentTarget) - textarea = $('.custom-hint[data-answer="'+target.attr('data-answer')+'"]') - post_json = {'answer': target.attr('data-answer'), 'hint': @$(textarea).val()} + textarea = $('.custom-hint') + answer = $('input:radio[name=answer-select]:checked').val() + if answer == undefined + # The user didn't choose an answer. Do nothing. + return + post_json = {'answer': answer, 'hint': textarea.val()} $.postWithPrefix "#{@url}/submit_hint",post_json, (response) => @render(response.contents) diff --git a/common/templates/hinter_display.html b/common/templates/hinter_display.html index d8b020c0f6..8fd219e847 100644 --- a/common/templates/hinter_display.html +++ b/common/templates/hinter_display.html @@ -52,39 +52,35 @@ % endfor

- Don't like any of the hints above? Please write your own, for one of your previous incorrect answers below: -

+ Don't like any of the hints above? + + Write your own! +

+ +