Examples¶
This page highlights a few common InstantGrade workflows.
Example 1: Launch the grading UI¶
instantgrade launch
Use this when you want a browser-based workflow for uploads, execution, history, and downloads.
Example 2: Grade notebooks locally¶
from instantgrade import InstantGrader
grader = InstantGrader(
solution_file_path="data/python_example/sample_solution_with_tests.ipynb",
submission_folder_path="data/python_example/submissions",
use_docker=False,
)
report = grader.run()
report.to_html("reports/python_local.html")
Example 3: Grade notebooks with Docker¶
from instantgrade import InstantGrader
grader = InstantGrader(
solution_file_path="data/python_example/sample_solution_with_tests.ipynb",
submission_folder_path="data/python_example/submissions",
use_docker=True,
)
report = grader.run()
Use this only when Docker is installed and running.
Example 4: Grade Excel submissions¶
from instantgrade import InstantGrader
grader = InstantGrader(
solution_file_path="data/excel_example/Assignment_ sol 1.xlsx",
submission_folder_path="data/excel_example/submissions",
)
For spreadsheet workflows, point the solution path to the instructor workbook used by the Excel evaluator.
Example 5: Generate a student notebook template¶
Launch the UI, open the student notebook generation section, upload the instructor solution notebook, and download the generated student copy.
Example 6: Start from a teacher notebook template¶
Open one of the sample teacher notebooks in data/python_example/:
teacher_notebook_basics.ipynbfor small pure-Python exercisesteacher_notebook_pandas.ipynbfor notebooks that depend on a dataset file
Each notebook follows the grading pattern InstantGrade expects:
a markdown heading for the question
a code cell with the reference solution
a code cell with setup and
assertchecks
This is the fastest way to create new instructor notebooks for a class.
Example 7: Use the walkthrough notebook¶
data/python_example/how_to_use_instantgrade.ipynb shows:
how to import
InstantGraderfrom the localsrc/treehow to run notebook grading in local mode
where the sample teacher notebook and submissions live
how to launch the GUI for upload-based grading