The Code Correctness problem type allows you to create auto-graded programming exercises that are completed and automatically scored on the Edfinity platform.
To create a new Python Code Correctness Problem, click on "Add Problem" in the top left of any assignment, and select "Code Correctness":
As an example, let's write a simple question that asks students to write a function prod that returns the product of two numbers a and b.
- First, write the problem statement in the "Question" box. This is a rich text box, so you can embed videos, images, and links to any other content that students might benefit from before solving the problem. We'll embed a video on defining python functions that students can reference.
- Second, fill out the Solution Code tab with the model solution. This will be used to determine the correct answers for the unit tests that evaluate the student code.
- Third, create the tests on the "Test Code" tab. Edfinity wrappers the Python UnitTest library, so you can write any UnitTest you want to evaluate student code. However, you can use our Intelligent Test Helper bar to quickly author common unit tests.
The helper bar automagically generates code for common unit tests like checking function return values, checking variable values, checking standard input/output, and examining the student source code to make sure they used or didn't use certain code constructions.
Let's first create a test checking that the student's prod function returns the same value as our model solution for two specific numbers.
Next, let's create some unit tests checking that 'lambda' is not in the student's source code, since our problem statement tells the students to not use a lambda.
We can similarly check that 'def prod' is in the student solution (maybe a freebie point).
Finally, we can create a unit test in which we randomize two numbers a and b and compare the student's return to the solution. Since a and b are randomized, they will be different on every run of the program, so students won't be able to game the unit test by hard coding the answer. - Finally, once your unit tests are ready, you can optionally include starter code for the student on the "Starting Code" tab. The code you put here will be pre-filled in the student's code editor when they open the problem.
In this case, we'll just give them the function definition (prototype). - You're done! If you want to preview the problem as a student, just click the preview tab at the top.