class FKSRules(FinishedRounds, CompetitionRules): RESULTS_TAGS = { FKS_B: ResultsTag(key=FKS_B, name='B'), FKS_A: ResultsTag(key=FKS_A, name='A'), } RESULTS_GENERATOR_CLASS = FKSResultsGenerator
class KMSRules(FinishedRounds, CompetitionRules): RESULTS_TAGS = { KMS_ALFA: ResultsTag(key=KMS_ALFA, name="Alfa"), KMS_BETA: ResultsTag(key=KMS_BETA, name="Beta"), } RESULTS_GENERATOR_CLASS = KMSResultsGenerator
class KSPRules(CompetitionRules): RESULTS_TAGS = { KSP_Z: ResultsTag(key=KSP_Z, name='Z'), KSP_O: ResultsTag(key=KSP_O, name='O'), } RESULTS_GENERATOR_CLASS = KSPResultsGenerator
class KSPRules(CompetitionRules): RESULTS_TAGS = OrderedDict([(KSP_ALL, ResultsTag(key=KSP_ALL, name='')), (KSP_L1, ResultsTag(key=KSP_L1, name='L1')), (KSP_L2, ResultsTag(key=KSP_L2, name='L2')), (KSP_L3, ResultsTag(key=KSP_L3, name='L3')), (KSP_L4, ResultsTag(key=KSP_L4, name='L4'))]) RESULTS_GENERATOR_CLASS = KSPResultsGenerator
class KSPRules(CompetitionRules): RESULTS_TAGS = OrderedDict([ (KSP_ALL, ResultsTag(key=KSP_ALL, name="")), (KSP_L1, ResultsTag(key=KSP_L1, name="L1")), (KSP_L2, ResultsTag(key=KSP_L2, name="L2")), (KSP_L3, ResultsTag(key=KSP_L3, name="L3")), (KSP_L4, ResultsTag(key=KSP_L4, name="L4")), ]) RESULTS_GENERATOR_CLASS = KSPResultsGenerator
class CompetitionRules(object): RESULTS_TAGS = {DEFAULT_TAG_KEY: ResultsTag(key=DEFAULT_TAG_KEY, name="")} RESULTS_GENERATOR_CLASS = ResultsGenerator def get_Q_for_graded_submits(self): return models.Q( time__lte=models.F("task__round__end_time")) | models.Q( testing_status=submit_constants.SUBMIT_STATUS_REVIEWED) def get_results_tags(self): return (self.RESULTS_TAGS[tag_key] for tag_key in self.RESULTS_TAGS) def get_results_generator(self, tag_key): if tag_key in self.RESULTS_TAGS: return self.RESULTS_GENERATOR_CLASS(tag=self.RESULTS_TAGS[tag_key]) raise KeyError(tag_key) def get_previous_round(self, round): qs = round.semester.round_set.filter(number=round.number - 1) if qs: return qs.get() else: return None def get_actual_result_rounds(self, competition): rounds = Round.objects.filter( semester__competition=competition, visible=True, end_time__gte=timezone.now() - timezone.timedelta(days=MAX_DAYS_TO_SHOW_ROUND_IN_ACTUAL_RESULTS), ) return rounds.order_by("-end_time", "-number")[:1]
class CompetitionRules(object): RESULTS_TAGS = {DEFAULT_TAG_KEY: ResultsTag(key=DEFAULT_TAG_KEY, name='')} RESULTS_GENERATOR_CLASS = ResultsGenerator def get_Q_for_graded_submits(self): return ( models.Q(time__lte=models.F('task__round__end_time')) | models.Q(testing_status=submit_constants.SUBMIT_STATUS_REVIEWED)) def get_results_tags(self): return (self.RESULTS_TAGS[tag_key] for tag_key in self.RESULTS_TAGS) def get_results_generator(self, tag_key): if tag_key in self.RESULTS_TAGS: return self.RESULTS_GENERATOR_CLASS(tag=self.RESULTS_TAGS[tag_key]) raise KeyError(tag_key) def get_previous_round(self, round): qs = round.semester.round_set.filter(number=round.number - 1) if qs: return qs.get() else: return None def get_actual_result_rounds(self, competition): rounds = Round.objects.filter(semester__competition=competition, visible=True) return rounds.order_by('-end_time', '-number')[:1]
class CompetitionRules(object): RESULTS_TAGS = {DEFAULT_TAG_KEY: ResultsTag(key=DEFAULT_TAG_KEY, name="")} RESULTS_GENERATOR_CLASS = ResultsGenerator def get_Q_for_graded_submits(self): return models.Q( time__lte=models.F("task__round__end_time")) | models.Q( testing_status=submit_constants.SUBMIT_STATUS_REVIEWED) def get_results_tags(self): return (self.RESULTS_TAGS[tag_key] for tag_key in self.RESULTS_TAGS) def get_results_generator(self, tag_key): if tag_key in self.RESULTS_TAGS: return self.RESULTS_GENERATOR_CLASS(tag=self.RESULTS_TAGS[tag_key]) raise KeyError(tag_key) def get_previous_round(self, round): qs = round.semester.round_set.filter(number=round.number - 1) if qs: return qs.get() else: return None def get_actual_result_rounds(self, competition): rounds = Round.objects.filter( semester__competition=competition, visible=True, end_time__gte=timezone.now() - timezone.timedelta(days=MAX_DAYS_TO_SHOW_ROUND_IN_ACTUAL_RESULTS), ) return rounds.order_by("-end_time", "-number")[:1] def grade_text_submit(self, task, user, submitted_text): Grading = namedtuple("Grading", ["response", "points"]) solution = [solution.lower() for solution in task.text_submit_solution] if submitted_text in solution: response = submit_constants.SUBMIT_RESPONSE_OK points = task.description_points else: response = submit_constants.SUBMIT_RESPONSE_WA points = 0 return Grading(response, points)
class SUSIRules(CompetitionRules): RESULTS_TAGS = { constants.SUSI_CIFERSKY_CECH: ResultsTag(key=constants.SUSI_CIFERSKY_CECH, name=constants.SUSI_CIFERSKY_CECH), constants.SUSI_AGAT: ResultsTag(key=constants.SUSI_AGAT, name=constants.SUSI_AGAT), constants.SUSI_BLYSKAVICA: ResultsTag(key=constants.SUSI_BLYSKAVICA, name=constants.SUSI_BLYSKAVICA), } RESULTS_GENERATOR_CLASS = SUSIResultsGenerator def get_actual_result_rounds(self, competition): active_rounds = Round.objects.filter( semester__competition=competition, visible=True, second_end_time__gte=timezone.now(), ) if len(active_rounds) > 0: return active_rounds.order_by("number", "end_time")[:1] finished_rounds = Round.objects.filter( semester__competition=competition, visible=True, second_end_time__lte=timezone.now(), end_time__gte=timezone.now() - timezone.timedelta(days=MAX_DAYS_TO_SHOW_ROUND_IN_ACTUAL_RESULTS), ) return finished_rounds.order_by("-end_time", "-number")[:1] def get_previous_round(self, round): previous_number = min(round.number - 1, 2) qs = round.semester.round_set.filter(number=previous_number) if qs: return qs.get() else: return None def grade_text_submit(self, task, user, submitted_text): submitted_text = unidecode(submitted_text.replace(" ", "").lower()) now = timezone.now() Grading = namedtuple("Grading", ["response", "points"]) solutions = [ unidecode(solution.replace(" ", "").lower()) for solution in task.text_submit_solution ] if submitted_text in solutions: response = SUBMIT_RESPONSE_OK points = constants.SUSI_POINTS_ALLOCATION[0] if (task.round.end_time < now <= task.round.susi_big_hint_date and len(task.susi_small_hint) > 0): points -= constants.SUSI_POINTS_ALLOCATION[1] elif (task.round.susi_big_hint_date < now and task.round.second_phase_running and len(task.susi_big_hint) > 0): points -= constants.SUSI_POINTS_ALLOCATION[2] elif now > task.round.end_time and not task.round.second_phase_running: points = constants.SUSI_POINTS_ALLOCATION[3] else: response = SUBMIT_RESPONSE_WA points = constants.SUSI_POINTS_ALLOCATION[3] max_time = task.round.second_end_time if max_time is None: max_time = task.round.end_time wrong_submits = len( Submit.objects.filter( task=task, user=user, time__lte=max_time).exclude(text__in=solutions)) points = max( points - wrong_submits // constants.SUSI_WRONG_SUBMITS_TO_PENALTY, 0) return Grading(response, points)