-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip duplicated grade_ids during autograding
- Loading branch information
Showing
7 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from .checkduplicateflag import CheckDuplicateFlag, DuplicateIdError | ||
|
||
__all__ = [ | ||
"CheckDuplicateFlag", | ||
"DuplicateIdError" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import nbformat | ||
from nbformat.notebooknode import NotebookNode | ||
|
||
|
||
class DuplicateIdError(Exception): | ||
|
||
def __init__(self, message): | ||
super(DuplicateIdError, self).__init__(message) | ||
|
||
|
||
class CheckDuplicateFlag: | ||
|
||
def __init__(self, notebook_filename): | ||
with open(notebook_filename, encoding="utf-8") as f: | ||
nb = nbformat.read(f, as_version=nbformat.NO_CONVERT) | ||
self.postprocess(nb) | ||
|
||
def postprocess(self, nb: NotebookNode): | ||
for cell in nb.cells: | ||
self.postprocess_cell(cell) | ||
|
||
@staticmethod | ||
def postprocess_cell(cell: NotebookNode): | ||
if "nbgrader" in cell.metadata and "duplicate" in cell.metadata.nbgrader: | ||
del cell.metadata.nbgrader["duplicate"] | ||
msg = "Detected cells with same ids" | ||
raise DuplicateIdError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters