from oioioi.contests.controllers import submission_template_context
from oioioi.programs.controllers import ProgrammingProblemController, \
    ProgrammingContestController
from oioioi.scoresreveal.utils import has_scores_reveal, is_revealed
from oioioi.scoresreveal.models import ScoreReveal


class ScoresRevealProblemControllerMixin(object):
    def mixins_for_admin(self):
        from oioioi.scoresreveal.admin import \
            ScoresRevealProgrammingProblemAdminMixin
        return super(ScoresRevealProblemControllerMixin, self) \
            .mixins_for_admin() + (ScoresRevealProgrammingProblemAdminMixin,)


ProgrammingProblemController.mix_in(ScoresRevealProblemControllerMixin)


class ScoresRevealContestControllerMixin(object):
    def can_see_submission_score(self, request, submission):
        return super(ScoresRevealContestControllerMixin, self) \
            .can_see_submission_score(request, submission) or \
            is_revealed(submission)

    def reveal_score(self, request, submission):
        assert has_scores_reveal(submission.problem)
        assert self.can_reveal(request, submission)[0]

        _obj, created = ScoreReveal.objects.get_or_create(
            submission=submission)
        return created
Exemple #2
0
        ]
        extend_after_placeholder(environ, 'after_compile', recipe_body)

        environ['error_handlers'].append(
            ('delete_output', 'oioioi.testrun.handlers.delete_output'))

        environ['save_outputs'] = True
        environ['check_outputs'] = False

    def mixins_for_admin(self):
        from oioioi.testrun.admin import TestRunProgrammingProblemAdminMixin
        return super(TestRunProblemControllerMixin, self) \
                .mixins_for_admin() + (TestRunProgrammingProblemAdminMixin,)


ProgrammingProblemController.mix_in(TestRunProblemControllerMixin)


class TestRunContestControllerMixin(object):
    def fill_evaluation_environ_post_problem(self, environ, submission):
        if submission.kind != 'TESTRUN':
            return super(TestRunContestControllerMixin, self) \
                    .fill_evaluation_environ_post_problem(environ, submission)

    def get_testrun_input_limit(self):
        return getattr(settings, 'TESTRUN_INPUT_LIMIT', 100 * 1024)

    def adjust_submission_form(self, request, form):
        super(TestRunContestControllerMixin, self) \
            .adjust_submission_form(request, form)
Exemple #3
0
from oioioi.contests.models import Submission
from oioioi.contests.controllers import submission_template_context
from oioioi.programs.controllers import ProgrammingProblemController, \
    ProgrammingContestController
from oioioi.scoresreveal.utils import has_scores_reveal, is_revealed
from oioioi.scoresreveal.models import ScoreReveal, ScoreRevealConfig


class ScoresRevealProblemControllerMixin(object):
    def mixins_for_admin(self):
        from oioioi.scoresreveal.admin import \
            ScoresRevealProgrammingProblemAdminMixin
        return super(ScoresRevealProblemControllerMixin, self) \
            .mixins_for_admin() + (ScoresRevealProgrammingProblemAdminMixin,)

ProgrammingProblemController.mix_in(ScoresRevealProblemControllerMixin)


class ScoresRevealContestControllerMixin(object):
    def use_spliteval(self, submission):
        return super(ScoresRevealContestControllerMixin, self) \
                .use_spliteval(submission) and not ScoreRevealConfig.objects \
                .filter(problem=submission.problem)

    def can_see_submission_score(self, request, submission):
        return super(ScoresRevealContestControllerMixin, self) \
            .can_see_submission_score(request, submission) or \
            is_revealed(submission)

    def reveal_score(self, request, submission):
        assert has_scores_reveal(submission.problem)
Exemple #4
0
        if (hasattr(problem_instance.problem, 'test_run_config')
                and hasattr(problem_instance, 'test_run_config')):
            test_runs_limit = problem_instance.test_run_config.test_runs_limit
        else:
            test_runs_limit = settings.DEFAULT_TEST_RUNS_LIMIT

        return test_runs_limit

    def mixins_for_admin(self):
        from oioioi.testrun.admin import TestRunProgrammingProblemAdminMixin
        return super(TestRunProblemControllerMixin, self) \
                .mixins_for_admin() + (TestRunProgrammingProblemAdminMixin,)


ProgrammingProblemController.mix_in(TestRunProblemControllerMixin)


class TestRunContestControllerMixin(object):
    """ContestController mixin that sets up testrun app for the contest.
    """

    def fill_evaluation_environ_post_problem(self, environ, submission):
        if submission.kind != 'TESTRUN':
            return super(TestRunContestControllerMixin, self) \
                    .fill_evaluation_environ_post_problem(environ, submission)

    def get_testrun_input_limit(self):
        return getattr(settings, 'TESTRUN_INPUT_LIMIT', 100 * 1024)

    def get_testrun_zipped_input_limit(self):
Exemple #5
0
if CODE_SHARING_FRIENDS_ENABLED:
    CodeSharingFriendsController.set_up()


class CodeSharingProgramControllerMixin(object):
    """A mixin allowing users to see shared submissions' contents.
    """
    def can_see_source(self, request, submission):
        prev = super(CodeSharingProgramControllerMixin, self) \
                .can_see_source(request, submission)

        return prev or CodeSharingController().can_see_code(
                submission.problem, request.user, submission.user)

ProgrammingProblemController.mix_in(CodeSharingProgramControllerMixin)


class CodeSharingContestControllerMixin(object):
    """A mixin allowing users to see shared submissions' contents.
    """
    def filter_visible_sources(self, request, queryset):
        prev = super(CodeSharingContestControllerMixin, self) \
                .filter_visible_sources(request, queryset)

        if not request.user.is_authenticated():
            return prev

        shared = CodeSharingController().all_shared_with_me(request.user)
        return prev | queryset.filter(id__in=shared)
Exemple #6
0
if CODE_SHARING_FRIENDS_ENABLED:
    CodeSharingFriendsController.set_up()


class CodeSharingProgramControllerMixin(object):
    """A mixin allowing users to see shared submissions' contents.
    """
    def can_see_source(self, request, submission):
        prev = super(CodeSharingProgramControllerMixin, self) \
                .can_see_source(request, submission)

        return prev or CodeSharingController().can_see_code(
                submission.problem, request.user, submission.user)

ProgrammingProblemController.mix_in(CodeSharingProgramControllerMixin)


class CodeSharingContestControllerMixin(object):
    """A mixin allowing users to see shared submissions' contents.
    """
    def filter_visible_sources(self, request, queryset):
        prev = super(CodeSharingContestControllerMixin, self) \
                .filter_visible_sources(request, queryset)

        if not request.user.is_authenticated():
            return prev

        shared = CodeSharingController().all_shared_with_me(request.user)
        return prev | queryset.filter(id__in=shared)