def home(): with tools.Contest() as contest: d = {'languages': list(sorted(list(contest['wrappers'].keys()))), 'questions': list(sorted(list(contest['questions'].keys()), key=lambda x: int(x))), 'intro': contest['intro'] } return tools.render('home.html', d)
def question_display(): pk, = jget('question_pk') statement = 'This question does not exist yet.' with tools.Contest() as contest: pk = str(pk) q = {'statement': 'This question does not exist'} if pk.isdigit(): if pk in contest['questions']: q = contest['questions'][pk] statement = q['statement'] return {'statement': statement}
def get_attempt_status(attempt_id): with tools.Contest() as contest: if attempt_id not in contest['attempts']: result, remark = None, 'The attempt has been sent to the judge' else: attempt = contest['attempts'][attempt_id] status = attempt['status'] if any(i is None for i in status): remark = 'The program raised an error' result = False elif all(status): remark = 'Your Program Cleared {} tests' remark = remark.format(sum(1 for i in status if i)) result = True elif not all(status): remark = 'Your Program did not clear some tests.' result = False return result, remark
def get_attempt_status(attempt_id): with tools.Contest() as contest: print("looking for->", attempt_id, "<-") if attempt_id == "No attempt Yet": result, remark = None, 'No attempt Yet' elif attempt_id not in contest['attempts']: print("not found") result, remark = None, 'The attempt has been sent to the judge' else: attempt = contest['attempts'][attempt_id] status = attempt['status'] if any(i is None for i in status): remark = 'The program raised an error or exceeded its resource limits' result = False elif all(status): remark = 'Your Program Cleared {} tests' remark = remark.format(sum(1 for i in status if i)) result = True elif not all(status): remark = 'Your Program did not clear some tests.' result = False return result, remark