Login Register
Back to Help Center

CodeGrade Exercise Format

How CodeGrade course/assignment exports are imported, including testgroups, sample selection, and the collection wizard.

What It Is

The CodeGrade Exercise Format mirrors the on-disk shape produced by CodeGrade's own course/assignment export. Unlike the Kattis format, it isn't an official/versioned spec — the importer just reads the folder layout CodeGrade produces.

Two archive shapes are recognized:

Detected asRoot containsResult
codegrade-exerciseexercise.ymlA single problem
codegrade-collectioncollection.yml, plus one or more subfolders each with their own exercise.ymlA wizard lets you pick which exercises to import

Package Layout

PathPurpose
exercise.ymlMetadata: Name and description (required), cpuTimeLimit, memoryLimit
<testgroup>/<caseId>.in / .ansNumbered testgroup folders, e.g. 01-SmallTests/, each holding one or more test cases
solution/Reference solution program(s), stored the same way as a Kattis submissions/accepted/<program>/ folder
test_samples/monkeycode-specific extension folder (see below)

description is used directly as the problem statement — it's expected to already be Markdown, so (unlike the Kattis format) no LaTeX parsing or validation runs on it. cpuTimeLimit is in milliseconds and defaults to 1000; memoryLimit is in kilobytes and is converted to the megabytes the platform stores, rounded up (defaulting to 2048MB if absent).

Sample vs. Secret Test Data

CodeGrade testgroups don't distinguish public sample data from secret grading data — the importer resolves that ambiguity one of two ways:

  1. A test_samples/ folder (sibling to the testgroup folders) containing its own .in/.ans pairs. If present, it's authoritative: those cases become the samples, and every testgroup case is imported as secret.
  2. An explicit test group selection, made in the import wizard when no test_samples/ folder exists. Whichever testgroups you check become samples; everything else is imported secret.
If there's no test_samples/ folder and you skip the selection step, every test case is imported as secret and a warning is recorded on the import — contestants will see no sample input at all.

Importing a Collection

For a collection.yml archive, the import dialog lists one row per exercise (its Name, a generated problem slug you can edit, and — if it has no test_samples/ folder — a checklist of its testgroups to mark as samples). You choose which exercises to import and can retry failed rows individually; each imported exercise becomes its own problem.

What Happens During Import

  • A problems row is created with time_limit/memory_limit from the exercise metadata and languages: ['en'].
  • CodeGrade exercises don't declare a Kattis-style judging type (pass-fail/scoring/interactive) — every imported exercise gets the platform's default problem type(s).
  • description is uploaded as problem.en.md — no statement validators run against it.
  • Every .in/.ans pair in every testgroup (and test_samples/, if present) is uploaded as sample or secret test data.
  • Files directly inside solution/ are uploaded as an accepted reference submission.

Common Import Errors

ErrorCause
exercise_path is required to import from a CodeGrade collection archive.Importing a collection without specifying which exercise
No <path>exercise.yml file found!Missing exercise.yml at the expected location
exercise.yml is missing a required 'Name'/'description' field.exercise.yml doesn't set one of the two required fields
No test cases found for this exercise.No .in/.ans pairs found in any testgroup or test_samples/
sample_test_groups must be a JSON array of testgroup names. / Unknown sample test group(s)An invalid or unrecognized testgroup selection was submitted

Further Reading