An Autograder is a tool built into a CodeHS exercise that tests student programs to identify errors in the code. It runs anytime the student checks their code or attempts to submit their Assignment. If any of the Autograder's tests fail, the student will be prompted to fix their code before submitting.
The Autograder uses a series of Test Cases to ensure that student code is both functionally and stylistically sound while accomplishing the goal(s) of a given exercise. When a student hits the ‘Submit Code’ button, the Test Cases are run against our Autograders, and if any fail, the student is prevented from submitting their code for grading.
Students and teachers can see these Test Cases when they visit the Test Cases tab in the top right corner of any exercise page and click Check, or when they click Submit + Continue upon completing an exercise.
Exercises Without Autograders
There are several reasons why an exercise may not include an Autograder, including:
The Autograder would not be able to thoroughly test student code
Adding an Autograder would limit an open-ended activity
The type of problem does not lend itself to Autograders
What CodeHS Autograders Can Check For
When a program outputs to the console, Autograders can capture this output and compare it to the expected results. For example, if the assignment description says that students should add 5 and 5, the Autograder checks that the output is 10.
However, Autograders cannot check the student code, which means that the Autograders cannot tell if the student adds 5 and 5, multiples 5 and 2, or just prints out 10.
Note: Lessons that focus on comments, or other changes to the code that are not reflected in the output cannot be tested.
Interaction with Methods & Functions
Autograders can pass parameters and receive and test any return values. This allows the Autograder to test multiple calls to the function to verify that it responds correctly to different parameters. Autograders only test output from one method or function at a time.
For example, if an exercise asked the students to create a function or method to take miles as an input and return kilometers, the Autograder can pass different values to the student's function and verify that the return value is correct each time.
When a program prompts the user, the Autograder can provide input to the prompts. This is helpful for many problems as it allows the Autograder to check multiple runs with different inputs to prevent students from hardcoding answers.
Autograders in Web Design (HTML/CSS)
For certain exercises in Web Design, the Autograders may not thoroughly test the student code, and teachers should make sure to review student submissions.
Autograders can check the index.html file and style.css files
Exercises that require students to create or edit multiple HTML files are also addressed in the autograder test cases - not just the index.html file.
Autograders in Java
Typically when you see a
Grader.java error, it is because the student code is missing a key piece outlined in the instructions. When students get this error, we recommend that they go back and double-check the instructions.
Still have questions? Contact our team at firstname.lastname@example.org to learn more!