Commit cb06091c by Justin Riley

cleanup get_assignments_attempted_and_failed

parent 3f9b1ef7
...@@ -296,45 +296,43 @@ class ProctorModuleInfo(object): ...@@ -296,45 +296,43 @@ class ProctorModuleInfo(object):
ret["grade_%s" % stat['name']] = '' ret["grade_%s" % stat['name']] = ''
return ret return ret
def _get_od_for_assignment(self, student, assignment):
return OrderedDict(id=student.id,
name=student.profile.name,
username=student.username,
assignment=assignment['name'],
problem=assignment['problem'],
date=str(datetime.datetime.now()),
earned=assignment['earned'],
possible=assignment['possible'])
def get_assignments_attempted_and_failed(self, student, do_reset=False): def get_assignments_attempted_and_failed(self, student, do_reset=False):
status = self.get_student_status(student) status = self.get_student_status(student)
assignments = [] failed = [self._get_od_for_assignment(a) for a in status['assignments']
for stat in status['assignments']: if a['attempted'] and a['earned'] != a['possible']]
if stat['attempted']: for f in failed:
if not stat['earned'] == stat['possible']: log.info(
log.info( "Student %s Assignment %s attempted '%s' but failed "
"Student %s Assignment %s attempted '%s' but failed " "(%s/%s)" % (student, f['assignment'], f['problem'],
"(%s/%s)" % (student, stat['name'], stat['problem'], f['earned'], f['possible']))
stat['earned'], stat['possible'])) if do_reset:
assignments.append(OrderedDict( try:
id=student.id, log.debug('resetting %s for student %s' %
name=student.profile.name, (f['assignment'], f['username']))
username=student.username, cloc = self.course.location
assignment=stat['name'], assi_url = Location(cloc.tag, cloc.org,
problem=stat['problem'], cloc.course, 'proctor',
date=str(datetime.datetime.now()), f['assignment'])
earned=stat['earned'], pmod = self.ms.get_instance(self.course.id,
possible=stat['possible'], assi_url.url())
)) tnset = TreeNodeSet(self.course.id, pmod, self.ms,
if do_reset: student)
aaf = assignments[-1] msg = tnset.reset_randomization()
try: log.debug(str(msg))
log.debug('resetting %s for student %s' % except Exception:
(aaf['assignment'], aaf['username'])) log.exception("Failed to do reset of %s for %s" %
cloc = self.course.location (f['assignment'], student))
assi_url = Location(cloc.tag, cloc.org, return failed
cloc.course, 'proctor',
aaf['assignment'])
pmod = self.ms.get_instance(self.course.id,
assi_url.url())
tnset = TreeNodeSet(self.course.id, pmod, self.ms,
student)
msg = tnset.reset_randomization()
log.debug(str(msg))
except Exception:
log.exception("Failed to do reset of %s for %s" %
(aaf['assignment'], student))
return assignments
def getip(request): def getip(request):
......
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