CodeHS Autograders

Learn more about CodeHS Autograders and what they can check.

David Burnham avatar
Written by David Burnham
Updated over a week ago
Free Feature

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.

An image showing an example program that does not pass all Test Cases

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

In this case, teachers should make sure to review student submissions using our grading tools. Pro teachers can also adjust their Grading Settings to add submissions to their Fast Grade queue.


What CodeHS Autograders Can Check For

Program Output

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.

User Input

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.

JavaScript files are not able to be checked by autograder test cases on HTML exercises. However, some JavaScript code included within an HTML file's <script> tag can be checked by an autograder. In these cases, teachers can glance at the student submission to visually check that JavaScript elements are correct on the JavaScript page.

Autograders in Java

Grader.java errors

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.

To learn more about Autograders and how to create your own, watch our webinar on creating Autograders or check out this article on Creating your Own Autograders!


Still have questions? Contact our team at hello@codehs.com to learn more!

Did this answer your question?