Exemple #1
0
    def from_raw(cls, contest_id, user_id):
        '''
    This will get all the scores for the specific user.
    Also, this will get the task_ordering for the contest.

    This function also sets self.score.
    '''

        scores = Score.get_scores(contest_id, user_id)
        contest = Contest.get_contest(contest_id)
        ordered_task_ids = contest.get_task_ordering()

        done_task_ids = []
        task_by_id = {}
        score_by_task_id = {}

        for s in scores:
            task_by_id[s.task.id] = s.task
            score_by_task_id[s.task.id] = s
            if s.solved or s.skipped:
                done_task_ids.append(s.task.id)

        instance = cls(done_task_ids, ordered_task_ids)
        instance.scores = scores
        instance.task_by_id = task_by_id
        instance.score_by_task_id = score_by_task_id
        instance.visible_task_ids = instance.get_visible_task_ids()
        instance.visible_tasks = instance.get_visible_tasks()
        return instance
Exemple #2
0
  def from_raw(cls, contest_id, user_id):
    '''
    This will get all the scores for the specific user.
    Also, this will get the task_ordering for the contest.

    This function also sets self.score.
    '''

    scores = Score.get_scores(contest_id, user_id)
    contest = Contest.get_contest(contest_id)
    ordered_task_ids = contest.get_task_ordering()

    done_task_ids = []
    task_by_id = {}
    score_by_task_id = {}

    for s in scores:
      task_by_id[s.task.id] = s.task
      score_by_task_id[s.task.id] = s
      if s.solved or s.skipped:
        done_task_ids.append(s.task.id)

    instance = cls(done_task_ids, ordered_task_ids)
    instance.scores = scores
    instance.task_by_id = task_by_id
    instance.score_by_task_id = score_by_task_id
    instance.visible_task_ids = instance.get_visible_task_ids()
    instance.visible_tasks = instance.get_visible_tasks()
    return instance
Exemple #3
0
 def _preset_scores(self):
     order = self.get_task_ordering()
     for u in self.registered_users.all():
         for task_id in order:
             Score.create_entry(self.id, u.id, task_id)
Exemple #4
0
 def _preset_scores(self):
   order = self.get_task_ordering()
   for u in self.registered_users.all():
     for task_id in order:
       Score.create_entry(self.id, u.id, task_id)