check a submission¶
You can check a submission in 2 ways:
Using the command line tool.
Using
nbchkr
as a library.
Using the command line tool¶
Given a source assignment main.ipynb
and a submission
submitted.ipynb
you can check the submission using:
$ nbchkr check --source main.ipynb --submitted submitted.ipynb --feedback-suffix -feedback.md --output data.csv
This creates submitted.ipynb-feedback.md
with feedback and outputs
summary scores to data.csv
.
Note that given a pattern matching a number of notebooks, for example all
notebooks in submissions/
you can check them all at once using:
$ nbchkr check --source main.ipynb --submitted "submissions/*.ipynb" --feedback-suffix -feedback.md --output data.csv
Using nbchkr
as a library¶
All of nbchkr
’s functionality is exposed to the user as a library.
Importing the relevant libraries:
>>> import pathlib
>>> import nbchkr.utils
Reading in the source notebook main.ipynb
and removing relevant cells:
>>> source_nb_path = pathlib.Path("main.ipynb")
>>> source_nb_node = nbchkr.utils.read(nb_path=source_nb_path)
Reading in the submitted notebook submitted.ipynb
and check that the tags
match (if they do not match the checker will still work but the results should
be confirmed manually):
>>> submitted_nb_path = pathlib.Path("submitted.ipynb")
>>> nb_node = nbchkr.utils.read(submitted_nb_path)
>>> tags_match = nbchkr.utils.check_tags_match(source_nb_node=source_nb_node, nb_node=nb_node)
>>> tags_match
True
Now we will add the checks to the submission from main.ipynb
and run
them:
>>> nb_node = nbchkr.utils.add_checks(nb_node=nb_node, source_nb_node=source_nb_node)
>>> score, maximum_score, feedback_md, passed_checks = nbchkr.utils.check(nb_node=nb_node)
>>> score
10
>>> maximum_score
11
>>> feedback_md
'\n---\n\n## answer:q1\n\n### Integer answer\n\n1 / 1\n\n### Correct answer\n...'
>>> passed_checks
{'Integer answer': True, 'Correct answer': True, 'Presence of docstring': False}
Note that the nbrchkr.utils.check_tags_match
,
nbchkr.utils.add_checks
and nbchkr.utils.check
functions can
take further arguments that allow for customisation of behaviour.