From bb1a6e15ec60f61d83f1dc74fbf559c5f861abdd Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Mon, 5 Oct 2015 15:48:57 +0100 Subject: [PATCH] Fixed whitespace issue when checking input against answer. --- static/quiz_item.coffee | 4 +++- templates/quiz.html | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/static/quiz_item.coffee b/static/quiz_item.coffee index 22f5f38..a0f8ae4 100644 --- a/static/quiz_item.coffee +++ b/static/quiz_item.coffee @@ -44,10 +44,12 @@ $(document).keypress (e) -> $("#submit-answer").click (e) -> e.preventDefault(); + answers = $('#answer').text().split(/[,\.]/g); + answers = $.map(answers, (x) -> ) input_answer = document.getElementById('kana').value; if($("#kana").hasClass("correct")) refreshQuestion(); - else if($('#answer').text().split(/[,\.]/g).indexOf(input_answer) != -1) + else if($('#answer').text().split(/[,\.]/g).map((x) -> x.trim()).indexOf(input_answer) != -1) $("#kana").addClass("correct").removeClass("wrong"); else $("#kana").addClass("wrong").removeClass("correct").val('') diff --git a/templates/quiz.html b/templates/quiz.html index 66298b6..c3301e9 100644 --- a/templates/quiz.html +++ b/templates/quiz.html @@ -44,5 +44,6 @@ + {% endblock %} \ No newline at end of file