Skip to content

Commit

Permalink
check if solved before returning timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhwanlazy committed Jul 27, 2023
1 parent f343336 commit ded104f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ps_trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def start_session(user, problem, sdb, timeout=3600, message='', show_problem_rat
prompt.append( 'Message : {message}')
prompt.append('\n[s]olved, [g]iveup, [q]uit\n')
prompt = '\n'.join(prompt)

while True:
remaining_time = timeout - (time.time() - start_time)
remaining_min = int(remaining_time) // 60
Expand All @@ -74,6 +75,12 @@ def start_session(user, problem, sdb, timeout=3600, message='', show_problem_rat
logger.info('quited session. it will automatically resumed when you start new session')
return 'quit'
message = f'"{char}" is not valid input!'
logger.info('session timed out!')
return 'timeout'

if check_solved(user, problem, sdb):
logger.info('congrats you solved the problem!')
logger.debug('solved')
return 'solve'
else:
logger.info('session timed out!')
return 'timeout'

0 comments on commit ded104f

Please sign in to comment.