Пример #1
0
def submit_view(request, problem_instance_id=None):
    if request.method == 'POST':
        form = SubmissionForm(request, request.POST, request.FILES)
        if form.is_valid():
            request.contest.controller.create_submission(
                request, form.cleaned_data['problem_instance'],
                form.cleaned_data)
            return redirect('my_submissions', contest_id=request.contest.id)
    else:
        initial = {}
        if problem_instance_id is not None:
            initial = {'problem_instance_id': int(problem_instance_id)}
        form = SubmissionForm(request, initial=initial)

    pis = form.get_problem_instances()
    submissions_left = {
        pi.id: pi.controller.get_submissions_left(request, pi)
        for pi in pis
    }
    return TemplateResponse(
        request,
        'contests/submit.html',
        {
            'form': form,
            'submissions_left': submissions_left
        },
    )
Пример #2
0
def testrun_submit_view(request):
    if request.method == 'POST':
        form = SubmissionForm(
            request,
            request.POST,
            request.FILES,
            kind='TESTRUN',
            problem_filter=filter_testrun_problem_instances,
        )
        if form.is_valid():
            request.contest.controller.create_testrun(
                request, form.cleaned_data['problem_instance'],
                form.cleaned_data)
            return redirect('my_submissions', contest_id=request.contest.id)
    else:
        form = SubmissionForm(request,
                              kind='TESTRUN',
                              problem_filter=filter_testrun_problem_instances)

    problem_instances = filter_testrun_problem_instances(
        form.get_problem_instances())

    submissions_left = {
        pi.id: pi.controller.get_submissions_left(request, pi, 'TESTRUN')
        for pi in problem_instances
    }

    # Testrun time limits in seconds.
    time_limits = {
        pi.id: float(pi.controller.get_test_run_time_limit(pi)) / 1000
        for pi in problem_instances
    }

    # Testrun memory limits in MB.
    memory_limits = {
        pi.id: pi.controller.get_test_run_memory_limit(pi) / 1024
        for pi in problem_instances
    }

    return TemplateResponse(
        request,
        'testrun/submit.html',
        {
            'form': form,
            'submissions_left': submissions_left,
            'time_limits': time_limits,
            'memory_limits': memory_limits,
        },
    )
Пример #3
0
def testrun_submit_view(request):
    if request.method == 'POST':
        form = SubmissionForm(request, request.POST, request.FILES,
                kind='TESTRUN',
                problem_filter=filter_testrun_problem_instances)
        if form.is_valid():
            request.contest.controller.create_testrun(request,
                    form.cleaned_data['problem_instance'], form.cleaned_data)
            return redirect('my_submissions', contest_id=request.contest.id)
    else:
        form = SubmissionForm(request, kind='TESTRUN',
                              problem_filter=filter_testrun_problem_instances)
    submissions_left = {pi.id: pi.controller.get_submissions_left(request, pi, 'TESTRUN')
                        for pi in form.get_problem_instances()}
    return TemplateResponse(request, 'testrun/submit.html',
                            {'form': form, 'submissions_left': submissions_left})
Пример #4
0
def submit_view(request, problem_instance_id=None):
    if request.method == 'POST':
        form = SubmissionForm(request, request.POST, request.FILES)
        if form.is_valid():
            request.contest.controller.create_submission(request,
                    form.cleaned_data['problem_instance'], form.cleaned_data)
            return redirect('my_submissions', contest_id=request.contest.id)
    else:
        initial = {}
        if problem_instance_id is not None:
            initial = {'problem_instance_id': int(problem_instance_id)}
        form = SubmissionForm(request, initial=initial)
    submissions_left = {pi.id: pi.controller.get_submissions_left(request, pi)
         for pi in form.get_problem_instances()}
    return TemplateResponse(request, 'contests/submit.html',
                            {'form': form, 'submissions_left': submissions_left})
Пример #5
0
def testrun_submit_view(request):
    if request.method == 'POST':
        form = SubmissionForm(request,
                              request.POST,
                              request.FILES,
                              kind='TESTRUN',
                              problem_filter=filter_testrun_problem_instances)
        if form.is_valid():
            request.contest.controller.create_testrun(
                request, form.cleaned_data['problem_instance'],
                form.cleaned_data)
            return redirect('my_submissions', contest_id=request.contest.id)
    else:
        form = SubmissionForm(request,
                              kind='TESTRUN',
                              problem_filter=filter_testrun_problem_instances)
    submissions_left = {
        pi.id: pi.controller.get_submissions_left(request, pi, 'TESTRUN')
        for pi in form.get_problem_instances()
    }
    return TemplateResponse(request, 'testrun/submit.html', {
        'form': form,
        'submissions_left': submissions_left
    })