📘Jupyter Notebook
Last updated
Last updated
In this tutorial we will guide you through all the steps to create your very first Jupyter Notebook assignment in CodeGrade. For this tutorial we will be considering the example below. Please make sure to save this file somewhere accessible on your computer:
In this assignment, students have been asked to answer 6 simple arithmetic questions in a Jupyter Notebook and save each answer to a corresponding variable.
There are many ways to set up an assignment for Jupyter Notebooks, most of which are quite complex. making your students write their answers to pre-assigned variables is a great way to reduce the complexity of your assignment setup. For more examples check the Advanced Jupyter Notebook guides.
Firstly, we need an assignment to work with. Whether CodeGrade is integrated in your LMS or you are using CodeGrade Standalone, you can follow the steps in the guide below to get started:
The first step in setting up an assignment is to ensure that students can submit their code correctly. Because this example is straightforward and only requires a single solution file, we will offer the students the default File Uploader option.
Navigate to the Assignment Management page by using the icon at the right-hand side of the page header on the submissions page.
Find the Submission settings in the corresponding container under the General tab.
Enable the File uploader submission method by clicking the respective check box.
Finalize your settings by clicking the "Submit" button.
For more information about submission methods, see Submission Settings.
While you can always grade assignments directly by manually setting the Final grade, It's only possible to award points for your automatic tests with Rubrics. Rubrics also allow you to standardize the grading scheme for graders and they allow you to clarify the grading requirements to your students.
CodeGrade offers two types of rubric category:
Discrete category - Specify points in discrete steps (eg. 0, 5 or 10 points)
Continuous category - Specify points as a continuous scale (eg. 0 - 10)
Navigate to the Rubric tab on the Assignment Management page.
Select Create new rubric.
Create a new Continuous Category.
Provide the name "IO Test" as the Category name.
Under Category description write: "Check that your answers are correct."
Set the Min points to 0 and the Max points to 100.
Automatic tests are really what gives your students the opportunity to learn in a unique way. The immediate feedback they get from the automatic tests allow them to learn through trial and error by applying the instant feedback and resubmitting their work. For this tutorial we will be setting up simple Input/Output tests.
Before creating the tests, we need to make sure that Python and Jupyter are installed.
Navigate to the Setup tab under the AutoTest settings.
Add an Install Python block to your configuration and select the latest version of Python from the drop-down menu.
Add a Script block to your configuration and install Jupyter with
Jupyter Notebooks are easy to use when run within the Jupyter environment. However, running and testing Jupyter Notebooks in the command line is more challenging. To make the most of CodeGrade's automatic grading options, we need to convert the Jupyter Notebook into a Python file.
Navigate to the Tests tab in the AutoTest settings.
Add a Script block to your configuration and convert the notebook to Python using the command
Input/Output tests (or IO tests for short) are a great way of checking a program's functionality by providing various input cases that should result in a different outputs. You can create IO test cases in AutoTest v2 using the IO Test wrapper block and its corresponding Full match, Substring match, and Regex match blocks.
Add a Connect Rubric block to your AutoTest configuration and select the "IO tests" rubric.
Add an IO test block to your AutoTest configuration and nest it in the Connect Rubric block.
Run the following command in the editor provided to start Python in interactive mode and access the variables from your students' submissions.
Add six Substring match blocks to your AutoTest configuration and nest them inside of the IO test block.
Copy and paste the info from the table below into the Input and Expected output fields in their respective match block:
It's important to test your AutoTest configuration before running it on students' submissions to make sure that your tests are running as expected and to check for edge cases. This is easy to do with Snapshots. When you're ready to check your tests, simply press the Build snapshot button at the bottom of the test block sidebar. This will make a test run of your AutoTest configuration on your Test submission.
The first time you build a snapshot, CodeGrade will prompt you to upload a Test submission. Use the "Click here to upload files" option or drag-and-drop the calculations.ipynb file that you downloaded at the beginning of this tutorial and click "Submit".
If, in the future, you need to re-upload your test submission, you can do so by going to Upload Submission option in the General Settings tab. Just upload your file and check the "Test Submission" option before clicking "Submit".
Once you're happy with your tests, you need to publish them to your students for them to run on their submissions. Publish your tests by building a snapshot and at the bottom of the pop-up modal click the Publish snapshot button.
You have just built your first Automatically graded assignment, ready for your students to begin submitting work!
This guide is designed to get you started with a completed assignment but doesn't go into explicit detail about all of the features CodeGrade has to offer. For more in-depth information about the product and the various workflows that you can achieve, see Learn more or reach out to our support team at support@codegrade.com.
Input | Expected output |
---|---|
print(q1)
168
print(q2)
100
print(q3)
115
print(q4)
10.83
print(q5)
3
print(q6)
35630.58916940624