Skip to content

Commit 6706939

Browse files
tuncbkosebrichet
authored andcommitted
Fix validation for failed cells with zero points
1 parent 1952b87 commit 6706939

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

nbgrader/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ def is_locked(cell: NotebookNode) -> bool:
6161
else:
6262
return cell.metadata['nbgrader'].get('locked', False)
6363

64+
65+
def has_failed(cell: NotebookNode) -> bool:
66+
"""Returns True if the cell contains an output indicative of an error"""
67+
if not cell.cell_type == 'code':
68+
return False
69+
for output in cell.outputs:
70+
if output.output_type == 'error' or output.output_type == "stream" and output.name == "stderr":
71+
return True
72+
# Otherwise assume all is fine
73+
return False
74+
75+
6476
def get_partial_grade(output, max_points, log=None):
6577
"""
6678
Calculates partial grade for a cell, based on contents of

nbgrader/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def _get_failed_cells(self, nb: NotebookNode) -> typing.List[NotebookNode]:
254254
# it's a markdown cell, so we can't do anything
255255
if score is None:
256256
pass
257-
elif score < max_score:
257+
elif score < max_score or (max_score == 0 and utils.has_failed(cell)):
258258
failed.append(cell)
259259
elif self.validate_all and cell.cell_type == 'code':
260260
for output in cell.outputs:

0 commit comments

Comments
 (0)