Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
additional keyword arguments for :class:`~nbgrader.api.GradeCell`
Returns
-------
grade_cell : :class:`~nbgrader.api.GradeCell`
"""
notebook = self.find_notebook(notebook, assignment)
grade_cell = GradeCell(name=name, notebook=notebook, **kwargs)
self.db.add(grade_cell)
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
self.db.rollback()
raise InvalidEntry(*e.args)
return grade_cell
additional keyword arguments for the :class:`~nbgrader.api.Assignment` object
Returns
-------
assignment : :class:`~nbgrader.api.Assignment`
"""
if 'duedate' in kwargs:
kwargs['duedate'] = utils.parse_utc(kwargs['duedate'])
assignment = Assignment(name=name, **kwargs)
self.db.add(assignment)
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
self.db.rollback()
raise InvalidEntry(*e.args)
return assignment
student : string
the name of a student
"""
submission = self.find_submission(assignment, student)
for notebook in submission.notebooks:
self.remove_submission_notebook(notebook.name, assignment, student)
self.db.delete(submission)
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
self.db.rollback()
raise InvalidEntry(*e.args)
the name of a student
"""
submission = self.find_submission_notebook(notebook, assignment, student)
for grade in submission.grades:
self.db.delete(grade)
for comment in submission.comments:
self.db.delete(comment)
self.db.delete(submission)
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
self.db.rollback()
raise InvalidEntry(*e.args)
-------
source_cell : :class:`~nbgrader.api.SourceCell`
"""
try:
source_cell = self.find_source_cell(name, notebook, assignment)
except MissingEntry:
source_cell = self.add_source_cell(name, notebook, assignment, **kwargs)
else:
for attr in kwargs:
setattr(source_cell, attr, kwargs[attr])
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
raise InvalidEntry(*e.args)
return source_cell
additional keyword arguments for the :class:`~nbgrader.api.Notebook` object
Returns
-------
notebook : :class:`~nbgrader.api.Notebook`
"""
notebook = Notebook(
name=name, assignment=self.find_assignment(assignment), **kwargs)
self.db.add(notebook)
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
self.db.rollback()
raise InvalidEntry(*e.args)
return notebook
try:
submission = self.find_submission(assignment, student)
except MissingEntry:
submission = self.add_submission(assignment, student, **kwargs)
else:
for attr in kwargs:
if attr == 'timestamp':
setattr(submission, attr, utils.parse_utc(kwargs[attr]))
else:
setattr(submission, attr, kwargs[attr])
try:
self.db.commit()
except (IntegrityError, FlushError) as e:
self.db.rollback()
raise InvalidEntry(*e.args)
return submission