def remember_engword_training(username, guess_word): guess_word = user_engdict_search(guess_word, username) word = UsersWords.query.get(guess_word[3]) word.remember_word = None db.session.commit() if word.word_translation is None and word.translation_word is None \ and word.word_write is None and word.translation_write is None: word_status_change_to_familiar(word)
def insert_translation_of_engword_training(username, guess_word, user_answer): guess_word = user_engdict_search(guess_word, username) word = UsersWords.query.get(guess_word[3]) if guess_word[0].translation_rus == user_answer: word.translation_write = None db.session.commit() if word.word_translation is None and word.translation_word is None \ and word.word_write is None and word.remember_word is None: word_status_change_to_familiar(word) return 'Верно', guess_word word.translation_write += 1 db.session.commit() return 'Неверно', guess_word
def engword_translation_training(username, guess_word, user_answer): guess_word = user_engdict_search(guess_word, username) word = UsersWords.query.get(guess_word[3]) if guess_word[0].translation_rus == user_answer: word.word_translation = None # if a word is familiar, the cell sets equal to NULL db.session.commit() if word.translation_word is None and word.word_write is None \ and word.translation_write is None and word.remember_word is None: word_status_change_to_familiar(word) return 'Верно', guess_word word.word_translation += 1 # if a user made a mistake, the counter is incremented by 1 db.session.commit() return 'Неверно', guess_word
def user_search_engword_button(username, word_to_search): username = User.query.filter_by(username=username).first_or_404() title = 'Ваш английский словарь' search_form = EngDictionarySearchForm() delete_form = DeleteEngWordButton() user_id = current_user.get_id() user_status = check_teacher_student(user_id) word, user_english_word_status, user_english_word_date, userword_id = user_engdict_search( word_to_search, username) return render_template('dictionary/user_engdict_search.html', page_title=title, english_word=word, english_word_status=user_english_word_status, english_word_date=user_english_word_date, form=search_form, delete_form=delete_form, user=username.username, user_status=user_status)
def user_process_engdict_search(username): username = User.query.filter_by(username=username).first_or_404() title = 'Ваш английский словарь' search_form = EngDictionarySearchForm() delete_form = DeleteEngWordButton() user_id = current_user.get_id() user_status = check_teacher_student(user_id) if search_form.validate_on_submit(): word_in_form, word = search_form.word.data, None session['word'] = search_form.word.data word, user_english_word_status, user_english_word_date, userword_id = user_engdict_search( word_in_form, username) if word: return render_template( 'dictionary/user_engdict_search.html', page_title=title, english_word=word, english_word_status=user_english_word_status, english_word_date=user_english_word_date, form=search_form, delete_form=delete_form, user=username.username, user_status=user_status) flash('Такого слова нет в вашем английском словаре') translation = user_engdict_translate(word_in_form) if translation: translation_form = WordInsertForm() return render_template('dictionary/user_engdict_insert.html', page_title=title, english_word=word_in_form, translation=translation, form=search_form, translation_form=translation_form, user=username.username, user_status=user_status) return redirect( url_for('.user_engdict_index', username=username.username))
def not_remember_engword_training(username, guess_word): guess_word = user_engdict_search(guess_word, username) word = UsersWords.query.get(guess_word[3]) word.remember_word += 1 db.session.commit()