Esempio n. 1
0
 def skip_task(cls, contest_id, user_id, task_id):
   entry = cls.get_entry(contest_id, user_id, task_id)
   p = Participation.get_entry(contest_id, user_id)
   can_skip = p.skips_left > 0 and entry.can_skip()
   if can_skip:
     entry.skipped = True
     entry.save()
     p.skip_task()
     LogEntry.skip_task(contest_id, user_id, task_id)
   else:
     raise IntegrityError
Esempio n. 2
0
 def solve_task(cls, contest_id, user_id, task_id):
   entry = cls.get_entry(contest_id, user_id, task_id)
   if not entry.solved:
     if entry.skipped == True:
       score = cls.SKIPPED
     else:
       score = cls.FULL
     entry.score = score
     entry.solved = True
     entry._try_task()
     p = Participation.get_entry(contest_id, user_id)
     p.increment_score(score)
     LogEntry.solve_task(contest_id, user_id, task_id)
   else:
     raise IntegrityError
Esempio n. 3
0
 def unregister_user(self, user_id):
     if self.state == Contest.UNASSIGNED:
         Participation.get_entry(self.id, user_id).delete()
     else:
         raise ContestStartedException(self)
Esempio n. 4
0
 def unregister_user(self, user_id):
   if self.state == Contest.UNASSIGNED:
     Participation.get_entry(self.id, user_id).delete()
   else:
     raise ContestStartedException(self)