Kanji and Vocab responses now have separate items for kana and meaning rather than both in one.

This commit is contained in:
neviyn 2015-12-23 23:16:26 +00:00
parent 1cc615d083
commit 8b170c3264
3 changed files with 18 additions and 16 deletions

View File

@ -23,9 +23,8 @@ refreshQuestion = () ->
else
document.body.style.backgroundColor = "darkviolet";
$("#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")
$('#answer').text(selection['answer_meaning']);
wanakana.unbind(input_element);
else
$("#kana").attr("placeholder", "かな")

View File

@ -30,9 +30,8 @@
document.body.style.backgroundColor = "darkviolet";
}
$("#question-area").text(selection['question']);
if (Math.random() >= 0.5) {
if (selection['answer_type'] === 'romaji') {
$("#kana").attr("placeholder", "Meaning");
$('#answer').text(selection['answer_meaning']);
return wanakana.unbind(input_element);
} else {
$("#kana").attr("placeholder", "かな");

View File

@ -118,25 +118,29 @@ def get_items_with_level_restriction(level_range, item_state, item_types):
loads = json.loads
if 'radical' in item_types:
items.extend({'item_type': 'radical', 'answer': item['meaning'], 'question': item['image']
if item['image'] else item['character']} for item in loads(current_user.radicals)
if item['image'] else item['character']} for item in loads(current_user.radicals)
if item['user_specific'] and item['user_specific']['srs'] in item_state
and item['level'] in level_range)
radical_count = len(items)
kanji_count = 0
if 'kanji' in item_types:
items.extend({'item_type': 'kanji', 'question': item['character'],
'answer': combine_onyomi_and_kunyomi(item['onyomi'], item['kunyomi']),
'answer_meaning': item['meaning']} for item in loads(current_user.kanji)
if item['user_specific'] and item['user_specific']['srs'] in item_state
and item['level'] in level_range)
kanji_count = len(items) - radical_count
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_type': 'kana'},
{'item_type': 'kanji', 'question': item['character'], 'answer': item['meaning'],
'answer_type': 'romaji'}])
kanji_count = (len(items) - radical_count) / 2
vocabulary_count = 0
if 'vocab' in item_types:
items.extend({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
'answer_meaning': item['meaning']} for item in loads(current_user.vocabulary)
if item['user_specific'] and item['user_specific']['srs'] in item_state
and item['level'] in level_range)
vocabulary_count = len(items) - (radical_count + kanji_count)
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.vocabulary)):
items.extend([{'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
'answer_type': 'kana'},
{'item_type': 'vocabulary', 'question': item['character'],
'answer': item['meaning'], 'answer_type': 'romaji'}])
vocabulary_count = (len(items) - (radical_count + kanji_count)) / 2
if not items:
return flask.jsonify(error="No items within these filter parameters")
else: