Skip to content

Commit

Permalink
Replace grade ids of all nbgrader cells
Browse files Browse the repository at this point in the history
  • Loading branch information
tmetzl committed Jan 20, 2025
1 parent 2734bd8 commit fb050e8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions e2xauthoring/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from typing import Dict

import nbformat
from e2xcore.utils.nbgrader_cells import get_points, is_grade, new_read_only_cell
from e2xcore.utils.nbgrader_cells import (
get_points,
is_grade,
is_nbgrader_cell,
new_read_only_cell,
)
from jupyter_client.kernelspec import KernelSpecManager

from ..dataclasses import GitStatus, TaskRecord
Expand Down Expand Up @@ -125,7 +130,7 @@ def _rename_notebook(self, path: str, old_name: str, new_name: str):
notebook_path = os.path.join(path, f"{new_name}.ipynb")
nb = nbformat.read(notebook_path, as_version=nbformat.NO_CONVERT)
for cell in nb.cells:
if is_grade(cell):
if is_nbgrader_cell(cell):
cell.source = cell.source.replace(old_name, new_name)
cell.metadata.nbgrader.grade_id = (
cell.metadata.nbgrader.grade_id.replace(old_name, new_name)
Expand Down

0 comments on commit fb050e8

Please sign in to comment.