Example #1
0
def translation_engword(username):
    username = User.query.filter_by(username=username).first_or_404()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    new_words = list(
        filter(lambda x: x[1] == 'new' and x[6] is not None,
               process_user_engdict_index(username)))
    new_words_number = len(new_words)
    if new_words_number:
        new_words_for_other_words_sampling = list(
            filter(lambda x: x[1] == 'new',
                   process_user_engdict_index(username)))
        guess_word = choice(new_words)
        other_words = [
            word[0].word_itself for word in new_words_for_other_words_sampling
            if word != guess_word
        ]
        other_words = sample(other_words, 4)
        other_words.append(guess_word[0].word_itself)
        mixture = sorted(other_words, key=lambda x: random())
        return render_template('exercises/translation_engword.html',
                               guess_word=guess_word[0].translation_rus,
                               new_words_number=new_words_number,
                               mixture=mixture,
                               user_status=user_status)
    return render_template('exercises/translation_engword.html',
                           user_status=user_status)
Example #2
0
def difficult_frenchwords(username):
    title = 'Самые сложные французские слова (не более 20 слов)'
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    diagram = difficult_frenchwords_catplot(username)
    return render_template(
        'progress/difficult_frenchwords.html',
        page_title=title,
        diagram=diagram,
        user_status=user_status
        )
Example #3
0
def familiar_frenchwords(username):
    title = 'Рост числа изученных французских слов '
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    diagram = familiar_frenchwords_accumulated(username)
    return render_template(
        'progress/familiar_frenchwords.html',
        page_title=title,
        diagram=diagram,
        user_status=user_status
        )
Example #4
0
def new_frenchwords(username):
    title = 'Рост числа французских слов в вашем словаре'
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    diagram = new_frenchwords_accumulated(username)
    return render_template(
        'progress/new_frenchwords.html',
        page_title=title,
        diagram=diagram,
        user_status=user_status
        )
Example #5
0
def insert_frenchword_answer(username, guess_word):
    username = User.query.filter_by(username=username).first_or_404()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    form = InsertWordForm()
    if form.validate_on_submit():
        user_answer = form.word.data
        decision, true_word = insert_frenchword_training(
            username, guess_word, user_answer)
        return render_template('exercises/insert_frenchword_answer.html',
                               true_word=true_word,
                               decision=decision,
                               user_status=user_status)
Example #6
0
def user_edit_engword_transcription(username, word_to_edit):
    username = User.query.filter_by(username=username).first_or_404()
    transcription_form = TranscriptionInsertForm()
    title = 'Ваш английский словарь'
    search_form = EngDictionarySearchForm()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_engdict_edit_transcription.html',
                           page_title=title,
                           english_word=word_to_edit,
                           form=search_form,
                           transcription_form=transcription_form,
                           user=username.username,
                           user_status=user_status)
Example #7
0
def user_frenchdict_index(username):
    username = User.query.filter_by(username=username).first_or_404()
    search_form = FrenchDictionarySearchForm()
    title = 'Ваш французский словарь'
    french_list = process_user_frenchdict_index(username)
    french_words_sum = len(french_list)
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_frenchdict_index.html',
                           page_title=title,
                           french_list=french_list,
                           french_list_len=french_words_sum,
                           form=search_form,
                           user=username.username,
                           user_status=user_status)
Example #8
0
def user_engdict_index(username):
    username = User.query.filter_by(username=username).first_or_404()
    search_form = EngDictionarySearchForm()
    title = 'Ваш английский словарь'
    english_list = process_user_engdict_index(username)
    english_words_sum = len(english_list)
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_engdict_index.html',
                           page_title=title,
                           english_list=english_list,
                           english_list_len=english_words_sum,
                           form=search_form,
                           user=username.username,
                           user_status=user_status)
Example #9
0
def engword_translation_answer(username, user_answer, guess_word, mixture):
    username = User.query.filter_by(username=username).first_or_404()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    mixture = mixture.split(', ')
    mixture = [re.findall('[а-яА-Я-]+', x) for x in mixture]
    final_mixture = [
        ' '.join(word) if len(word) > 1 else word[0] for word in mixture
    ]
    decision, true_word = engword_translation_training(
        username, guess_word, final_mixture[user_answer])
    return render_template('exercises/engword_translation_answer.html',
                           true_word=true_word,
                           mixture=final_mixture,
                           decision=decision,
                           user_status=user_status)
Example #10
0
def remember_frenchword(username):
    username = User.query.filter_by(username=username).first_or_404()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    new_words = list(
        filter(lambda x: x[1] == 'new' and x[9] is not None,
               process_user_frenchdict_index(username)))
    new_words_number = len(new_words)
    if new_words_number:
        guess_word = choice(new_words)
        return render_template('exercises/remember_frenchword.html',
                               guess_word=guess_word[0].word_itself,
                               new_words_number=new_words_number,
                               user_status=user_status)
    return render_template('exercises/remember_frenchword.html',
                           user_status=user_status)
Example #11
0
def user_edit_frenchword(username, word_to_edit):
    username = User.query.filter_by(username=username).first_or_404()
    word_to_edit = user_frenchdict_delete_word(word_to_edit, username)
    translation = user_frenchdict_translate(word_to_edit.word_itself)
    translation_form = WordInsertForm()
    title = 'Ваш французский словарь'
    search_form = FrenchDictionarySearchForm()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_frenchdict_edit.html',
                           page_title=title,
                           french_word=word_to_edit.word_itself,
                           translation=translation,
                           form=search_form,
                           translation_form=translation_form,
                           user=username.username,
                           user_status=user_status)
Example #12
0
def user_search_frenchword_button(username, word_to_search):
    username = User.query.filter_by(username=username).first_or_404()
    title = 'Ваш французский словарь'
    search_form = FrenchDictionarySearchForm()
    delete_form = DeleteFrenchWordButton()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    word, user_french_word_status, user_french_word_date, userword_id = user_frenchdict_search(
        word_to_search, username)
    return render_template('dictionary/user_frenchdict_search.html',
                           page_title=title,
                           french_word=word,
                           french_word_status=user_french_word_status,
                           french_word_date=user_french_word_date,
                           form=search_form,
                           delete_form=delete_form,
                           user=username.username,
                           user_status=user_status)
Example #13
0
def insert_frenchword(username):
    username = User.query.filter_by(username=username).first_or_404()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    new_words = list(
        filter(lambda x: x[1] == 'new' and x[7] is not None,
               process_user_frenchdict_index(username)))
    new_words_number = len(new_words)
    form = InsertWordForm()
    if new_words_number:
        guess_word = choice(new_words)
        return render_template('exercises/insert_frenchword.html',
                               guess_word=guess_word[0].translation_rus,
                               new_words_number=new_words_number,
                               form=form,
                               user_status=user_status)
    return render_template('exercises/insert_frenchword.html',
                           user_status=user_status)
Example #14
0
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))
Example #15
0
def choose_diagram(username):
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('progress/choose_diagram.html', user_status=user_status)
Example #16
0
def choose_exercise(username):
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('exercises/choose_exercise.html',
                           user_status=user_status)