本文整理汇总了Python中nbgrader.api.Gradebook.find_submission方法的典型用法代码示例。如果您正苦于以下问题:Python Gradebook.find_submission方法的具体用法?Python Gradebook.find_submission怎么用?Python Gradebook.find_submission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nbgrader.api.Gradebook
的用法示例。
在下文中一共展示了Gradebook.find_submission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_grade_timestamp
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import find_submission [as 别名]
def test_grade_timestamp(self):
"""Is a timestamp correctly read in?"""
with self._temp_cwd(["files/submitted-unchanged.ipynb", "files/submitted-changed.ipynb"]):
dbpath = self._setup_db()
os.makedirs('source/ps1')
shutil.copy('submitted-unchanged.ipynb', 'source/ps1/p1.ipynb')
self._run_command('nbgrader assign ps1 --db="{}" '.format(dbpath))
os.makedirs('submitted/foo/ps1')
shutil.move('submitted-unchanged.ipynb', 'submitted/foo/ps1/p1.ipynb')
with open('submitted/foo/ps1/timestamp.txt', 'w') as fh:
fh.write("2015-02-02 15:58:23.948203 PST")
os.makedirs('submitted/bar/ps1')
shutil.move('submitted-changed.ipynb', 'submitted/bar/ps1/p1.ipynb')
with open('submitted/bar/ps1/timestamp.txt', 'w') as fh:
fh.write("2015-02-01 14:58:23.948203 PST")
self._run_command('nbgrader autograde ps1 --db="{}"'.format(dbpath))
assert os.path.isfile("autograded/foo/ps1/p1.ipynb")
assert os.path.isfile("autograded/foo/ps1/timestamp.txt")
assert os.path.isfile("autograded/bar/ps1/p1.ipynb")
assert os.path.isfile("autograded/bar/ps1/timestamp.txt")
gb = Gradebook(dbpath)
submission = gb.find_submission('ps1', 'foo')
assert submission.total_seconds_late > 0
submission = gb.find_submission('ps1', 'bar')
assert submission.total_seconds_late == 0
# make sure it still works to run it a second time
self._run_command('nbgrader autograde ps1 --db="{}"'.format(dbpath))
示例2: test_grade_timestamp
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import find_submission [as 别名]
def test_grade_timestamp(self, gradebook):
"""Is a timestamp correctly read in?"""
self._copy_file("files/submitted-unchanged.ipynb", "source/ps1/p1.ipynb")
run_command('nbgrader assign ps1 --db="{}" '.format(gradebook))
self._copy_file("files/submitted-unchanged.ipynb", "submitted/foo/ps1/p1.ipynb")
self._make_file('submitted/foo/ps1/timestamp.txt', "2015-02-02 15:58:23.948203 PST")
self._copy_file("files/submitted-changed.ipynb", "submitted/bar/ps1/p1.ipynb")
self._make_file('submitted/bar/ps1/timestamp.txt', "2015-02-01 14:58:23.948203 PST")
run_command('nbgrader autograde ps1 --db="{}"'.format(gradebook))
assert os.path.isfile("autograded/foo/ps1/p1.ipynb")
assert os.path.isfile("autograded/foo/ps1/timestamp.txt")
assert os.path.isfile("autograded/bar/ps1/p1.ipynb")
assert os.path.isfile("autograded/bar/ps1/timestamp.txt")
gb = Gradebook(gradebook)
submission = gb.find_submission('ps1', 'foo')
assert submission.total_seconds_late > 0
submission = gb.find_submission('ps1', 'bar')
assert submission.total_seconds_late == 0
# make sure it still works to run it a second time
run_command('nbgrader autograde ps1 --db="{}"'.format(gradebook))
示例3: open
# 需要导入模块: from nbgrader.api import Gradebook [as 别名]
# 或者: from nbgrader.api.Gradebook import find_submission [as 别名]
# Loop over each student in the database
for student in gb.students:
# Create a dictionary that will store information about this student's
# submitted assignment
score = {}
score['max_score'] = assignment.max_score
score['student'] = student.id
score['assignment'] = assignment.name
# Try to find the submission in the database. If it doesn't exist, the
# `MissingEntry` exception will be raised, which means the student
# didn't submit anything, so we assign them a score of zero.
try:
submission = gb.find_submission(assignment.name, student.id)
except MissingEntry:
score['score'] = 0.0
else:
score['score'] = submission.score
grades.append(score)
# Create a pandas dataframe with our grade information, and save it to disk
grades = pd.DataFrame(grades).set_index(['student', 'assignment']).sortlevel()
grades.to_csv('grades.csv')
# Print out what the grades look like
with open('grades.csv', 'r') as fh:
print(fh.read())