oioioi.programs.controllers

Module Contents

Classes

ProgrammingProblemController

Defines rules for handling specific problem.

ProgrammingContestController

Contains the contest logic and rules.

Functions

get_report_display_type(request, test_report)

Attributes

oioioi.programs.controllers.logger[source]
oioioi.programs.controllers.get_report_display_type(request, test_report)[source]
class oioioi.programs.controllers.ProgrammingProblemController(problem)[source]

Bases: oioioi.problems.controllers.ProblemController

Defines rules for handling specific problem.

Every method should:

  • be called from contest controller

  • or be specific for problems that this controller controls

Please note that a global problem instance exists for each problem. That problem instance has no contest (contest is None), so methods can’t be overridden by a contest controller which means they behave in a default way.

description[source]
get_compiler_for_submission(submission)[source]
get_compiler_for_language(problem_instance, language)[source]
generate_initial_evaluation_environ(environ, submission, **kwargs)[source]
generate_base_environ(environ, submission, **kwargs)[source]
generate_recipe(kinds)[source]
get_compilation_result_size_limit(submission)[source]
fill_evaluation_environ(environ, submission, **kwargs)[source]

Fills a minimal environment with evaluation receipt and other values required by the evaluation machinery.

Passed environ should already contain entries for the actiual data to be judged (for example the source file to evaluate).

Details on which keys need to be present should be specified by particular subclasses.

As the result, environ will be filled at least with a suitable evaluation recipe.

_map_report_to_submission_status(status, problem_instance, kind='INITIAL')[source]
update_submission_score(submission)[source]
get_submission_size_limit(problem_instance)[source]
check_repeated_submission(request, problem_instance, form)[source]
validate_submission_form(request, problem_instance, form, cleaned_data)[source]
mixins_for_admin()[source]

Returns an iterable of mixins to add to the default oioioi.problems.admin.ProblemAdmin for this particular problem.

The default implementation returns an empty tuple.

create_submission(request, problem_instance, form_data, judge_after_create=True, **kwargs)[source]
_add_langs_to_form(request, form, problem_instance)[source]
adjust_submission_form(request, form, problem_instance)[source]
static _add_js(form, js)[source]
render_submission(request, submission)[source]
render_report_failure(request, report)[source]
is_admin(request, report)[source]
render_report(request, report)[source]

Renders the given report to HTML.

Default implementation supports only rendering reports of kind FAILURE and raises NotImplementedError otherwise.

can_generate_user_out(request, submission_report)[source]

Determines if the current user is allowed to generate outs from submission_report.

Default implementations allow only problem admins.

can_see_source(request, submission)[source]
can_see_test_comments(request, submissionreport)[source]
can_see_test(request, test)[source]
can_see_checker_exe(request, checker)[source]
get_visible_reports_kinds(request, submission)[source]
filter_visible_reports(request, submission, queryset)[source]

Determines which reports the user should be able to see.

It needs to check whether the submission is visible to the user and submission is submitted without contest.

Parameters
  • request – Django request

  • submission – instance of Submission

  • queryset – a queryset, initially filtered at least to select only given submission’s reports

Returns

updated queryset

_out_generate_status(request, testreport)[source]
get_safe_exec_mode()[source]

Determines execution mode when USE_UNSAFE_EXEC is False.

Return ‘sio2jail’ if you want to use SIO2Jail. Otherwise return ‘cpu’.

get_allowed_languages()[source]

Determines which languages are allowed for submissions.

Renders the given submission footer to HTML.

Footer is shown under the submission reports. The default implementation returns an empty string.

get_allowed_languages_for_problem(problem)[source]
class oioioi.programs.controllers.ProgrammingContestController(contest)[source]

Bases: oioioi.contests.controllers.ContestController

Contains the contest logic and rules.

This is the computerized implementation of the contest’s official rules.

description[source]
get_compiler_for_submission(submission)[source]
get_compiler_for_language(problem_instance, language)[source]
_map_report_to_submission_status(status, problem_instance, kind='INITIAL')[source]
get_compilation_result_size_limit(submission)[source]
fill_evaluation_environ(environ, submission)[source]
fill_evaluation_environ_post_problem(environ, submission)[source]

Run after ProblemController.fill_evaluation_environ.

get_submission_size_limit(problem_instance)[source]
check_repeated_submission(request, problem_instance, form)[source]
update_report_statuses(submission, queryset)[source]

Updates statuses of reports for the newly judged submission.

Usually this involves looking at reports and deciding which should be ACTIVE and which should be SUPERSEDED.

Parameters
can_see_submission_status(request, submission)[source]

Statuses are taken from initial tests which are always public.

can_see_test(request, test)[source]
can_see_checker_exe(request, checker)[source]
get_visible_reports_kinds(request, submission)[source]
filter_visible_reports(request, submission, queryset)[source]

Determines which reports the user should be able to see.

It need not check whether the submission is visible to the user.

The default implementation uses results_visible().

Parameters
  • request – Django request

  • submission – instance of Submission

  • queryset – a queryset, initially filtered at least to select only given submission’s reports

Returns

updated queryset

filter_my_visible_submissions(request, queryset, filter_user=True)[source]

Returns the submissions which the user should see in the “My submissions” view.

The default implementation returns all submissions belonging to the user for the problems that are visible, except for admins, which get all their submissions.

Should return the updated queryset.

can_generate_user_out(request, submission_report)[source]

Determines if the current user is allowed to generate outs from submission_report.

Default implementations delegates to report_actions_config associated with the problem, can_see_problem(), filter_my_visible_submissions(), except for admins and observers, which get full access.

filter_visible_sources(request, queryset)[source]

Determines which sources the user could see.

This usually involves cross-user privileges, like publicizing sources. Default implementations delegates to filter_my_visible_submissions(), except for admins and observers, which get full access.

Queryset’s model should be oioioi.contest.Submission

can_see_source(request, submission)[source]

Check if submission’s source should be visible. :type submission: oioioi.contest.Submission

Consider using filter_visible_sources instead, especially for batch queries.

render_submission(request, submission)[source]

Renders the given submission to HTML.

This is usually a table with some basic submission info, source code download etc., displayed on the top of the submission details view, above the reports.

_out_generate_status(request, testreport)[source]
can_see_test_comments(request, submissionreport)[source]
render_report_failure(request, report)[source]
is_admin(request, report)[source]
render_report(request, report)[source]
valid_kinds_for_submission(submission)[source]
get_safe_exec_mode()[source]

Determines execution mode when USE_UNSAFE_EXEC is False.

Return ‘sio2jail’ if you want to use SIO2Jail. Otherwise return ‘cpu’.

get_default_safe_exec_mode()[source]
get_allowed_languages()[source]

Determines which languages are allowed for submissions.