:py:mod:`oioioi.programs.controllers` ===================================== .. py:module:: oioioi.programs.controllers Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.programs.controllers.ProgrammingProblemController oioioi.programs.controllers.ProgrammingContestController Functions ~~~~~~~~~ .. autoapisummary:: oioioi.programs.controllers.get_report_display_type Attributes ~~~~~~~~~~ .. autoapisummary:: oioioi.programs.controllers.logger .. py:data:: logger .. py:function:: get_report_display_type(request, test_report) .. py:class:: ProgrammingProblemController(problem) Bases: :py:obj:`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. .. py:attribute:: description .. py:method:: get_compiler_for_submission(submission) .. py:method:: get_compiler_for_language(problem_instance, language) .. py:method:: generate_initial_evaluation_environ(environ, submission, **kwargs) .. py:method:: generate_base_environ(environ, submission, **kwargs) .. py:method:: generate_recipe(kinds) .. py:method:: get_compilation_result_size_limit(submission) .. py:method:: fill_evaluation_environ(environ, submission, **kwargs) 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``. .. py:method:: _map_report_to_submission_status(status, problem_instance, kind='INITIAL') .. py:method:: update_submission_score(submission) .. py:method:: get_submission_size_limit(problem_instance) .. py:method:: check_repeated_submission(request, problem_instance, form) .. py:method:: validate_submission_form(request, problem_instance, form, cleaned_data) .. py:method:: mixins_for_admin() Returns an iterable of mixins to add to the default :class:`oioioi.problems.admin.ProblemAdmin` for this particular problem. The default implementation returns an empty tuple. .. py:method:: create_submission(request, problem_instance, form_data, judge_after_create=True, **kwargs) .. py:method:: _add_langs_to_form(request, form, problem_instance) .. py:method:: adjust_submission_form(request, form, problem_instance) .. py:method:: _add_js(form, js) :staticmethod: .. py:method:: render_submission(request, submission) .. py:method:: render_report_failure(request, report) .. py:method:: is_admin(request, report) .. py:method:: render_report(request, report) Renders the given report to HTML. Default implementation supports only rendering reports of kind ``FAILURE`` and raises :py:exc:`NotImplementedError` otherwise. .. py:method:: can_generate_user_out(request, submission_report) Determines if the current user is allowed to generate outs from ``submission_report``. Default implementations allow only problem admins. .. py:method:: can_see_source(request, submission) .. py:method:: can_see_test_comments(request, submissionreport) .. py:method:: can_see_test(request, test) .. py:method:: can_see_checker_exe(request, checker) .. py:method:: get_visible_reports_kinds(request, submission) .. py:method:: filter_visible_reports(request, submission, queryset) 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. :param request: Django request :param submission: instance of :class:`~oioioi.contests.models.Submission` :param queryset: a queryset, initially filtered at least to select only given submission's reports :returns: updated queryset .. py:method:: _out_generate_status(request, testreport) .. py:method:: get_safe_exec_mode() Determines execution mode when `USE_UNSAFE_EXEC` is False. Return 'sio2jail' if you want to use SIO2Jail. Otherwise return 'cpu'. .. py:method:: get_allowed_languages() Determines which languages are allowed for submissions. .. py:method:: render_submission_footer(request, submission) Renders the given submission footer to HTML. Footer is shown under the submission reports. The default implementation returns an empty string. .. py:method:: get_allowed_languages_for_problem(problem) .. py:class:: ProgrammingContestController(contest) Bases: :py:obj:`oioioi.contests.controllers.ContestController` Contains the contest logic and rules. This is the computerized implementation of the contest's official rules. .. py:attribute:: description .. py:method:: get_compiler_for_submission(submission) .. py:method:: get_compiler_for_language(problem_instance, language) .. py:method:: _map_report_to_submission_status(status, problem_instance, kind='INITIAL') .. py:method:: get_compilation_result_size_limit(submission) .. py:method:: fill_evaluation_environ(environ, submission) .. py:method:: fill_evaluation_environ_post_problem(environ, submission) Run after ProblemController.fill_evaluation_environ. .. py:method:: get_submission_size_limit(problem_instance) .. py:method:: check_repeated_submission(request, problem_instance, form) .. py:method:: update_report_statuses(submission, queryset) 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``. :param submission: an instance of :class:`oioioi.contests.models.Submission` :param queryset: a queryset returning reports for the submission .. py:method:: can_see_submission_status(request, submission) Statuses are taken from initial tests which are always public. .. py:method:: can_see_test(request, test) .. py:method:: can_see_checker_exe(request, checker) .. py:method:: get_visible_reports_kinds(request, submission) .. py:method:: filter_visible_reports(request, submission, queryset) 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 :meth:`~ContestController.results_visible`. :param request: Django request :param submission: instance of :class:`~oioioi.contests.models.Submission` :param queryset: a queryset, initially filtered at least to select only given submission's reports :returns: updated queryset .. py:method:: filter_my_visible_submissions(request, queryset, filter_user=True) 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. .. py:method:: can_generate_user_out(request, submission_report) Determines if the current user is allowed to generate outs from ``submission_report``. Default implementations delegates to ``report_actions_config`` associated with the problem, :meth:`~ContestController.can_see_problem`, :meth:`~ContestController.filter_my_visible_submissions`, except for admins and observers, which get full access. .. py:method:: filter_visible_sources(request, queryset) Determines which sources the user could see. This usually involves cross-user privileges, like publicizing sources. Default implementations delegates to :meth:`~ContestController.filter_my_visible_submissions`, except for admins and observers, which get full access. Queryset's model should be oioioi.contest.Submission .. py:method:: can_see_source(request, submission) Check if submission's source should be visible. :type submission: oioioi.contest.Submission Consider using filter_visible_sources instead, especially for batch queries. .. py:method:: render_submission(request, submission) 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. .. py:method:: _out_generate_status(request, testreport) .. py:method:: can_see_test_comments(request, submissionreport) .. py:method:: render_report_failure(request, report) .. py:method:: is_admin(request, report) .. py:method:: render_report(request, report) .. py:method:: render_submission_footer(request, submission) .. py:method:: valid_kinds_for_submission(submission) .. py:method:: get_safe_exec_mode() Determines execution mode when `USE_UNSAFE_EXEC` is False. Return 'sio2jail' if you want to use SIO2Jail. Otherwise return 'cpu'. .. py:method:: get_default_safe_exec_mode() .. py:method:: get_allowed_languages() Determines which languages are allowed for submissions.