本文整理汇总了Python中nbgrader.api.Gradebook.add_submission方法的典型用法代码示例。如果您正苦于以下问题:Python Gradebook.add_submission方法的具体用法?Python Gradebook.add_submission怎么用?Python Gradebook.add_submission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nbgrader.api.Gradebook
的用法示例。
在下文中一共展示了Gradebook.add_submission方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_extra_notebooks_with_submissions
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import add_submission [as 别名]
def test_add_extra_notebooks_with_submissions(self, db):
"""Is an error thrown when new notebooks are added and there are existing submissions?"""
gb = Gradebook(db)
assignment = gb.add_assignment("ps1")
self._copy_file("files/test.ipynb", "source/ps1/test.ipynb")
run_command('nbgrader assign ps1 --db="{}"'.format(db))
gb.db.refresh(assignment)
assert len(assignment.notebooks) == 1
gb.add_student("hacker123")
gb.add_submission("ps1", "hacker123")
self._copy_file("files/test.ipynb", "source/ps1/test2.ipynb")
run_command('nbgrader assign ps1 --db="{}" --force'.format(db), retcode=1)
示例2: test_remove_extra_notebooks_with_submissions
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import add_submission [as 别名]
def test_remove_extra_notebooks_with_submissions(self, db):
"""Is an error thrown when notebooks are removed and there are existing submissions?"""
gb = Gradebook(db)
assignment = gb.add_assignment("ps1")
self._copy_file("files/test.ipynb", "source/ps1/test.ipynb")
self._copy_file("files/test.ipynb", "source/ps1/test2.ipynb")
run_command(["nbgrader", "assign", "ps1", "--db", db])
gb.db.refresh(assignment)
assert len(assignment.notebooks) == 2
gb.add_student("hacker123")
gb.add_submission("ps1", "hacker123")
os.remove("source/ps1/test2.ipynb")
run_command(["nbgrader", "assign", "ps1", "--db", db, "--force"], retcode=1)
示例3: test_same_notebooks_with_submissions
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import add_submission [as 别名]
def test_same_notebooks_with_submissions(self, db):
"""Is it ok to run nbgrader assign with the same notebooks and existing submissions?"""
gb = Gradebook(db)
assignment = gb.add_assignment("ps1")
self._copy_file("files/test.ipynb", "source/ps1/test.ipynb")
run_command('nbgrader assign ps1 --db="{}"'.format(db))
gb.db.refresh(assignment)
assert len(assignment.notebooks) == 1
notebook = assignment.notebooks[0]
gb.add_student("hacker123")
submission = gb.add_submission("ps1", "hacker123")
submission_notebook = submission.notebooks[0]
run_command('nbgrader assign ps1 --db="{}" --force'.format(db))
gb.db.refresh(assignment)
assert len(assignment.notebooks) == 1
gb.db.refresh(notebook)
gb.db.refresh(submission)
gb.db.refresh(submission_notebook)
示例4: TestSaveAutoGrades
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import add_submission [as 别名]
class TestSaveAutoGrades(TestBase):
def setup(self):
super(TestSaveAutoGrades, self).setup()
db_url = self._init_db()
self.gb = Gradebook(db_url)
self.gb.add_assignment("ps0")
self.gb.add_student("bar")
self.preprocessor1 = SaveCells()
self.preprocessor2 = SaveAutoGrades()
self.resources = {
"nbgrader": {
"db_url": db_url,
"assignment": "ps0",
"notebook": "test",
"student": "bar"
}
}
def test_grade_correct_code(self):
"""Is a passing code cell correctly graded?"""
cell = self._create_grade_cell("hello", "code", "foo", 1)
nb = new_notebook()
nb.cells.append(cell)
self.preprocessor1.preprocess(nb, self.resources)
self.gb.add_submission("ps0", "bar")
self.preprocessor2.preprocess(nb, self.resources)
grade_cell = self.gb.find_grade("foo", "test", "ps0", "bar")
assert_equal(grade_cell.score, 1)
assert_equal(grade_cell.max_score, 1)
assert_equal(grade_cell.auto_score, 1)
assert_equal(grade_cell.manual_score, None)
assert not grade_cell.needs_manual_grade
def test_grade_incorrect_code(self):
"""Is a failing code cell correctly graded?"""
cell = self._create_grade_cell("hello", "code", "foo", 1)
cell.outputs = [new_output('error', ename="NotImplementedError", evalue="", traceback=["error"])]
nb = new_notebook()
nb.cells.append(cell)
self.preprocessor1.preprocess(nb, self.resources)
self.gb.add_submission("ps0", "bar")
self.preprocessor2.preprocess(nb, self.resources)
grade_cell = self.gb.find_grade("foo", "test", "ps0", "bar")
assert_equal(grade_cell.score, 0)
assert_equal(grade_cell.max_score, 1)
assert_equal(grade_cell.auto_score, 0)
assert_equal(grade_cell.manual_score, None)
assert not grade_cell.needs_manual_grade
def test_grade_unchanged_markdown(self):
"""Is an unchanged markdown cell correctly graded?"""
cell = self._create_grade_and_solution_cell("hello", "markdown", "foo", 1)
nb = new_notebook()
nb.cells.append(cell)
self.preprocessor1.preprocess(nb, self.resources)
self.gb.add_submission("ps0", "bar")
self.preprocessor2.preprocess(nb, self.resources)
grade_cell = self.gb.find_grade("foo", "test", "ps0", "bar")
assert_equal(grade_cell.score, 0)
assert_equal(grade_cell.max_score, 1)
assert_equal(grade_cell.auto_score, 0)
assert_equal(grade_cell.manual_score, None)
assert not grade_cell.needs_manual_grade
def test_grade_changed_markdown(self):
"""Is a changed markdown cell correctly graded?"""
cell = self._create_grade_and_solution_cell("hello", "markdown", "foo", 1)
nb = new_notebook()
nb.cells.append(cell)
self.preprocessor1.preprocess(nb, self.resources)
self.gb.add_submission("ps0", "bar")
cell.source = "hello!"
self.preprocessor2.preprocess(nb, self.resources)
grade_cell = self.gb.find_grade("foo", "test", "ps0", "bar")
assert_equal(grade_cell.score, 0)
assert_equal(grade_cell.max_score, 1)
assert_equal(grade_cell.auto_score, None)
assert_equal(grade_cell.manual_score, None)
assert grade_cell.needs_manual_grade
def test_comment_unchanged_code(self):
"""Is an unchanged code cell given the correct comment?"""
cell = self._create_solution_cell("hello", "code")
nb = new_notebook()
nb.cells.append(cell)
self.preprocessor1.preprocess(nb, self.resources)
self.gb.add_submission("ps0", "bar")
self.preprocessor2.preprocess(nb, self.resources)
comment = self.gb.find_comment(0, "test", "ps0", "bar")
assert_equal(comment.comment, "No response.")
def test_comment_changed_code(self):
"""Is a changed code cell given the correct comment?"""
#.........这里部分代码省略.........