Esempio n. 1
0
def judge_submission_on_contest(submission: Submission, callback=None, **kwargs):

    def _callback():
        invalidate_contest_participant(contest, submission.author_id)
        invalidate_contest_problem(contest, submission.problem_id)
        if callback:
            callback()

    contest = submission.contest or kwargs.get('contest')
    sync = kwargs.get('sync', False)
    if contest is None:
        raise ValueError('Judge on "None" contest')
    cases = 'all' if contest.system_tested else contest.run_tests_during_contest
    # print(cases)
    run_until_complete = contest.scoring_method == 'oi' and not submission.problem.group_enabled
    if not submission.contest:
        cases = 'all'
        _callback = None

    if cases != 'none':
        judge_submission_on_problem(submission, callback=_callback, case=cases,
                                    run_until_complete=run_until_complete,
                                    status_for_pretest=cases != 'all', sync=sync)
    else:
        submission.status = SubmissionStatus.SUBMITTED
        submission.save(update_fields=['status'])
        Thread(target=_callback).start()
Esempio n. 2
0
def rejudge_submission(submission, callback=None, run_until_complete=False):
    if submission.contest_id:
        judge_submission_on_contest(submission, callback=callback, sync=True)
    else:
        judge_submission_on_problem(submission,
                                    callback=callback,
                                    sync=True,
                                    run_until_complete=run_until_complete)
Esempio n. 3
0
def judge_submission_on_contest(submission: Submission,
                                callback=None,
                                **kwargs):
    def _callback():
        invalidate_contest_participant(contest, submission.author_id)
        if callback:
            callback()

    contest = submission.contest
    cases = 'all' if contest.status > 0 else contest.run_tests_during_contest
    run_until_complete = contest.scoring_method == 'oi'
    if cases != 'none':
        judge_submission_on_problem(submission,
                                    callback=_callback,
                                    case=cases,
                                    status_private=contest.is_frozen,
                                    run_until_complete=run_until_complete,
                                    status_for_pretest=cases != 'all')
    else:
        submission.status = submission.status_private = SubmissionStatus.SUBMITTED
        submission.save(update_fields=['status', 'status_private'])
        Thread(target=_callback).start()
Esempio n. 4
0
def rejudge_submission(submission, callback=None):
    if submission.contest_id:
        judge_submission_on_contest(submission, callback=callback, sync=True)
    else:
        judge_submission_on_problem(submission, callback=callback, sync=True)