From 4838e37e26c3fb72ad509d7aef7f307cc7ae3ef2 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 4 Feb 2015 23:48:56 +0100 Subject: Small cleanups --- monkey/test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'monkey/test.py') diff --git a/monkey/test.py b/monkey/test.py index 0bb047e..b5701a2 100755 --- a/monkey/test.py +++ b/monkey/test.py @@ -18,6 +18,7 @@ from .util import indent # Load django models. os.environ['DJANGO_SETTINGS_MODULE'] = 'webmonkey.settings' django.setup() +from django.apps import apps as tutor_apps from django.contrib.auth.models import User from tutor.models import Attempt, Problem, get_aux_code @@ -27,13 +28,16 @@ if len(sys.argv) < 2: sys.exit(1) pid = int(sys.argv[1]) -# Analyze traces for this problem to get edits, submissions and queries. problem = Problem.objects.get(pk=pid) aux_code = get_aux_code(user=User.objects.get(pk=1), problem=problem) attempts = Attempt.objects.filter(problem=problem) -traces = [a.trace for a in attempts] -edits, lines, submissions, queries = get_edits_from_traces(traces) + +# Load hint database stored in edits.pickle. +edits = tutor_apps.get_app_config('tutor').edits[problem.pk] +lines = tutor_apps.get_app_config('tutor').lines[problem.pk] +submissions = tutor_apps.get_app_config('tutor').submissions[problem.pk] +queries = tutor_apps.get_app_config('tutor').queries[problem.pk] # Find incorrect submissions. incorrect = [] @@ -72,7 +76,7 @@ if len(sys.argv) >= 3 and sys.argv[2] == 'test': print(colored('Analyzing program {0}/{1}…'.format(i+1, len(incorrect)), 'yellow')) print(indent(compose(*decompose(program)), 2)) - solution, steps, fix_time, n_tested = fix(problem.name, program, edits, aux_code=aux_code, timeout=timeout) + solution, steps, fix_time, n_tested = fix(problem.name, program, edits, lines, aux_code=aux_code, timeout=timeout) if solution: done.append(program) print_hint(solution, steps, fix_time, n_tested) @@ -88,7 +92,7 @@ elif len(sys.argv) >= 3 and sys.argv[2] == 'info': if len(sys.argv) == 3: print('Problem {} ({}): {} edits in {} traces, fixed {}/{} ({}/{} unique)'.format( problem.pk, colored(problem.name, 'yellow'), - colored(str(len(edits)), 'yellow'), colored(str(len(traces)), 'yellow'), + colored(str(len(edits)), 'yellow'), colored(str(len([a.trace for a in attempts])), 'yellow'), colored(str(len([p for p in incorrect if p in done])), 'yellow'), colored(str(len(incorrect)), 'yellow'), colored(str(len(set(done))), 'yellow'), -- cgit v1.2.1