Radical answers are now stripped of "-" characters.

This commit is contained in:
neviyn 2016-02-18 01:13:45 +00:00
parent 7488a5eb7b
commit 84de8f5780
2 changed files with 23 additions and 11 deletions

View File

@ -106,13 +106,17 @@ $(document).keypress (e) ->
$("#submit-answer").click (e) ->
e.preventDefault();
input_answer = document.getElementById('kana').value;
if($("#kana").hasClass("correct"))
refreshQuestion();
else if(selection['answer'].split(/[,\.]/g).map((x) -> x.trim()).indexOf(input_answer) != -1)
$("#kana").addClass("correct").removeClass("wrong");
else
$("#kana").addClass("wrong").removeClass("correct").val('')
input_answer = document.getElementById('kana').value;
expected_answer = selection['answer'].split(/[,\.]/g).map((x) -> x.trim())
if(selection["item_type"] == "radical")
expected_answer = expected_answer.map((x) -> x.replace("-", " "))
if(expected_answer.indexOf(input_answer) != -1)
$("#kana").addClass("correct").removeClass("wrong");
else
$("#kana").addClass("wrong").removeClass("correct").val('')
$("#get-help").click (e) ->
e.preventDefault();

View File

@ -155,17 +155,25 @@
});
$("#submit-answer").click(function(e) {
var input_answer;
var expected_answer, input_answer;
e.preventDefault();
input_answer = document.getElementById('kana').value;
if ($("#kana").hasClass("correct")) {
return refreshQuestion();
} else if (selection['answer'].split(/[,\.]/g).map(function(x) {
return x.trim();
}).indexOf(input_answer) !== -1) {
return $("#kana").addClass("correct").removeClass("wrong");
} else {
return $("#kana").addClass("wrong").removeClass("correct").val('');
input_answer = document.getElementById('kana').value;
expected_answer = selection['answer'].split(/[,\.]/g).map(function(x) {
return x.trim();
});
if (selection["item_type"] === "radical") {
expected_answer = expected_answer.map(function(x) {
return x.replace("-", " ");
});
}
if (expected_answer.indexOf(input_answer) !== -1) {
return $("#kana").addClass("correct").removeClass("wrong");
} else {
return $("#kana").addClass("wrong").removeClass("correct").val('');
}
}
});