def question_attempt(): qpk, lang, code, token = jget('question', 'language', 'code', 'token') user = tools.get_user(token) message, attid = 'Unexpected Error', None if user is not None: if tools.attempt_is_ok(qpk, lang, code): i, o = tools.get_question_io(qpk) wrap = tools.get_wrap(lang) attid = tools.random_id() judge.submit_attempt(code, i, o, wrap, attid, user, qpk) message = 'Submitted' else: message = 'Question/Language does not exist' else: message = 'Please login' # ------------------------------------------- return {'attempt': attid, 'message': message}
def user_details(): token, = jget('token') user = tools.get_user(token)['name'] score = tools.get_user_score(user) return {'user': user, 'score': score}