Commit 919777b6 by Justin Riley

submission_history: add more sanity checks

The StudentModuleHistory db entries are filled with incomplete/invalid
entries. Add more checks to ensure the state is complete with attempts,
correct_map, and student_answers and ensure that both grade and
max_grade are not null. There are also some entries whose score doesn't
match the correct_map which we filter by manually counting the
'correctness'='correct' entries in the correct_map and comparing that to
the grade.
parent 9f15acce
......@@ -4,6 +4,7 @@ import datetime
from collections import OrderedDict
import pytz
from django.db.models import Q
from django.db import transaction
from django.contrib.auth.models import User
from django.conf import settings
......@@ -374,8 +375,11 @@ class ProctorModuleInfo(object):
student_id=student.id)
history_entries = StudentModuleHistory.objects.filter(
Q(state__contains='"attempts"') &
Q(state__contains='"correct_map"') &
Q(state__contains='"student_answers"'),
student_module__in=student_modules, grade__isnull=False,
state__contains='"attempts"',
max_grade__isnull=False,
).order_by('-id')
seen_states = []
......@@ -383,7 +387,12 @@ class ProctorModuleInfo(object):
for entry in history_entries:
state = json.loads(entry.state)
if state in seen_states:
cmap = state['correct_map']
real_grade = len([i for i in cmap.values() if
i['correctness'] == 'correct'])
if entry.grade != real_grade:
continue
elif state in seen_states:
continue
else:
seen_states.append(state)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment