예제 #1
0
파일: controllers.py 프로젝트: tmkkk/oioioi
 def render_report(self, request, report):
     problem = report.submission.problem_instance.problem
     return ProblemController.render_report(problem.controller, request, report)
예제 #2
0
 def render_report_failure(self, request, report):
     return ProblemController.render_report(self, request, report)
예제 #3
0
           suggestion can be returned
        """
        user_level = Experience(user).current_level

        if user_level >= SuggestLvl5From:
            qset = get_problems_by_difficulty(DIFFICULTY.IMPOSSIBLE)
        elif user_level >= SuggestLvl4From:
            qset = get_problems_by_difficulty(DIFFICULTY.HARD)
        elif user_level >= SuggestLvl3From:
            qset = get_problems_by_difficulty(DIFFICULTY.MEDIUM)
        elif user_level >= SuggestLvl2From:
            qset = get_problems_by_difficulty(DIFFICULTY.EASY)
        else:
            qset = get_problems_by_difficulty(DIFFICULTY.TRIVIAL)

        try:
            return qset.filter(is_public=True).order_by('?').first()
        except Problem.DoesNotExist:
            return None


class DifficultyProblemMixin(object):
    """A class to mix-in with problem controller, overriding fill_ev
       to update difficulty rows"""
    def adjust_problem(self):
        """Creates row with difficulty for current problem"""
        super(DifficultyProblemMixin, self).adjust_problem()
        _update_problem_difficulty(self.problem)

ProblemController.mix_in(DifficultyProblemMixin)
예제 #4
0
 def render_report(self, request, report):
     problem = report.submission.problem_instance.problem
     return ProblemController.render_report(problem.controller, request,
                                            report)
예제 #5
0
 def render_report_failure(self, request, report):
     return ProblemController.render_report(self, request, report)
예제 #6
0
            return None

        user_level = Experience(user).current_level

        if user_level >= SuggestLvl5From:
            qset = get_problems_by_difficulty(DIFFICULTY.IMPOSSIBLE)
        elif user_level >= SuggestLvl4From:
            qset = get_problems_by_difficulty(DIFFICULTY.HARD)
        elif user_level >= SuggestLvl3From:
            qset = get_problems_by_difficulty(DIFFICULTY.MEDIUM)
        elif user_level >= SuggestLvl2From:
            qset = get_problems_by_difficulty(DIFFICULTY.EASY)
        else:
            qset = get_problems_by_difficulty(DIFFICULTY.TRIVIAL)

        try:
            return qset.filter(is_public=True).order_by('?').first()
        except Problem.DoesNotExist:
            return None


class DifficultyProblemMixin(object):
    """A class to mix-in with problem controller, overriding fill_ev
       to update difficulty rows"""
    def adjust_problem(self):
        """Creates row with difficulty for current problem"""
        super(DifficultyProblemMixin, self).adjust_problem()
        _update_problem_difficulty(self.problem)

ProblemController.mix_in(DifficultyProblemMixin)