diff options
-rw-r--r-- | monkey/edits.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/monkey/edits.py b/monkey/edits.py index 349ebf7..58843f6 100644 --- a/monkey/edits.py +++ b/monkey/edits.py @@ -305,3 +305,25 @@ def clean_graph(nodes): break diff += 1 node.data[0] -= diff + +if __name__ == '__main__': + import os + import pickle + import django + + # Load django models. + os.environ['DJANGO_SETTINGS_MODULE'] = 'webmonkey.settings' + django.setup() + from django.contrib.auth.models import User + from tutor.models import Attempt, Problem + + edits = {} + lines = {} + submissions = {} + queries = {} + for problem in Problem.objects.all(): + pid = problem.pk + traces = [a.trace for a in Attempt.objects.filter(problem=problem, done=True)] + edits[pid], lines[pid], submissions[pid], queries[pid] = get_edits_from_traces(traces) + + pickle.dump((edits, lines, submissions, queries), open('edits.pickle', 'wb')) |