def test_get_next_unchecked( course: Course, student_user: User, exercise: Exercise, staff_user: User, _assessments, ): student_user2 = conftest.create_student_user(index=1) exercise2 = conftest.create_exercise(course, 2, index=3) solution1 = conftest.create_solution(exercise, student_user) solution2 = conftest.create_solution(exercise2, student_user) solution3 = conftest.create_solution(exercise, student_user2) assert len(list(Solution.select())) == 3 unchecked = solutions.get_next_unchecked(exercise.id) assert unchecked is not None assert unchecked.exercise.id == solution1.exercise.id assert unchecked == solution1 solutions.mark_as_checked(solution1.id, staff_user) unchecked = solutions.get_next_unchecked(exercise.id) assert unchecked is not None assert unchecked.exercise.id == solution3.exercise.id assert unchecked == solution3 solutions.mark_as_checked(solution3.id, staff_user) unchecked = solutions.get_next_unchecked(exercise.id) assert unchecked is None unchecked = solutions.get_next_unchecked() assert unchecked is not None assert unchecked == solution2 solutions.mark_as_checked(solution2.id, staff_user) unchecked = solutions.get_next_unchecked() assert unchecked is None unchecked = solutions.get_next_unchecked(solution2.id) assert unchecked is None
def start_checking(exercise_id): next_solution = solutions.get_next_unchecked(exercise_id) if solutions.start_checking(next_solution): return redirect(f'{routes.SOLUTIONS}/{next_solution.id}') return redirect(routes.STATUS)
def done_checking(exercise_id, solution_id): is_updated = solutions.mark_as_checked(solution_id, current_user.id) next_solution = solutions.get_next_unchecked(exercise_id) next_solution_id = getattr(next_solution, 'id', None) return jsonify({'success': is_updated, 'next': next_solution_id})