Ejemplo n.º 1
0
def handle_submissions_reviewed_query(call):
    bot.clear_step_handler_by_chat_id(call.message.chat.id)
    data = get_call_data(call)
    teacher = Teacher.get(call.message.chat.id)
    task = Task.get(data['task_id'])
    task_assessments_view(teacher, task)
    task_detail_view(teacher, task)
Ejemplo n.º 2
0
def submission_assessment_receive(message, submission_id):
    teacher = Teacher.get(message.chat.id)
    if len(message.text) > 15:
        ru_text = "Длина оценки не должна превышать 15 символов. Попробуйте ещё раз"
        en_text = "The length of the rate mustn't exceed 15 characters. Try again"
        text = ru_text if teacher.language_code == 'ru' else en_text
        bot.send_message(message.chat.id,
                         text,
                         reply_markup=markups.get_assessment_markup(teacher),
                         parse_mode='Markdown')
        bot.register_next_step_handler(message, submission_assessment_receive,
                                       submission_id)
    else:
        submission = Submission.get(submission_id)
        submission.assessment = message.text
        submission.status = SubmissionStatus.REVIEWED.value
        submission.save()

        ru_text = "Результат проверки отправлен ученику"
        en_text = "The review result has been sent to the student"
        text = ru_text if teacher.language_code == 'ru' else en_text

        bot.send_message(message.chat.id,
                         text,
                         reply_markup=remove_markup(),
                         parse_mode='Markdown')
        task = Task.get(submission.task_id)
        task_detail_view(teacher, task)
        new_submission_review_result_notification(submission)
Ejemplo n.º 3
0
def handle_task_messages_query(call):
    bot.clear_step_handler_by_chat_id(call.message.chat.id)
    data = get_call_data(call)
    user = Teacher.get(call.message.chat.id) or Student.get(
        call.message.chat.id)
    task = Task.get(data['task_id'])
    task_message_list_view(user, task)
    task_detail_view(user, task)
Ejemplo n.º 4
0
def handle_submission_message_list_query(call):
    bot.clear_step_handler_by_chat_id(call.message.chat.id)
    data = get_call_data(call)
    user = Teacher.get(call.message.chat.id) or Student.get(
        call.message.chat.id)
    submission = Submission.get(data['submission_id'])
    task = Task.get(submission.task_id)
    submission_message_list_view(user, submission, task)
    task_detail_view(user, task)
Ejemplo n.º 5
0
def new_task_notification(task):
    classroom = Classroom.get(task.classroom_id)
    teacher = Teacher.get(classroom.teacher_id)
    students = Student.get_classroom_students(classroom.id)

    ru_text = f"🔔 Новое задание: *{task.name}*\n\n*{classroom.name}*. Учитель: _{teacher.fullname}_"
    en_text = f"🔔 New task: *{task.name}*\n\n*{classroom.name}*. Teacher: _{teacher.fullname}_"

    for student in students:
        text = ru_text if student.language_code == 'ru' else en_text
        bot.send_message(student.id, text, parse_mode='MarkDown')
        task_detail_view(student, task)
Ejemplo n.º 6
0
def new_submission_review_result_notification(submission):
    task = Task.get(submission.task_id)
    classroom = Classroom.get(task.classroom_id)
    student = Student.get(submission.student_id)
    teacher = Teacher.get(classroom.teacher_id)

    ru_text = f"🔔 Ваше задание проверено\n\n*{classroom.name}*\n_{teacher.fullname}_"
    en_text = f"🔔 New submission review\n\n*{classroom.name}*\n_{teacher.fullname}_"
    text = ru_text if student.language_code == 'ru' else en_text

    bot.send_message(student.id, text, parse_mode='MarkDown')
    submission_review_result_view(student, submission, task)
    task_detail_view(student, task)
def compose_submission(message, submission):
    student = Student.get(message.chat.id)

    if message.text in ['Отправить на проверку', 'Submit for review']:
        submission.status = SubmissionStatus.REVIEW.value
        submission.save()

        ru_text = "Ваше задание отправлено, ждите результата"
        en_text = "Your submission is sent, wait for the review result"
        text = ru_text if student.language_code == 'ru' else en_text

        bot.send_message(message.chat.id, text, reply_markup=remove_markup())

        task = Task.get(submission.task_id)
        task_detail_view(student, task)
    elif message.text in ['❌ Отмена', '❌ Cancel']:
        ru_text = "Отмена"
        en_text = "Cancel"
        text = ru_text if student.language_code == 'ru' else en_text

        bot.send_message(message.chat.id, text, reply_markup=remove_markup())

        task = Task.get(submission.task_id)
        task_detail_view(student, task)
        submission.delete()
    else:
        submission.add(message)

        ru_text = "Отправьте ещё что-то или нажмите *Отправить на проверку*"
        en_text = "Send something else or tap *Submit for review*"
        text = ru_text if student.language_code == 'ru' else en_text

        bot.send_message(
            message.chat.id,
            text,
            reply_markup=markups.get_compose_submission_markup(student),
            parse_mode='Markdown',
        )

        bot.register_next_step_handler(message, compose_submission, submission)
Ejemplo n.º 8
0
def handle_task_query(call):
    data = get_call_data(call)
    user = Teacher.get(call.message.chat.id) or Student.get(
        call.message.chat.id)
    task = Task.get(data['task_id'])
    task_detail_view(user, task, message_to_edit=call.message)