コード例 #1
0
    def test_solutions_of_user(
        staff_user: User,
        student_user: User,
        course: Course,
        solution: Solution,
        _assessments,
    ):
        conftest.create_usercourse(student_user, course)
        client = conftest.get_logged_user(staff_user.username)
        client.post(
            f'/assessment/{solution.id}',
            data=json.dumps({'assessment': 2}),
            content_type='application/json',
        )
        solution = Solution.get_by_id(solution.id)
        assert solution.assessment.name == 'Nice'

        client.post(
            f'/assessment/{solution.id}',
            data=json.dumps({'assessment': None}),
            content_type='application/json',
        )

        exercise2 = conftest.create_exercise(course, 2)
        solution2 = conftest.create_solution(exercise2, student_user)
        client.post(
            f'/assessment/{solution2.id}',
            data=json.dumps({'assessment': 3}),
            content_type='application/json',
        )
        solution2 = Solution.get_by_id(solution2.id)

        exercises = solution.of_user(student_user.id, from_all_courses=True)
        assert exercises[0].get('assessment') is None
        assert exercises[1].get('assessment') == 'Try again'
コード例 #2
0
ファイル: views.py プロジェクト: yaronneuman/lms
def exercises_page():
    fetch_archived = bool(request.args.get('archived'))
    exercises = Solution.of_user(current_user.id, fetch_archived)
    is_manager = current_user.role.is_manager
    return render_template(
        'exercises.html',
        exercises=exercises,
        is_manager=is_manager,
        fetch_archived=fetch_archived,
    )
コード例 #3
0
ファイル: views.py プロジェクト: zoharb157/lms
def user(user_id):
    if user_id != current_user.id and not current_user.role.is_manager:
        return fail(403, "You aren't allowed to watch this page.")
    target_user = User.get_or_none(User.id == user_id)
    if target_user is None:
        return fail(404, 'There is no such user.')

    return render_template(
        'user.html',
        solutions=Solution.of_user(target_user.id, with_archived=True),
        user=target_user,
    )
コード例 #4
0
def user(user_id):
    if user_id != current_user.id and not current_user.role.is_manager:
        return fail(403, "You aren't allowed to watch this page.")
    target_user = User.get_or_none(User.id == user_id)
    if target_user is None:
        return fail(404, 'There is no such user.')

    is_manager = current_user.role.is_manager

    return render_template(
        'user.html',
        solutions=Solution.of_user(
            target_user.id, with_archived=True, from_all_courses=True,
        ),
        user=target_user,
        is_manager=is_manager,
        notes_options=Note.get_note_options(),
        public_course_exists=Course.public_course_exists(),
    )