Programming exams with automatic grading

Assessing programming on paper measures little; on a computer, without care, it measures ChatGPT. A good programming exam gives students a real editor, runs their code in an isolated environment and grades it with tests, some of them hidden.

By Christophe Soares, university lecturer and creator of Clausa ·

What a programming exam needs

  • An in-browser editor with syntax highlighting, with nothing to install apart from the exam’s locked-down environment.
  • Code execution in an isolated sandbox, with time and memory limits, so that no program can affect the server or other students.
  • Visible tests, so students understand what is being asked, and hidden tests, so a program cannot simply hard-code the examples.
  • Clear verdicts: accepted, wrong answer, time limit exceeded, compilation or runtime error.
  • A locked-down environment, because an editor next to ChatGPT no longer assesses the student.

How to design the tests

  1. Start with the simple cases from the problem statement, visible to students.
  2. Add hidden edge cases: empty input, large values, duplicates, reverse order.
  3. Use time limits to tell an efficient solution from brute force, when that is part of what you assess.
  4. Award partial marks per test, so an almost-correct solution is not worth zero.
  5. Review borderline cases by hand: automatic grading is a starting point, not the final word.

With Clausa

Clausa grew out of real programming exams. Students write code in an in-browser editor (the same engine as Visual Studio Code), run the visible tests and submit; the code runs in an isolated sandbox and is graded against visible and hidden tests.

It supports C, Java, Python, PHP, JavaScript (Node.js), Go and SQL, multi-file problems and mixed exams, with multiple-choice or open questions in the same exam. With Safe Exam Browser, students never leave the exam editor; and teachers can adjust the grade of each answer after reading the code.

Frequently asked questions

Which programming languages are supported?
In Clausa: C, Java, Python, PHP, JavaScript (Node.js), Go and SQL (SQLite), each with its own compiler or interpreter in an isolated sandbox.
Can students see the hidden tests?
No. They see the results of the visible tests while they work; the hidden ones only count towards the grade.
Can it be used for programming contests?
Yes. The same automatic grading works for contests, with a public scoreboard and tests organised by efficiency level.

More guides