Kanji and Vocab responses now have separate items for kana and meaning rather than both in one.
This commit is contained in:
parent
1cc615d083
commit
8b170c3264
@ -23,9 +23,8 @@ refreshQuestion = () ->
|
|||||||
else
|
else
|
||||||
document.body.style.backgroundColor = "darkviolet";
|
document.body.style.backgroundColor = "darkviolet";
|
||||||
$("#question-area").text(selection['question']);
|
$("#question-area").text(selection['question']);
|
||||||
if(Math.random() >= 0.5) # Random chance of asking for the kana or meaning
|
if(selection['answer_type'] == 'romaji')
|
||||||
$("#kana").attr("placeholder", "Meaning")
|
$("#kana").attr("placeholder", "Meaning")
|
||||||
$('#answer').text(selection['answer_meaning']);
|
|
||||||
wanakana.unbind(input_element);
|
wanakana.unbind(input_element);
|
||||||
else
|
else
|
||||||
$("#kana").attr("placeholder", "かな")
|
$("#kana").attr("placeholder", "かな")
|
||||||
|
@ -30,9 +30,8 @@
|
|||||||
document.body.style.backgroundColor = "darkviolet";
|
document.body.style.backgroundColor = "darkviolet";
|
||||||
}
|
}
|
||||||
$("#question-area").text(selection['question']);
|
$("#question-area").text(selection['question']);
|
||||||
if (Math.random() >= 0.5) {
|
if (selection['answer_type'] === 'romaji') {
|
||||||
$("#kana").attr("placeholder", "Meaning");
|
$("#kana").attr("placeholder", "Meaning");
|
||||||
$('#answer').text(selection['answer_meaning']);
|
|
||||||
return wanakana.unbind(input_element);
|
return wanakana.unbind(input_element);
|
||||||
} else {
|
} else {
|
||||||
$("#kana").attr("placeholder", "かな");
|
$("#kana").attr("placeholder", "かな");
|
||||||
|
@ -124,19 +124,23 @@ def get_items_with_level_restriction(level_range, item_state, item_types):
|
|||||||
radical_count = len(items)
|
radical_count = len(items)
|
||||||
kanji_count = 0
|
kanji_count = 0
|
||||||
if 'kanji' in item_types:
|
if 'kanji' in item_types:
|
||||||
items.extend({'item_type': 'kanji', 'question': item['character'],
|
for item in filter((lambda x: x['user_specific'] and x['user_specific']['srs'] in item_state
|
||||||
|
and x['level'] in level_range), loads(current_user.kanji)):
|
||||||
|
items.extend([{'item_type': 'kanji', 'question': item['character'],
|
||||||
'answer': combine_onyomi_and_kunyomi(item['onyomi'], item['kunyomi']),
|
'answer': combine_onyomi_and_kunyomi(item['onyomi'], item['kunyomi']),
|
||||||
'answer_meaning': item['meaning']} for item in loads(current_user.kanji)
|
'answer_type': 'kana'},
|
||||||
if item['user_specific'] and item['user_specific']['srs'] in item_state
|
{'item_type': 'kanji', 'question': item['character'], 'answer': item['meaning'],
|
||||||
and item['level'] in level_range)
|
'answer_type': 'romaji'}])
|
||||||
kanji_count = len(items) - radical_count
|
kanji_count = (len(items) - radical_count) / 2
|
||||||
vocabulary_count = 0
|
vocabulary_count = 0
|
||||||
if 'vocab' in item_types:
|
if 'vocab' in item_types:
|
||||||
items.extend({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
|
for item in filter((lambda x: x['user_specific'] and x['user_specific']['srs'] in item_state
|
||||||
'answer_meaning': item['meaning']} for item in loads(current_user.vocabulary)
|
and x['level'] in level_range), loads(current_user.vocabulary)):
|
||||||
if item['user_specific'] and item['user_specific']['srs'] in item_state
|
items.extend([{'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
|
||||||
and item['level'] in level_range)
|
'answer_type': 'kana'},
|
||||||
vocabulary_count = len(items) - (radical_count + kanji_count)
|
{'item_type': 'vocabulary', 'question': item['character'],
|
||||||
|
'answer': item['meaning'], 'answer_type': 'romaji'}])
|
||||||
|
vocabulary_count = (len(items) - (radical_count + kanji_count)) / 2
|
||||||
if not items:
|
if not items:
|
||||||
return flask.jsonify(error="No items within these filter parameters")
|
return flask.jsonify(error="No items within these filter parameters")
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user