Skip to content

Configuring testcases

Nattee Niparnan edited this page Sep 14, 2025 · 4 revisions

Configuring Testcases

Each testcase in cafe-grader has several configurable properties. You can adjust them through the Testcase Params interface.

Testcase Properties

Property Description
num The order/index of the testcase. Testcases in the same group are sorted by this value.
code_name The name of the testcase, usually based on the testcase filename when imported. This is only for display.
group Numeric group ID. Testcases with the same group value are bundled together to form a grouped testcase.
group_name A human-friendly label for a group. This is only for display. Grouping logic uses group. You may reuse the same group_name for different groups.
weight The scoring weight of the testcase, controlling how much it contributes to the total score.

How to Set Properties

  1. Go to the Problem Edit page of a specific problem and click on the "Testcases" tab under the "Datasets" section. There will be the Testcase config field.
  2. Enter a parameter string using one of the supported formats below.
  3. Click Set to apply.

You can set weight, group, or group_name this way.


Parameter Formats

1. Simple Array

[w1, w2, w3, ..., wk]
  • This sets only weight but not any other property.
  • Assigns values sequentially.
  • Example: [10, 20, 30] sets the first testcase’s weight to 10, the second to 20, the third to 30.

2. Counting (Run-Length) Form

[[c1, v1], [c2, v2], ..., [ck, vk]]
  • This sets both the weight and group.
  • Assigns values in bulk and automatically bundle testcases in the same bulk into the same group.
  • c1 = number of testcases, v1 = weight value. These c1 testcases will be grouped together.
  • Example: [[3, 10], [2, 20]] means first 3 testcases → weight 10 and bundled into Group 1, next 2 testcases → weight 20 and bundled into Group 2.
  • This follows the format of IOI CMS (https://cms.readthedocs.io/en/v1.4/Score%20types.html#groupmin)

3. JSON Object Form

{
  "property_name": array_or_counting_form
}
  • property_name must be one of: weight, group, or group_name.
  • The value can be either a simple array or a counting form. For the run-length form, the value is assigned to the specific property only without setting the group.
  • Multiple properties can be set together.

Examples

Input Effect
[10,10,10,20,20] First 3 testcases → weight 10, next 2 → weight 20.
[[3,10],[2,20]] Same as above using counting form.
{"weight": [[3,10],[2,20]]} Uses JSON object to set weights.
{"group": [1,1,1], "weight": [[3,10],[2,20]]} First 3 testcases → group 1 with weight 10, next 2 → weight 20 without changing their groups.
{"group_name": [[4,"somchai"]]} First 4 testcases → group_name "somchai".

Notes & Tips

  • Grouping logic: Only group (numeric) determines grouping. group_name is just a label.
  • Partial lists: If you provide fewer entries than the total number of testcases, the remaining testcases keep their old configuration.
  • Strings: Always use quotes around strings in JSON (e.g. "somchai").
  • Combining properties: JSON form lets you update multiple properties in a single parameter string.

Clone this wiki locally