Coding Blocks and Autograders

A coding block gives every student their own Linux machine in the browser, with an editor, a terminal and an optional graphical desktop. You supply starter files, a model solution and a set of tests; students press Run to see their program work and, if you allow it, Run Tests to check it against yours. When they submit, your tests run on their code and the result is the block's score.

Languages

Python, Java, C#, JavaScript, C and C++. Every one has Run, both kinds of autograder test and the similarity report. Python, C#, JavaScript, C and C++ also have a language server, which gives students completions, hover help and red underlines on errors while the machine is running. Java does not: it gets syntax colouring and word suggestions only. What is installed for each language is on The coding machine.

Setting Up a Block

Insert a coding block and you get three tabs: Template, Model Solution and Auto Grading.

Template: What Students Start With

The empty tab reads "Start Virtual Codespace". Choose a language and Classla starts a machine with a Hello World file (main.py, Main.java, Program.cs, main.js, main.c or main.cpp). Add as many files as you need; type a path such as lib/helpers.py to put a file in a folder, or upload files. The folder button beside the + at the top of the file list makes a folder: name it and its first file (a folder exists while it holds a file). The + on a folder adds a file inside it. The file students run is set from the arrow beside Run.

Each student gets a copy of the template the first time they open the block. After that the copy is theirs: editing the template later does not reach students who already opened it. A student who presses Reset to Template gets the template as it is now, and loses their own changes.

Model Solution: Your Working Answer

Start it and it begins as a copy of the template; write the answer there. Create with AI drafts one for you. Delete Model Solution removes it without asking. Students never see the model solution in an assignment. The one exception is a live game, where it is shown to players after the reveal.

Auto Grading: The Tests

+ Add Test opens a dialog with three kinds of test, below. Generate with AI drafts a set and adds it to the ones you have, and Test Model Solution runs every test against your model solution, so you find a broken test before the class does. The dialog saves as you type; there is no Save button, only Done, and a test is saved once it has a name. Expand makes the dialog fill the window.

Test a wrong answer checks the other half: write a solution your tests should reject (one that calls a method you banned, hard-codes the answer or is off by one), click Run tests, and the tests run with it in place of the model solution's file of the same name. The file name starts as the block's run file; Add file adds more, up to 20. Nothing is saved or graded and the model solution does not change. The tests meant to catch that wrong answer should fail.

Give the block a Name: at the bottom of the editor ("e.g. FRQ 2: ArrayList"). Graders see it in the grading view and when choosing which autograders to rerun; without one the block is "IDE Block 1", "IDE Block 2" and so on.

Writing Tests

Students see the name of each test and whether it passed, so name tests like feedback: "Handles an empty list" beats "test 3". Every test is all or nothing.

Input/Output

Input is "Sent to the program on stdin" and Expected output is "Compared with what the program prints". The rules:

  • Only standard output is compared. Spaces and blank lines at the very start and end are ignored; everything in between must match exactly, including capitals and spacing inside lines.
  • The test runs the program's main file by name, not the block's run file: main.py (or solution.py, code.py), Main.java, Program.cs or Main.cs, main.c, main.cpp, or main.js (or index.js). Name the starter file that way.
  • Each test has 30 seconds, including compiling for Java, C, C++ and C#. A program that runs longer fails with "Test execution timed out".
  • A failing test shows the student "Expected: … Got: …", so the expected output is visible to them once a test fails.

Unit Test

You write real test code under Framework, which defaults to the block's language:

unittest (Python)
Python's built-in unittest. Test methods start with test_.
JUnit (Java)
JUnit 4, with @Test methods.
NUnit (C#)
NUnit-style [Test] methods and asserts, run by Classla's own runner. The common attributes and asserts are there; it is not the full NUnit library.
node:test (JavaScript)
Node's built-in test runner with node:assert.
Classla tests (C)
A small test header that comes with the machine. Each test runs in its own process, so one crash does not take the others down.
doctest (C++)
doctest, with TEST_CASE and CHECK.

A unit test entry passes only if every test method in it passes. To give credit for each behaviour separately, add one entry per behaviour rather than one entry with many methods. A unit test has about 30 seconds to compile and 30 to run (60 in all for JavaScript).

Manual Grading

"Nothing runs for this test. You award its points while grading." Use it for style, comments or anything a test cannot check.

Points

The block's Points: field is what the block is worth ("Autograder test points scale to this value"). Each test's points are weights inside the block, not extra points: a 2 point block with two tests of 10 points each gives 1 point per passing test, and raising one test's weight cannot inflate the assignment.

Manual Grading tests take their share of the block out of the automatic pool and wait for you in the grading view. A block with no tests at all is graded entirely by hand. Until you score such a block, or mark the attempt reviewed, the assignment reads Pending grading and is left out of the course grade.

Which Test Run Counts

When a student submits, Classla runs your tests on their code one more time, and that run scores the block. Before that, each time a student presses Run Tests, Classla runs your tests again on its own server and rescores the open attempt from that run, so the score in the grading view follows their latest check a few moments after they see it. If the tests cannot run at submit (the student never opened the block, or the machine failed), the newest earlier run stays the score. When you rerun the autograder, the run it makes is the one that counts. Rerunning and reading runs are on Grading code.

Per-Block Settings

Allow student to check answer
Gives the student the Auto Grader tab before they submit, with Run Tests. A live game ignores this unless you also turn on Tests during coding rounds when you start the game.
Enable full autocomplete (keywords & snippets)
Adds keyword and snippet suggestions, and words from every open file, to the editor.
Disable running code
"Removes the Run button and terminal. Test cases still run when the assignment is submitted, and Check Answer still works if allowed above." Use it when students should write code without running it, as on a paper test. You and your TAs can still run a student's code while grading.
Pasting from outside the editor
The course default, Allow or Block for this block alone. Every paste is recorded either way; see Grading code.

Course-wide defaults are in Course Settings, under New blocks, then Coding: Allow student to check answer, Disable Run, Full autocomplete, Language, Points and Block pasting from outside the editor. A default applies to blocks you create afterwards, not to existing ones.

Copy block copies a coding block with its template, model solution and tests, so pasting it into another assignment gives you a working block. Students' work is not copied.

What the Student Sees

The Code tab, plus Auto Grader if you turned on Allow student to check answer. Run starts the machine if it is not already up and runs the file named under the button. On the autograder tab, Run Tests reports "Latest Result: 4/6 tests passed" and keeps a Test Run History of their last ten runs. Runs you start while grading are not in the student's list.

To try the block as a student would, press Student Preview in the editor. The preview gets a throwaway workspace, deleted when you leave, and its test runs are not recorded. The Classla AI, and Claude, ChatGPT or Gemini through the connector, can also run the tests against your model solution or starter code when you ask whether they pass; those runs are not recorded either. Working in the editor, the terminal and the desktop is described on The coding machine.

What It Does Not Do

  • There are no hidden tests. Students with Check Answer on see every test's name and result, and a failing Input/Output test shows the expected output.
  • There is no partial credit inside a single test. Write several small tests rather than one big one.
  • Changing the template does not update students who have already opened the block. Fix starter code before you publish.
  • Java has no language server, so Java students get no error underlines or member completions while typing. Errors show when they Run. The machine runs Java 11, so newer syntax such as records, text blocks and switch expressions will not compile.
  • A coding block cannot be Required, unlike the other question blocks.
  • In a live round a student can Run their code, but there is no Auto Grader tab or Check Answer unless the game has Tests during coding rounds on. Either way the tests run for everyone when the question closes, and that run is the score.
  • Deleting a test or the model solution happens at once, with no confirmation.