def robot_detail(robot_id, inputs=None): robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") runs = r.get_registry()['RUNS'].get_runs(robot_id) run_levels = [run['id'] for run in runs] # check if disqualifited and eligibility to advnace to next level eligibility = LevelProgressHandler.get_eligibility_for_next_run( runs, robot['level']) # get current best scores best_scores, attempted_levels, total_score, num_successful = ( ScoreCalculator.get_best_scores(runs)) return render_template( "robot.html", attempted_levels=attempted_levels, total_score=total_score, robot_id=robot_id, robot=robot, disqualified=eligibility['disqualified'], eligible=eligibility['can_level_up'], best_scores=best_scores, robot_runs=runs, applied_factors=[applied_factors(id, robot_id) for id in run_levels], inputs=inputs)
def robot_detail(robot_id, inputs=None): robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") runs = r.get_registry()['RUNS'].get_runs(robot_id) run_levels = [run['id'] for run in runs] # check if disqualifited and eligibility to advnace to next level eligibility = LevelProgressHandler.get_eligibility_for_next_run( runs, robot['level'] ) # get current best scores best_scores, attempted_levels, total_score, num_successful = ( ScoreCalculator.get_best_scores(runs) ) return render_template( "robot.html", attempted_levels=attempted_levels, total_score=total_score, robot_id=robot_id, robot=robot, disqualified=eligibility['disqualified'], eligible=eligibility['can_level_up'], best_scores=best_scores, robot_runs=runs, applied_factors=[applied_factors(id, robot_id) for id in run_levels], inputs=inputs )
def advance_level(robot_id): # validate robot id robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") # get existing runs of robot runs = r.get_registry()['RUNS'].get_runs(robot_id) # check if robot is eligible to be advanced to next level eligible = LevelProgressHandler.get_eligibility_for_next_run( runs, robot['level'] ) # if eligible and has not be disqualified, advance robot to next level if eligible.get('can_level_up') and not eligible['disqualified']: # advance to next level by updating 'level' column in db r.get_registry()['ROBOTS'].advance_level( robot_id, robot['level'] ) # redirect to add run page return redirect( url_for('main.robot_add_run', robot_id=robot_id) ) return "Robot not eligible to advance to next level.\n"
def advance_level(robot_id): robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") runs = r.get_registry()['RUNS'].get_runs(robot_id) eligible = LevelProgressHandler.get_eligibility_for_next_run(runs, robot['level']) if eligible.get('can_level_up') and not eligible['disqualified']: r.get_registry()['ROBOTS'].advance_level(robot_id, robot['level']) return redirect(url_for('main.robot_add_run', robot_id=robot_id)) return "Robot not eligible to advance to next level.\n"
def advance_level(robot_id): robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") runs = r.get_registry()['RUNS'].get_runs(robot_id) eligible = LevelProgressHandler.get_eligibility_for_next_run( runs, robot['level']) if eligible.get('can_level_up') and not eligible['disqualified']: r.get_registry()['ROBOTS'].advance_level(robot_id, robot['level']) return redirect(url_for('main.robot_add_run', robot_id=robot_id)) return "Robot not eligible to advance to next level.\n"
def robot_detail(robot_id, inputs=None): robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") runs = r.get_registry()['RUNS'].get_runs(robot_id) run_levels = [run['id'] for run in runs] # check if disqualifited and eligibility to advnace to next level eligibility = LevelProgressHandler.get_eligibility_for_next_run( runs, robot['level'] ) # get current best scores best_scores, attempted_levels, total_score, num_successful = ( ScoreCalculator.get_best_scores(runs) ) # check how many runs robot did on sunday (sunday = 1) # TODO: this logic needs to be rewritten after the competition sunday = 1 filtered = filter_runs_day(runs, sunday) already_run_three = False if len(filtered) >= 3: already_run_three = True return render_template( "robot.html", attempted_levels=attempted_levels, total_score=total_score, robot_id=robot_id, robot=robot, disqualified=eligibility['disqualified'], eligible=eligibility['can_level_up'], best_scores=best_scores, robot_runs=runs, applied_factors=[applied_factors(id, robot_id) for id in run_levels], inputs=inputs, already_run_three=already_run_three )
def robot_detail(robot_id, inputs=None): robot = r.get_registry()['ROBOTS'].get_robot(robot_id) if not robot: return render_template("not_found.html") runs = r.get_registry()['RUNS'].get_runs(robot_id) run_levels = [run['id'] for run in runs] # check if disqualifited and eligibility to advnace to next level eligibility = LevelProgressHandler.get_eligibility_for_next_run( runs, robot['level']) # get current best scores best_scores, attempted_levels, total_score, num_successful = ( ScoreCalculator.get_best_scores(runs)) # check how many runs robot did on sunday (sunday = 1) # TODO: this logic needs to be rewritten after the competition sunday = 1 filtered = filter_runs_day(runs, sunday) already_run_three = False if len(filtered) >= 3: already_run_three = True return render_template( "robot.html", attempted_levels=attempted_levels, total_score=total_score, robot_id=robot_id, robot=robot, disqualified=eligibility['disqualified'], eligible=eligibility['can_level_up'], best_scores=best_scores, robot_runs=runs, applied_factors=[applied_factors(id, robot_id) for id in run_levels], inputs=inputs, already_run_three=already_run_three)