Skip to content

Commit 52e4ebe

Browse files
committed
Fix query of max scores in newer sqlite
1 parent ee8ece8 commit 52e4ebe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nbgrader/api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ def max_score(self):
841841
return self.max_score_taskcell
842842
else:
843843
return self.max_score_gradecell
844+
844845
#: Whether the autograded score is a result of failed autograder tests. This
845846
#: is True if the autograder score is zero and the cell type is "code", and
846847
#: otherwise False.
@@ -2962,7 +2963,13 @@ def student_dicts(self):
29622963
A list of dictionaries, one per student
29632964
29642965
"""
2965-
total_score, = self.db.query(func.sum(Assignment.max_score)).one()
2966+
max_scores = self.db.query(
2967+
Assignment.id,
2968+
func.sum(Assignment.max_score).label("max_score")
2969+
).group_by(Assignment.id).subquery()
2970+
_max_scores = func.coalesce(max_scores.c.max_score, 0.0)
2971+
total_score, = self.db.query(func.sum(_max_scores)).one()
2972+
29662973
if len(self.assignments) > 0 and total_score > 0:
29672974
# subquery the scores
29682975
scores = self.db.query(

0 commit comments

Comments
 (0)