Skip to content
Snippets Groups Projects

Resolve "Make exam a many to many field on StudentInfo model"

7 files
+ 43
56
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -99,32 +99,6 @@ class StudentInfo(models.Model):
exam_info.save()
self.exams.add(exam_info)
@classmethod
def get_annotated_score_submission_list(cls) -> QuerySet:
"""Can be used to quickly annotate a user with the necessary
information on the overall score of a student and if he does not need
any more correction.
A student is done if
* module type was pass_only and student has enough points
* every submission got accepted feedback
Returns
-------
QuerySet
the annotated QuerySet as described above.
"""
return cls.objects.annotate(
overall_score=Coalesce(Sum('submissions__feedback__score'),
Value(0)),
).annotate(
done=Case(
When(exam__pass_score__lt=F('overall_score'), then=Value(1)),
default=Value(0),
output_field=BooleanField()
)
).order_by('user__username')
def disable(self):
"""The student won't be able to login in anymore, but his current
session can be continued until s/he logs out.
Loading