summaryrefslogtreecommitdiff
path: root/monkey/test.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-02-04 23:48:56 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:01 +0200
commit4838e37e26c3fb72ad509d7aef7f307cc7ae3ef2 (patch)
treee09c3f476bf0d056cb7ddfcce8a68636327b74a6 /monkey/test.py
parent92066f4993343037c79c93ecbedd2fdb22011320 (diff)
Small cleanups
Diffstat (limited to 'monkey/test.py')
-rwxr-xr-xmonkey/test.py14
1 files changed, 9 insertions, 5 deletions
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'),