Skip to content

Commit

Permalink
Adding progress output after fail
Browse files Browse the repository at this point in the history
  • Loading branch information
jakefish18 committed Aug 13, 2023
1 parent 497452d commit cede346
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/telegram_bot/client_commands/run_learning_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ async def run_learning_session_st2(message: types.message, state: FSMContext):

crud_learning_session.create_many(db, learning_session_cards)

# Preparing data for learning session.
async with state.proxy() as answer:
answer["answered_count"] = 0
answer["choosen_training"] = learning_collection.name
answer["total_count_of_cards"] = len(learning_collection.cards)

db.close()

await continue_learning_session(message, state, first_question=True)
Expand All @@ -122,9 +128,12 @@ async def continue_learning_session(message: types.message, state: FSMContext, f
async with state.proxy() as answer:
if answer["answer"] != message.text:
await state.finish()
answered_count = answer["answered_count"]
total_count_of_cards = answer["total_count_of_cards"]
await bot.send_message(
user_telegram_id,
f'Вопрос: {answer["question"]}\n'
f"Сделано: {answered_count}/{total_count_of_cards}\n"
+ f'Вопрос: {answer["question"]}\n'
+ f'Правильный ответ: {answer["answer"]}\n'
+ f"Ваш ответ: {message.text}\n"
+ RUN_LEARNING_SESSION_ERROR_3,
Expand All @@ -139,6 +148,9 @@ async def continue_learning_session(message: types.message, state: FSMContext, f
passed_card.is_passed = True
passed_card = crud_learning_session_card.update(db, passed_card)

# Saving answered count for session.
answer["answered_count"] += 1

# Get user learning session.
learning_session = crud_learning_session.get_user_session(db, user)

Expand Down

0 comments on commit cede346

Please sign in to comment.