Added kanji/vocab meaning quiz functionality.
This commit is contained in:
parent
f43c089b95
commit
9b17d17a9e
@ -25,13 +25,18 @@ refreshQuestion = () ->
|
|||||||
else
|
else
|
||||||
$("#question-area").text(selection['question']);
|
$("#question-area").text(selection['question']);
|
||||||
else
|
else
|
||||||
$("#kana").attr("placeholder", "かな")
|
|
||||||
if(selection['item_type'] == 'kanji')
|
if(selection['item_type'] == 'kanji')
|
||||||
document.body.style.backgroundColor = "deeppink";
|
document.body.style.backgroundColor = "deeppink";
|
||||||
else
|
else
|
||||||
document.body.style.backgroundColor = "darkviolet";
|
document.body.style.backgroundColor = "darkviolet";
|
||||||
wanakana.bind(input_element);
|
|
||||||
$("#question-area").text(selection['question']);
|
$("#question-area").text(selection['question']);
|
||||||
|
if(Math.random() >= 0.5) # Random chance of asking for the kana or meaning
|
||||||
|
$("#kana").attr("placeholder", "Meaning")
|
||||||
|
$('#answer').text(selection['answer_meaning']);
|
||||||
|
wanakana.unbind(input_element);
|
||||||
|
else
|
||||||
|
$("#kana").attr("placeholder", "かな")
|
||||||
|
wanakana.bind(input_element);
|
||||||
|
|
||||||
$(document).keypress (e) ->
|
$(document).keypress (e) ->
|
||||||
if(e.which == 13)
|
if(e.which == 13)
|
||||||
@ -42,7 +47,7 @@ $("#submit-answer").click (e) ->
|
|||||||
input_answer = document.getElementById('kana').value;
|
input_answer = document.getElementById('kana').value;
|
||||||
if($("#kana").hasClass("correct"))
|
if($("#kana").hasClass("correct"))
|
||||||
refreshQuestion();
|
refreshQuestion();
|
||||||
else if($('#answer').text().replace(/\s/g, '').split(/[,\.]/g).indexOf(input_answer) != -1)
|
else if($('#answer').text().split(/[,\.]/g).indexOf(input_answer) != -1)
|
||||||
$("#kana").addClass("correct").removeClass("wrong");
|
$("#kana").addClass("correct").removeClass("wrong");
|
||||||
else
|
else
|
||||||
$("#kana").addClass("wrong").removeClass("correct").val('')
|
$("#kana").addClass("wrong").removeClass("correct").val('')
|
||||||
|
@ -156,9 +156,11 @@ def get_items():
|
|||||||
made_answer = item['onyomi']
|
made_answer = item['onyomi']
|
||||||
elif item['kunyomi']:
|
elif item['kunyomi']:
|
||||||
made_answer = item['kunyomi'].replace('.*', '')
|
made_answer = item['kunyomi'].replace('.*', '')
|
||||||
items.append({'item_type': 'kanji', 'question': item['character'], 'answer': made_answer})
|
items.append({'item_type': 'kanji', 'question': item['character'], 'answer': made_answer,
|
||||||
|
'answer_meaning': item['meaning']})
|
||||||
for item in json.loads(current_user.vocabulary):
|
for item in json.loads(current_user.vocabulary):
|
||||||
items.append({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana']})
|
items.append({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
|
||||||
|
'answer_meaning': item['meaning']})
|
||||||
return jsonify(item_list=items)
|
return jsonify(item_list=items)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user