Esempio n. 1
0
def submit_solution_mutate(_root,
                           info,
                           problem_id: int,
                           language_id: int,
                           source_code: File) -> Submission:
    user = get_me(info.context)
    return submit_solution(user, problem_id, language_id, source_code)
Esempio n. 2
0
def update_contest_mutate(_root, info, contest: UpdateContestInput) -> Contest:
    user = get_me(info.context)
    new_contest = update_contest(user, contest.name, contest.short_description,
                                 contest.description, contest.start_time,
                                 contest.finish_time, contest.freezed,
                                 contest.grading_size,
                                 contest.permitted_languages)
    return new_contest
Esempio n. 3
0
def create_problem_mutate(_root, info, problem: ProblemInput) -> Problem:
    user = get_me(info.context)
    return create_problem(user,
                          problem.short_id,
                          problem.name,
                          problem.statement,
                          problem.disabled,
                          problem.time_limit,
                          problem.tolerance,
                          problem.memory_limit,
                          problem.output_limit,
                          problem.tcgen_language_id,
                          problem.tcgen_source_code,
                          problem.solution_language_id,
                          problem.solution_source_code,
                          problem.checker_language_id,
                          problem.checker_source_code,)
Esempio n. 4
0
    def get(self, request):
        try:
            try:
                my_user = get_me(request)
            except AuthenticationError as err:
                return HttpResponse(err, status=403)

            job_token, spec = get_grading_job(my_user)

            if spec is None:
                return HttpResponse('No Job', status=404)

            filename = spec.name.split('/')[-1]
            response = HttpResponse(spec, content_type='text/plain')
            response[
                'Content-Disposition'] = 'attachment; filename="%s"' % filename
            response['X-JOB-TOKEN'] = job_token

            return response
        except ValueError as err:
            return HttpResponse(err, status=500)
Esempio n. 5
0
def submissions_resolver(_root, info) -> Iterable[Submission]:
    user = get_me(info.context)
    return get_contest_submissions(user, user.contest.id)
Esempio n. 6
0
def submission_resolver(_root, info, submission_id: int) -> Submission:
    user = get_me(info.context)
    return get_submission_by_id(user, submission_id)
Esempio n. 7
0
def problem_resolver(_root, info, problem_id: int) -> Problem:
    user = get_me(info.context)
    return get_problem_by_id(user, problem_id)
Esempio n. 8
0
def delete_problem_mutate(_root, info, problem_id: int) -> str:
    user = get_me(info.context)
    return delete_problem(user, problem_id)
Esempio n. 9
0
def problems_resolver(_root, info) -> Iterable[Problem]:
    user = get_me(info.context)
    return get_contest_problems(user, user.contest.id)
Esempio n. 10
0
def my_contest_resolver(_root, info) -> Contest:
    user = get_me(info.context)
    return get_contest_by_id(user.contest.id)
Esempio n. 11
0
def contest_submissions_resolver(root: Contest, info) -> Iterable[Submission]:
    user = get_me(info.context)
    return get_contest_submissions(user, root.id)
Esempio n. 12
0
def contest_problems_resolver(root: Contest, info) -> Iterable[Problem]:
    user = get_me(info.context)
    return get_contest_problems(user, root.id)
Esempio n. 13
0
def update_user_permissions_mutate(_root, info, user_id: int,
                                   permissions: List[str]) -> User:
    user = get_me(info.context)
    return update_permissions(user, user_id, permissions)
Esempio n. 14
0
def invite_users_mutate(_root, info, emails: List[str],
                        permissions: List[str]) -> Iterable[User]:
    user = get_me(info.context)
    return invite_users(user, emails, permissions)