def get_past_ungraded_course_run(user=None, course=None, now=None):
"""Loop through past course runs and find one without grade data"""
past_runs = CourseRun.objects.filter(
course=course,
end_date__lt=now,
).exclude(end_date=None).order_by('-end_date').all()
for past_run in past_runs:
if not (CachedCurrentGradeHandler(user).exists(past_run) or
FinalGrade.objects.filter(user=user, course_run=past_run).exists()):
return past_run
raise CommandError("Can't find past run that isn't already passed/failed for Course '{}'".format(course.title))
评论列表
文章目录