CES-Alpha
マニュアル / CES-Alpha 問題JSONファイル形式 — バージョン 1.0

CES-Alpha 問題JSONファイル形式 — バージョン 1.0

Markdown版(AIエージェント用) auto_grade_question_format.ja.md

目次
  • 1ファイルを使う場所
  • 2ファイルの基本
  • 3ヘッダー(必須)
  • 4両サイト共通のフィールド
  • 5数学サイト("site": "math")
  • 6プログラミングサイト("site": "code")
  • 7問題文・ヒント・解説のテキスト
  • 81.0 より前のファイル
  • 9サンプル
  • 10AI エージェント向けの指示
  • 11変更履歴

この文書は、CES-Alpha の自動採点問題を1問以上収めた JSON ファイルの仕様を定めます。手作業、スクリプト、AI エージェントのいずれでファイルを作成する場合も、この仕様に従ってください。

  • この文書のWebページ: https://document.ces-alpha.jp/manual/auto_grade_question_format.html
  • この文書の Markdown 版: https://document.ces-alpha.jp/manual/auto_grade_question_format.ja.md
  • サンプルファイル: 第9節
1ファイルを使う場所

教員の問題編集ページで使います。

  • ダウンロード: ページ下部の「問題JSONファイル」欄の「JSONファイルをダウンロード」で、問題をこの形式のファイルとしてダウンロードできます。
  • 1つのファイルを読み込む: 「問題をロード」→「ローカルのJSONファイルから」で、1問分の内容がフォームに入力されます。保存ボタンを押すまでは保存されません。
  • 複数の問題を読み込む: 複数のファイル、.zip ファイル、または問題のリストを収めたファイルを選ぶと、すべての問題が、ページで選択中のグループに新しい問題として追加されます。

サイトは2つあり、ファイルはそのどちらか一方のためのものです。

サイト site 問題
プログラミングサイト(code.ces-alpha.org とそのサブサイト) "code" プログラミング問題、および短いテキスト解答の問題
数学サイト(math.ces-alpha.org) "math" 記号計算で採点する数学の問題
2ファイルの基本
  • 文字コード: UTF-8。形式: JSON(RFC 8259)。拡張子: .json。
  • 1つの問題は1つの JSON オブジェクトです。複数の問題を扱う場合は、次のいずれかを使います。
    • 1つのファイルに問題オブジェクトの JSON 配列を書く
    • 複数の .json ファイルを同時に選ぶ
    • .json ファイルをまとめた .zip ファイル(中のフォルダは使用可。. で始まるファイルと __MACOSX フォルダは読み飛ばされます)
  • テキストの値はすべて JSON 文字列です。改行は \n と書きます。バックスラッシュは \\ と書くため、LaTeX の \frac{1}{2} はファイル内では "\\frac{1}{2}" となります。
  • この文書に記載のないキーは無視されます。
  • 空文字列 "" は、キーがない場合と同じ意味です。
3ヘッダー(必須)

形式 1.0 の問題オブジェクトは、必ず次の2つのキーで始めます。

キー 型 値
ces_question_format 文字列 "1.0": 形式のバージョン("メジャー.マイナー")。
site 文字列 "code" または "math": 問題の対象サイト。

ファイル読み込み時の規則:

  • メジャーバージョンが同じ(マイナーバージョンは問わない)("1.0"、"1.2"、…): ファイルは読み込まれます。後のマイナーバージョンで追加されたキーは無視されます。
  • メジャーバージョンが異なる("2.0"、…): ファイルは拒否されます。
  • site がページのサイトと一致しない: ファイルは拒否されます。数学の問題をプログラミングサイトで読み込むことはできず、その逆もできません。
  • ces_question_format キーがない: 1.0 より前のファイル(第8節)とみなし、従来どおりに読み込みます。
4両サイト共通のフィールド
キー 型 必須 既定値 意味
question_type 文字列 はい — 問題の種類。値は第5節(数学)と第6節(プログラミング)を参照。
question_title 文字列 はい* "" 問題一覧に表示されるタイトル。
question_content 文字列 はい* "" 学生に表示される問題文(第7節)。
score 整数 いいえ 1 問題の配点(「点数の設定」)。
evaluation_method 整数 いいえ 数学 0、プログラミング 1 解答の採点方法。値は第5節と第6節を参照。
question_hint 文字列 いいえ "" 学生が開いて見られるヒント(「ヒント」)。
q_solution_explanation 文字列 いいえ "" 解答の解説。正解とともに学生に表示されます(「問題の解説」)。
note 文字列 いいえ "" 教員向けのメモ(「備考」)。学生には表示されません。

* question_title と question_content の少なくとも一方は設定が必要です。両方を設定してください。

5数学サイト("site": "math")

5.1 問題の種類

question_type 学生は… 使用するフィールド
"text"(「テキスト入力 (穴埋めを含む)」) 1つ以上の式を入力する question_answer, question_variable, answer_const
"select"(「多肢選択」) リストから1つを選ぶ answer_candidate, question_answer
"matrix"(「ベクトル/行列入力」) ベクトルまたは行列を入力する question_answer, question_variable

5.2 フィールド

キー 型 必須 意味
question_variable 文字列 いいえ パラメータ(「パラメータ」): 学生ごとに問題を変えるためのランダムな値(5.3)。
question_answer 文字列 はい 正解。書き方は question_type によって異なります(5.4)。
answer_candidate 文字列の配列 select のみ 選択肢。表示される順に並べます。
answer_const 真偽値 いいえ(text のみ) true: question_answer と定数だけ異なる解答も正解とします(不定積分など。「定数分の違いを許容する(不定積分など)」)。既定値は false。

5.3 パラメータ(question_variable)

1行に1つのパラメータを 名前=値 の形で書きます(行の区切りは \n)。

a=1,2,5
b_1=-3,...,-1,1,...,5
alpha=1,...,5
beta=a+b_1
  • カンマ区切りの数値のリスト: 学生ごとに1つの値がランダムに選ばれます。m,...,n は m から n までのすべての整数を表します。
  • 式(beta=a+b_1 のように文字を含むもの): 他のパラメータから計算されます。
  • 名前: 1文字(a, b, x, …)またはギリシャ文字の名前(alpha, beta, …。ただし lambda, pi, e は不可)。1桁の添字を付けることもできます(b_1, beta_9)。
  • E(または e)、pi、I(虚数単位)は数学定数です。
  • question_content では、$...$ 内のパラメータがその値に置き換えられます。ギリシャ文字は、問題文ではバックスラッシュを付けて($\\alpha$)、question_variable では付けずに(alpha)書きます。

5.4 正解(question_answer)

text: 解答欄ごとに1行、名前=式 の形で書きます。

A=2*a*x+b
B=2*a+b
  • 名前(A, B)は解答欄のラベルです。問題文中に \ans{A} と書いて、解答欄の位置を示します(第7節)。
  • 式は電卓と同じように SymPy の記法で書きます。掛け算は *、累乗は ^ または **、ほかに sqrt(x), sin(x), exp(x), log(x), pi, E, I, oo(無限大)が使えます。パラメータも使えます。
  • 1つの解答欄に複数の正解がある場合: ; で区切ります(x=2;-2)。
  • 1行だけ採点方法を変える場合: 行末に # mode:1、# mode:2、# mode:3 のいずれかを付けます(A=x+1 # mode:3)。番号は 5.5 のものです。

matrix: 1行に行列の1行を書き、要素はカンマで区切ります。列ベクトルは1行に1要素です。

a+2, 2
1, 1

select: 正解の選択肢のテキストを、answer_candidate に書いたとおりに書きます。

5.5 採点方法(evaluation_method)

値 フォーム上の名前 正解となる条件
0 [mode:1] 数式の同値性チェック 数学的に同じ意味である: (x-1)^2 = x^2-2x+1。
1 [mode:2] 形式を含めたチェック 順序の違いを除いて同じ形である: (x-3)(x-1) = (x-1)(x-3)。ただし 3x ≠ x+2x。
2 [mode:3] 完全一致のチェック 文字列として同じである: 2x ≠ 2*x。

select では使いません。select は常に選ばれたテキストを比較します。

6プログラミングサイト("site": "code")

6.1 問題の種類

question_type 学生は… 採点方法
"code"(「コード作成」) プログラムを書く sample_code と学生のコードを同じ入力で実行し、結果を比較する
"text"(「テキスト入力 (穴埋めを含む)」) 短い解答を入力する question_answer と比較する

6.2 code 問題のフィールド

キー 型 必須 意味
code_language 文字列 はい "Python"(Python 3)、"R"、"MATLAB"(Octave で実行)のいずれか。既定値は "Python"。
answer_template 文字列 いいえ 学生のエディタに最初に表示されるコード。
sample_code 文字列 はい 模範解答。採点サーバーで実行され、学生には表示されません。
object_for_grade 文字列 はい 比較の対象(6.3)。
input_argument 文字列 いいえ 関数呼び出しの入力。1行に1つのテストケースを書きます(6.3)。
evaluation_method 整数 いいえ 1: コードを実行して結果を比較します(既定値。「コードの実行結果を確認」)。

6.3 比較の対象(object_for_grade, input_argument)

方法は2つあります。

関数。 object_for_grade は add(a, b) のような関数呼び出しです。input_argument の各行が1つのテストケースで、カンマ区切りの値が順に引数の位置に入ります。各テストケースについて sample_code と学生のコードの両方で関数が呼び出され、戻り値が一致する必要があります。

"object_for_grade": "add(a, b)",
"input_argument": "1, 2\n-3, 5\n0.5, 0.25"
  • リストや入れ子の呼び出しも値として使えます。[1,2], 5 と c(1,2,3), 1000 はどちらも2つの値です。
  • プレースホルダー var1, var2, …(値が1つなら var)も使えます。式の中でも使えます: solve(var1, np.array([var2, var3]))。
  • input_argument がない場合、関数は引数なしで1回だけ呼び出されます(f())。

変数。 object_for_grade は m, mx のような、カンマ区切りの変数名のリストです。両方のプログラムを実行し、終了時のこれらの変数の値が一致する必要があります。input_argument は使いません。

6.4 プログラミングサイトの text 問題

question_answer には、5.4 と同じく解答欄ごとに1行、名前=値 の形で書きます。複数の正解は ; で区切ります(PrimeNumber=3;13;23)。解答そのものにセミコロンが含まれる場合は \; と書きます(JSON ファイル内では "\\;")。

7問題文・ヒント・解説のテキスト
  • question_content、question_hint、q_solution_explanation は Markdown です。空行で新しい段落になります。コードはバッククォートで囲んで書けます。
  • 数学サイトでは LaTeX の数式が使えます。インラインは $...$、ブロックは $$...$$ です。
  • \ans{名前} は、テキスト中のその位置に、解答 名前 の入力欄を表示します。
81.0 より前のファイル

ces_question_format のないファイルは従来どおりに読み込まれます。そのようなファイルに限り、互換性のために次の別名も受け付けます。新しいファイルでは使わないでください。

1.0 のキー 受け付ける別名
question_type exercise_type, q_type
question_title title
question_content q_content
question_variable q_variable
question_answer answer
answer_candidate answer_choices
question_hint hint
q_solution_explanation solution_explanation
answer_template code_template
object_for_grade code_output

1.0 より前のファイルで、問題の種類がない場合やサイトにない種類の場合は、種類を推定します。プログラミングサイトでは、answer_template または object_for_grade がある問題は code、それ以外は text とみなします。

9サンプル
ファイル サイト 種類
code_python_function.json code code、テストケース付きの関数
code_python_variables.json code code、変数
code_text.json code text
math_text.json math text、パラメータあり、解答2つ
math_text_integral.json math text、answer_const あり
math_select.json math select
math_matrix.json math matrix
math_several_questions.json math 2問の配列

プログラミング問題の例:

{
  "ces_question_format": "1.0",
  "site": "code",
  "question_type": "code",
  "question_title": "Sum of two numbers",
  "question_content": "Write a function `add(a, b)` that returns the sum of `a` and `b`.",
  "score": 1,
  "evaluation_method": 1,
  "code_language": "Python",
  "answer_template": "def add(a, b):\n    # Write your code here.\n    return None\n",
  "sample_code": "def add(a, b):\n    return a + b\n",
  "object_for_grade": "add(a, b)",
  "input_argument": "1, 2\n-3, 5\n0.5, 0.25",
  "question_hint": "Use the + operator.",
  "q_solution_explanation": "Return `a + b`.",
  "note": "Week 1"
}

数学の問題の例:

{
  "ces_question_format": "1.0",
  "site": "math",
  "question_type": "text",
  "question_title": "Derivative of a polynomial",
  "question_content": "Let $f(x) = a x^2 + b x$. Find $f'(x)$ and $f'(1)$.\n\n$f'(x) = $ \\ans{A}, $f'(1) = $ \\ans{B}",
  "question_variable": "a=1,...,5\nb=-3,-2,-1,1,2,3",
  "question_answer": "A=2*a*x+b\nB=2*a+b",
  "evaluation_method": 0,
  "score": 2,
  "question_hint": "$(x^n)' = n x^{n-1}$",
  "q_solution_explanation": "$f'(x) = 2ax + b$, so $f'(1) = 2a + b$."
}
10AI エージェント向けの指示

問題ファイルを作成する AI エージェントには、この節、または文書全体を渡してください。

あなたは CES-Alpha の問題ファイルを「CES-Alpha 問題JSONファイル形式 1.0」で作成します。
- 出力は有効な JSON のみとし、UTF-8 で、コメントや前後の文章を含めないでください。
- 各問題はオブジェクトとし、"ces_question_format": "1.0" と "site": "code" または "math" で始めてください。
- 複数の問題は、そのようなオブジェクトの JSON 配列として出力してください。
- この形式のキーだけを使ってください。第8節の旧名は決して使わないでください。
- question_type, question_title, question_content, question_answer は必ず設定してください
  (プログラミングの "code" 問題では、question_answer の代わりに code_language, sample_code, object_for_grade を設定します)。
- 数学サイト: question_type は "text", "select", "matrix" のいずれかです。式は SymPy の記法で書きます(2*x, x^2, sqrt(x), pi, E)。
  "text" の正解は、解答欄ごとに1行 "name=expression" と書き、問題文中の各解答欄の位置を \ans{name} で示します。
  "select" の正解は、answer_candidate のいずれか1つと完全に同じ文字列にします。
- プログラミングサイト: question_type は "code" または "text" です。code_language は "Python", "R", "MATLAB" のいずれかです。
  sample_code はエラーなく実行でき、object_for_grade が指すものを定義していなければなりません。
  関数の場合は、input_argument に複数のテストケースを1行に1つずつ書いてください。
- JSON 文字列内のエスケープ: 改行は \n、バックスラッシュは \\(LaTeX の \frac は \\frac と書く)、ダブルクォートは \" とします。
- 正解を書く前に、その正解が正しいことを確認してください。
11変更履歴
バージョン 日付 変更内容
1.0 2026-10 最初のバージョン: ヘッダー ces_question_format と site、answer_const を追加。第8節の旧名は互換性のためだけに残す。
Manual / CES-Alpha Question JSON File Format — Version 1.0

CES-Alpha Question JSON File Format — Version 1.0

Markdown (for AI agents) auto_grade_question_format.en.md

Contents
  • 1Where the file is used
  • 2File basics
  • 3Header (required)
  • 4Fields used on both sites
  • 5Mathematics site ("site": "math")
  • 6Programming site ("site": "code")
  • 7Text of the question, hint and explanation
  • 8Files of before 1.0
  • 9Examples
  • 10Instructions for AI agents
  • 11Changes

This document specifies the JSON file that holds one or more auto-graded questions of CES-Alpha. Follow it to write such a file by hand, with a script, or with an AI agent.

  • Web page of this document: https://document.ces-alpha.jp/manual/auto_grade_question_format.html
  • This document as Markdown: https://document.ces-alpha.jp/manual/auto_grade_question_format.en.md
  • Example files: section 9
1Where the file is used

On the question edit page of a teacher:

  • Download: the "Question JSON file" zone at the bottom of the page downloads the question as a file of this format ("Download JSON file").
  • Load one file: "Load question" → "From local json file" fills the form with one question. Nothing is saved until you press the save button.
  • Load several questions: if you choose several files, a .zip file, or a file holding a list of questions, all of them are added as new questions to the group selected on the page.

There are two sites, and a file is for one of them:

Site site Questions
Programming site (code.ces-alpha.org and its sub-sites) "code" Programming questions, and short text answers
Mathematics site (math.ces-alpha.org) "math" Math questions graded by symbolic computation
2File basics
  • Encoding: UTF-8. Format: JSON (RFC 8259). Extension: .json.
  • One question is one JSON object. For several questions, use one of:
    • a JSON array of question objects in one file,
    • several .json files chosen at the same time,
    • a .zip file of .json files (folders inside are allowed; files starting with . and the __MACOSX folder are skipped).
  • All text values are JSON strings. Write a line break as \n. Write a backslash as \\, so the LaTeX \frac{1}{2} is written "\\frac{1}{2}" in the file.
  • Keys that this document does not list are ignored.
  • An empty string "" means the same as a missing key.
3Header (required)

Every question object of format 1.0 starts with these two keys:

Key Type Value
ces_question_format string "1.0": the format version, as "major.minor".
site string "code" or "math": the site the question is for.

Rules for reading a file:

  • Same major version, any minor version ("1.0", "1.2", …): the file is read; keys that a later minor version added are ignored.
  • Other major version ("2.0", …): the file is refused.
  • site not the site of the page: the file is refused. A math question cannot be loaded on the programming site, and the other way round.
  • No ces_question_format key: the file is a file of before 1.0 (see section 8) and is read as before.
4Fields used on both sites
Key Type Required Default Meaning
question_type string yes — The kind of question. Values: see section 5 (math) and section 6 (code).
question_title string yes* "" The title shown in question lists.
question_content string yes* "" The question text shown to students (section 7).
score integer no 1 The points of the question ("Score setting").
evaluation_method integer no math 0, code 1 How the answer is graded. Values: see sections 5 and 6.
question_hint string no "" A hint that students can open ("Hint").
q_solution_explanation string no "" The explanation of the solution, shown to students with the correct answer ("Solution Explanation").
note string no "" A note for teachers ("Note"). Students never see it.

* At least one of question_title and question_content must be set. Set both.

5Mathematics site ("site": "math")

5.1 Question types

question_type The student… Fields used
"text" ("Answer in textbox") types one or more expressions question_answer, question_variable, answer_const
"select" ("Select from list") chooses one item of a list answer_candidate, question_answer
"matrix" ("Answer as vector or matrix") types a vector or a matrix question_answer, question_variable

5.2 Fields

Key Type Required Meaning
question_variable string no Parameters ("Parameter"): random values that make each student's question different (5.3).
question_answer string yes The correct answer. Its form depends on question_type (5.4).
answer_candidate array of strings select only The choices, in the order they are shown.
answer_const boolean no (text only) true ("Allow the addition of a constant"): an answer that differs from question_answer by a constant is also correct (indefinite integrals). Default false.

5.3 Parameters (question_variable)

One parameter per line (\n between lines), name=values:

a=1,2,5
b_1=-3,...,-1,1,...,5
alpha=1,...,5
beta=a+b_1
  • A comma-separated list of numbers: one value is drawn at random for each student. m,...,n stands for all the integers from m to n.
  • An expression (it has letters, such as beta=a+b_1): it is computed from the other parameters.
  • Names: one letter (a, b, x, …) or a Greek letter name (alpha, beta, …; not lambda, pi or e), optionally with a one-digit subscript (b_1, beta_9).
  • E (or e), pi and I (the imaginary unit) are the mathematical constants.
  • In question_content, a parameter inside $...$ is replaced by its value. Write Greek letters there with a backslash ($\\alpha$); in question_variable write them without it (alpha).

5.4 Answer (question_answer)

text: one line for each answer box, name=expression:

A=2*a*x+b
B=2*a+b
  • The name (A, B) is the label of the answer box. Write it in the question text with \ans{A} to show where it goes (section 7).
  • The expression is written as on a calculator, with SymPy syntax: * for multiplication, ^ or ** for powers, sqrt(x), sin(x), exp(x), log(x), pi, E, I, oo (infinity). Parameters can be used.
  • Several correct answers for one box: separate them with ; (x=2;-2).
  • A grading method for one line only: add # mode:1, # mode:2 or # mode:3 at the end of the line (A=x+1 # mode:3). The numbers are those of 5.5.

matrix: one row per line, the elements separated by commas. A column vector is one element per line.

a+2, 2
1, 1

select: the text of the correct choice, exactly as it is written in answer_candidate.

5.5 Grading method (evaluation_method)

Value Name in the form The answer is correct when…
0 [mode:1] Equivalence check it has the same mathematical meaning: (x-1)^2 = x^2-2x+1.
1 [mode:2] Formal check it has the same form, up to order: (x-3)(x-1) = (x-1)(x-3), but 3x ≠ x+2x.
2 [mode:3] Strict check it is the same string: 2x ≠ 2*x.

Not used for select, which always compares the chosen text.

6Programming site ("site": "code")

6.1 Question types

question_type The student… Graded by
"code" ("Code Creation") writes a program running sample_code and the student's code with the same input, and comparing the results
"text" ("Answer in textbox") types a short answer comparing it with question_answer

6.2 Fields of a code question

Key Type Required Meaning
code_language string yes "Python" (Python 3), "R" or "MATLAB" (run with Octave). Default "Python".
answer_template string no The code that the student's editor starts with.
sample_code string yes The model answer. It is run on the grading server; students do not see it.
object_for_grade string yes What is compared (6.3).
input_argument string no The inputs of a function call, one test case per line (6.3).
evaluation_method integer no 1 ("Check code-running result"): run the code and compare the results (default).

6.3 What is compared (object_for_grade, input_argument)

There are two ways.

A function. object_for_grade is a call, such as add(a, b). Each line of input_argument is one test case: its comma-separated values are put in the place of the arguments, in order. The function is called with each test case in sample_code and in the student's code, and the return values must match.

"object_for_grade": "add(a, b)",
"input_argument": "1, 2\n-3, 5\n0.5, 0.25"
  • Lists and nested calls can be values: [1,2], 5 and c(1,2,3), 1000 are two values each.
  • The placeholders var1, var2, … (or var for a single value) also work, also inside an expression: solve(var1, np.array([var2, var3])).
  • Without input_argument, the function is called once without arguments (f()).

Variables. object_for_grade is a comma-separated list of variable names, such as m, mx. Both programs are run, and the values of these variables at the end must match. input_argument is not used.

6.4 A text question on the programming site

question_answer has one line for each answer box, name=value, as in 5.4. Several correct answers are separated with ; (PrimeNumber=3;13;23). If the answer itself has a semicolon, write it as \; (in the JSON file: "\\;").

7Text of the question, hint and explanation
  • question_content, question_hint and q_solution_explanation are Markdown. A blank line starts a new paragraph. Code can be written with backticks.
  • On the mathematics site, LaTeX formulas can be used: $...$ inline and $$...$$ as a block.
  • \ans{name} draws a box in the text, at the place of the answer name.
8Files of before 1.0

Files without ces_question_format are read as before. In such files, and only for compatibility, these other names are accepted. Do not use them in new files.

Key of 1.0 Other names also accepted
question_type exercise_type, q_type
question_title title
question_content q_content
question_variable q_variable
question_answer answer
answer_candidate answer_choices
question_hint hint
q_solution_explanation solution_explanation
answer_template code_template
object_for_grade code_output

In a file of before 1.0, the question type is guessed when it is missing or is not a type of the site: on the programming site, a question with answer_template or object_for_grade is code; otherwise it is text.

9Examples
File Site Type
code_python_function.json code code, a function with test cases
code_python_variables.json code code, variables
code_text.json code text
math_text.json math text with parameters, two answers
math_text_integral.json math text with answer_const
math_select.json math select
math_matrix.json math matrix
math_several_questions.json math an array of two questions

A programming question:

{
  "ces_question_format": "1.0",
  "site": "code",
  "question_type": "code",
  "question_title": "Sum of two numbers",
  "question_content": "Write a function `add(a, b)` that returns the sum of `a` and `b`.",
  "score": 1,
  "evaluation_method": 1,
  "code_language": "Python",
  "answer_template": "def add(a, b):\n    # Write your code here.\n    return None\n",
  "sample_code": "def add(a, b):\n    return a + b\n",
  "object_for_grade": "add(a, b)",
  "input_argument": "1, 2\n-3, 5\n0.5, 0.25",
  "question_hint": "Use the + operator.",
  "q_solution_explanation": "Return `a + b`.",
  "note": "Week 1"
}

A math question:

{
  "ces_question_format": "1.0",
  "site": "math",
  "question_type": "text",
  "question_title": "Derivative of a polynomial",
  "question_content": "Let $f(x) = a x^2 + b x$. Find $f'(x)$ and $f'(1)$.\n\n$f'(x) = $ \\ans{A}, $f'(1) = $ \\ans{B}",
  "question_variable": "a=1,...,5\nb=-3,-2,-1,1,2,3",
  "question_answer": "A=2*a*x+b\nB=2*a+b",
  "evaluation_method": 0,
  "score": 2,
  "question_hint": "$(x^n)' = n x^{n-1}$",
  "q_solution_explanation": "$f'(x) = 2ax + b$, so $f'(1) = 2a + b$."
}
10Instructions for AI agents

Give this section, or the whole document, to an AI agent that writes question files.

You write question files for CES-Alpha in the "CES-Alpha Question JSON File Format 1.0".
- Output valid JSON only, UTF-8, with no comments and no text around it.
- Each question is an object that starts with "ces_question_format": "1.0" and "site": "code" or "math".
- For several questions, output a JSON array of such objects.
- Use only the keys of the format. Never use the old names of section 8.
- Always set question_type, question_title, question_content and question_answer
  (for a programming "code" question: code_language, sample_code and object_for_grade instead of question_answer).
- Math site: question_type is "text", "select" or "matrix"; expressions use SymPy syntax (2*x, x^2, sqrt(x), pi, E).
  A "text" answer has one line "name=expression" per answer box; mark each box in the text with \ans{name}.
  A "select" answer is exactly one of answer_candidate.
- Programming site: question_type is "code" or "text"; code_language is "Python", "R" or "MATLAB".
  sample_code must run without errors and define what object_for_grade names.
  For a function, give several test cases in input_argument, one per line.
- Escape inside JSON strings: newline as \n, backslash as \\ (LaTeX \frac is written \\frac), double quote as \".
- Check that the answer is correct before writing it.
11Changes
Version Date Changes
1.0 2026-10 First version: the header ces_question_format and site; answer_const; the old names of section 8 are for compatibility only.
手册 / CES-Alpha 题目 JSON 文件格式 — 版本 1.0

CES-Alpha 题目 JSON 文件格式 — 版本 1.0

Markdown 版(供 AI 智能体使用) auto_grade_question_format.zh-Hans.md

目录
  • 1文件的使用场景
  • 2文件基本规则
  • 3文件头(必需)
  • 4两个站点共用的字段
  • 5数学站点("site": "math")
  • 6编程站点("site": "code")
  • 7题目正文、提示和解答说明
  • 81.0 之前的文件
  • 9示例
  • 10给 AI 智能体的说明
  • 11变更记录

本文档规定了用于保存 CES-Alpha 自动评分题目(一道或多道)的 JSON 文件格式。无论是手工编写、用脚本生成,还是让 AI 智能体生成这类文件,都请遵循本文档。

  • 本文档网页版:https://document.ces-alpha.jp/manual/auto_grade_question_format.html
  • 本文档 Markdown 版:https://document.ces-alpha.jp/manual/auto_grade_question_format.zh-Hans.md
  • 示例文件:见第 9 节
1文件的使用场景

在教师的题目编辑页面中:

  • 下载:页面底部的“题目 JSON 文件”区域可将当前题目下载为本格式的文件(“下载 JSON 文件”)。
  • 加载一个文件:“加载题目” → “从本地 JSON 文件”可将一道题目填入表单。在按下保存按钮之前,不会保存任何内容。
  • 加载多道题目:如果选择了多个文件、一个 .zip 文件,或一个包含题目列表的文件,其中所有题目都会作为新题目添加到页面上所选的分组中。

系统有两个站点,一个文件只对应其中一个站点:

站点 site 题目
编程站点(code.ces-alpha.org 及其子站点) "code" 编程题,以及简短文本作答题
数学站点(math.ces-alpha.org) "math" 通过符号计算评分的数学题
2文件基本规则
  • 编码:UTF-8。格式:JSON(RFC 8259)。扩展名:.json。
  • 一道题目就是一个 JSON 对象。多道题目可采用以下任一方式:
    • 在一个文件中使用由题目对象组成的 JSON 数组;
    • 同时选择多个 .json 文件;
    • 使用包含 .json 文件的 .zip 文件(其中可以有文件夹;以 . 开头的文件和 __MACOSX 文件夹会被跳过)。
  • 所有文本值都是 JSON 字符串。换行写作 \n,反斜杠写作 \\,因此 LaTeX 的 \frac{1}{2} 在文件中写作 "\\frac{1}{2}"。
  • 本文档未列出的键会被忽略。
  • 空字符串 "" 与缺少该键的含义相同。
3文件头(必需)

格式 1.0 的每个题目对象都以下面两个键开头:

键 类型 值
ces_question_format 字符串 "1.0":格式版本,形式为 "主版本.次版本"。
site 字符串 "code" 或 "math":题目所属的站点。

读取文件时的规则:

  • 主版本相同、次版本任意("1.0"、"1.2"、…):文件会被读取;较新次版本中新增的键会被忽略。
  • 主版本不同("2.0"、…):拒绝读取该文件。
  • site 与当前页面的站点不一致:拒绝读取该文件。数学题不能加载到编程站点,反之亦然。
  • 没有 ces_question_format 键:该文件被视为 1.0 之前的文件(见第 8 节),按以前的方式读取。
4两个站点共用的字段
键 类型 必需 默认值 含义
question_type 字符串 是 — 题目类型。取值见第 5 节(数学)和第 6 节(编程)。
question_title 字符串 是* "" 在题目列表中显示的标题。
question_content 字符串 是* "" 显示给学生的题目正文(第 7 节)。
score 整数 否 1 题目的分值(表单中的“成绩设定”)。
evaluation_method 整数 否 数学 0,编程 1 答案的评分方式。取值见第 5 节和第 6 节。
question_hint 字符串 否 "" 学生可以打开查看的提示(表单中的“提示”)。
q_solution_explanation 字符串 否 "" 解答说明,与正确答案一起显示给学生(表单中的“问题解答说明”)。
note 字符串 否 "" 给教师看的备注,学生永远看不到(表单中的“注解”)。

* question_title 和 question_content 至少要设置一个。建议两个都设置。

5数学站点("site": "math")

5.1 题目类型

question_type 学生…… 使用的字段
"text" 输入一个或多个表达式(表单中的“文本对话框中回答”) question_answer、question_variable、answer_const
"select" 从列表中选择一项(表单中的“选择题”) answer_candidate、question_answer
"matrix" 输入向量或矩阵(表单中的“以矩阵或者向量形式回答”) question_answer、question_variable

5.2 字段

键 类型 必需 含义
question_variable 字符串 否 参数(表单中的“参数”):随机取值,使每个学生的题目各不相同(5.3)。
question_answer 字符串 是 正确答案。其形式取决于 question_type(5.4)。
answer_candidate 字符串数组 仅 select 各个选项,按显示顺序排列。
answer_const 布尔值 否(仅 text) true:与 question_answer 只相差一个常数的答案也判为正确(用于不定积分;表单中的“答案判定时忽略不定积分结果中的常数。”)。默认 false。

5.3 参数(question_variable)

每行一个参数(各行之间用 \n 分隔),格式为 名称=取值:

a=1,2,5
b_1=-3,...,-1,1,...,5
alpha=1,...,5
beta=a+b_1
  • 逗号分隔的数值列表:为每个学生随机抽取其中一个值。m,...,n 表示从 m 到 n 的所有整数。
  • 表达式(含有字母,例如 beta=a+b_1):由其他参数计算得到。
  • 名称:一个字母(a、b、x、…)或希腊字母名称(alpha、beta、…;但不能用 lambda、pi 或 e),可以带一位数字的下标(b_1、beta_9)。
  • E(或 e)、pi 和 I(虚数单位)是数学常数。
  • 在 question_content 中,$...$ 内的参数会被替换为其取值。在那里希腊字母要带反斜杠书写($\\alpha$);在 question_variable 中则不带反斜杠(alpha)。

5.4 答案(question_answer)

text:每个答案框一行,格式为 名称=表达式:

A=2*a*x+b
B=2*a+b
  • 名称(A、B)是答案框的标签。在题目正文中用 \ans{A} 标出答案框的位置(第 7 节)。
  • 表达式的写法与计算器相同,采用 SymPy 语法:乘法用 *,乘方用 ^ 或 **,以及 sqrt(x)、sin(x)、exp(x)、log(x)、pi、E、I、oo(无穷大)。可以使用参数。
  • 一个答案框有多个正确答案时,用 ; 分隔(x=2;-2)。
  • 只对某一行指定评分方式:在该行末尾加上 # mode:1、# mode:2 或 # mode:3(A=x+1 # mode:3)。编号与 5.5 中的相同。

matrix:每行写矩阵的一行,元素之间用逗号分隔。列向量每行写一个元素。

a+2, 2
1, 1

select:正确选项的文本,必须与 answer_candidate 中的写法完全一致。

5.5 评分方式(evaluation_method)

值 表单中的名称 判为正确的条件
0 [mode:1] 等价性判定(Equivalence check) 数学含义相同:(x-1)^2 = x^2-2x+1。
1 [mode:2] 形式判定(Formal check) 形式相同(不计顺序):(x-3)(x-1) = (x-1)(x-3),但 3x ≠ x+2x。
2 [mode:3] 严格判定(Strict check) 字符串完全相同:2x ≠ 2*x。

select 不使用此字段,它总是比较所选的文本。

6编程站点("site": "code")

6.1 题目类型

question_type 学生…… 评分方式
"code" 编写程序(表单中的“编写程序”) 用相同输入运行 sample_code 和学生的代码,并比较结果
"text" 输入简短答案(表单中的“文本对话框中回答”) 与 question_answer 进行比较

6.2 code 题目的字段

键 类型 必需 含义
code_language 字符串 是 "Python"(Python 3)、"R" 或 "MATLAB"(用 Octave 运行)。默认 "Python"。
answer_template 字符串 否 学生编辑器中的初始代码。
sample_code 字符串 是 参考答案。它在评分服务器上运行,学生看不到。
object_for_grade 字符串 是 比较的对象(6.3)。
input_argument 字符串 否 函数调用的输入,每行一个测试用例(6.3)。
evaluation_method 整数 否 1:运行代码并比较结果(默认;表单中的“检查程序运行结果”)。

6.3 比较的对象(object_for_grade、input_argument)

有两种方式。

函数。 object_for_grade 是一个函数调用,例如 add(a, b)。input_argument 的每一行是一个测试用例:其中逗号分隔的各个值按顺序代入各参数的位置。对每个测试用例,分别调用 sample_code 和学生代码中的该函数,返回值必须一致。

"object_for_grade": "add(a, b)",
"input_argument": "1, 2\n-3, 5\n0.5, 0.25"
  • 列表和嵌套调用也可以作为值:[1,2], 5 和 c(1,2,3), 1000 都各是两个值。
  • 也可以使用占位符 var1、var2、…(只有一个值时用 var),占位符也可以写在表达式中:solve(var1, np.array([var2, var3]))。
  • 如果没有 input_argument,函数会不带参数调用一次(f())。

变量。 object_for_grade 是逗号分隔的变量名列表,例如 m, mx。两个程序都会运行,运行结束时这些变量的值必须一致。此时不使用 input_argument。

6.4 编程站点上的 text 题目

question_answer 每个答案框一行,格式为 名称=值,与 5.4 相同。多个正确答案用 ; 分隔(PrimeNumber=3;13;23)。如果答案本身含有分号,写作 \;(在 JSON 文件中写作 "\\;")。

7题目正文、提示和解答说明
  • question_content、question_hint 和 q_solution_explanation 采用 Markdown 格式。空一行表示开始新段落。代码可以用反引号书写。
  • 在数学站点上可以使用 LaTeX 公式:行内公式用 $...$,独立公式块用 $$...$$。
  • \ans{名称} 会在正文中答案 名称 的位置绘制一个答案框。
81.0 之前的文件

没有 ces_question_format 的文件按以前的方式读取。仅为了兼容,在这类文件中还接受以下其他名称。新文件中请不要使用它们。

1.0 的键 同样接受的其他名称
question_type exercise_type、q_type
question_title title
question_content q_content
question_variable q_variable
question_answer answer
answer_candidate answer_choices
question_hint hint
q_solution_explanation solution_explanation
answer_template code_template
object_for_grade code_output

在 1.0 之前的文件中,如果缺少题目类型,或题目类型不是该站点的类型,系统会推断题目类型:在编程站点上,含有 answer_template 或 object_for_grade 的题目视为 code,否则视为 text。

9示例
文件 站点 类型
code_python_function.json code code,带测试用例的函数
code_python_variables.json code code,变量
code_text.json code text
math_text.json math 带参数的 text,两个答案
math_text_integral.json math 带 answer_const 的 text
math_select.json math select
math_matrix.json math matrix
math_several_questions.json math 包含两道题目的数组

一道编程题:

{
  "ces_question_format": "1.0",
  "site": "code",
  "question_type": "code",
  "question_title": "Sum of two numbers",
  "question_content": "Write a function `add(a, b)` that returns the sum of `a` and `b`.",
  "score": 1,
  "evaluation_method": 1,
  "code_language": "Python",
  "answer_template": "def add(a, b):\n    # Write your code here.\n    return None\n",
  "sample_code": "def add(a, b):\n    return a + b\n",
  "object_for_grade": "add(a, b)",
  "input_argument": "1, 2\n-3, 5\n0.5, 0.25",
  "question_hint": "Use the + operator.",
  "q_solution_explanation": "Return `a + b`.",
  "note": "Week 1"
}

一道数学题:

{
  "ces_question_format": "1.0",
  "site": "math",
  "question_type": "text",
  "question_title": "Derivative of a polynomial",
  "question_content": "Let $f(x) = a x^2 + b x$. Find $f'(x)$ and $f'(1)$.\n\n$f'(x) = $ \\ans{A}, $f'(1) = $ \\ans{B}",
  "question_variable": "a=1,...,5\nb=-3,-2,-1,1,2,3",
  "question_answer": "A=2*a*x+b\nB=2*a+b",
  "evaluation_method": 0,
  "score": 2,
  "question_hint": "$(x^n)' = n x^{n-1}$",
  "q_solution_explanation": "$f'(x) = 2ax + b$, so $f'(1) = 2a + b$."
}
10给 AI 智能体的说明

请把本节或整篇文档交给负责编写题目文件的 AI 智能体。

你按照“CES-Alpha 题目 JSON 文件格式 1.0”为 CES-Alpha 编写题目文件。
- 只输出合法的 JSON,使用 UTF-8,不加注释,前后不附带任何文字。
- 每道题目是一个对象,以 "ces_question_format": "1.0" 和 "site": "code" 或 "math" 开头。
- 多道题目时,输出由这类对象组成的 JSON 数组。
- 只使用本格式规定的键。绝不使用第 8 节中的旧名称。
- 务必设置 question_type、question_title、question_content 和 question_answer
  (对于编程站点的 "code" 题目,用 code_language、sample_code 和 object_for_grade 代替 question_answer)。
- 数学站点:question_type 为 "text"、"select" 或 "matrix";表达式使用 SymPy 语法(2*x、x^2、sqrt(x)、pi、E)。
  "text" 题目的答案每个答案框一行 "name=expression";在正文中用 \ans{name} 标出每个答案框。
  "select" 题目的答案必须与 answer_candidate 中的某一项完全一致。
- 编程站点:question_type 为 "code" 或 "text";code_language 为 "Python"、"R" 或 "MATLAB"。
  sample_code 必须能无错误地运行,并定义 object_for_grade 中所指的对象。
  对于函数,在 input_argument 中给出多个测试用例,每行一个。
- JSON 字符串内的转义:换行写作 \n,反斜杠写作 \\(LaTeX 的 \frac 写作 \\frac),双引号写作 \"。
- 写入答案之前,先确认答案是正确的。
11变更记录
版本 日期 变更内容
1.0 2026-10 第一版:新增文件头 ces_question_format 和 site;新增 answer_const;第 8 节中的旧名称仅用于兼容。
手冊 / CES-Alpha 題目 JSON 檔案格式 — 版本 1.0

CES-Alpha 題目 JSON 檔案格式 — 版本 1.0

Markdown 版(供 AI 代理使用) auto_grade_question_format.zh-Hant.md

目錄
  • 1檔案的使用場合
  • 2檔案基本規則
  • 3標頭(必要)
  • 4兩個網站共用的欄位
  • 5數學網站("site": "math")
  • 6程式網站("site": "code")
  • 7題目內容、提示與解答說明的文字
  • 81.0 之前的檔案
  • 9範例
  • 10給 AI 代理的指示
  • 11變更紀錄

本文件說明存放 CES-Alpha 自動評分題目(一題或多題)的 JSON 檔案格式。無論是手動撰寫、用程式產生,或交給 AI 代理產生這種檔案,都請依照本文件。

  • 本文件的網頁版:https://document.ces-alpha.jp/manual/auto_grade_question_format.html
  • 本文件的 Markdown 版:https://document.ces-alpha.jp/manual/auto_grade_question_format.zh-Hant.md
  • 範例檔案:第 9 節
1檔案的使用場合

在教師的題目編輯頁面中:

  • 下載:頁面底部的「題目 JSON 檔案」區塊(「下載 JSON 檔案」)可將題目下載為本格式的檔案。
  • 載入一個檔案:「載入題目」→「從本機 JSON 檔案」會把一道題目填入表單。在按下儲存按鈕之前,不會儲存任何內容。
  • 載入多道題目:如果選擇多個檔案、一個 .zip 檔案,或一個包含題目清單的檔案,其中所有題目都會以新題目的形式加入頁面上所選的群組。

系統有兩個網站,一個檔案只適用於其中一個:

網站 site 題目
程式網站(code.ces-alpha.org 及其子網站) "code" 程式設計題,以及簡短的文字作答題
數學網站(math.ces-alpha.org) "math" 以符號運算評分的數學題
2檔案基本規則
  • 編碼:UTF-8。格式:JSON(RFC 8259)。副檔名:.json。
  • 一道題目是一個 JSON 物件(object)。若有多道題目,可使用下列任一方式:
    • 在一個檔案中放入由題目物件組成的 JSON 陣列(array),
    • 同時選擇多個 .json 檔案,
    • 由 .json 檔案組成的 .zip 檔案(內部可以有資料夾;以 . 開頭的檔案及 __MACOSX 資料夾會被略過)。
  • 所有文字值都是 JSON 字串。換行寫成 \n。反斜線寫成 \\,因此 LaTeX 的 \frac{1}{2} 在檔案中寫成 "\\frac{1}{2}"。
  • 本文件未列出的鍵(key)會被忽略。
  • 空字串 "" 與沒有該鍵的意思相同。
3標頭(必要)

格式 1.0 的每個題目物件都以下列兩個鍵開頭:

鍵 型別 值
ces_question_format 字串 "1.0":格式版本,形式為 "major.minor"(主版本.次版本)。
site 字串 "code" 或 "math":題目所屬的網站。

讀取檔案時的規則:

  • 主版本相同,次版本不限("1.0"、"1.2"、…):檔案會被讀取;較新的次版本所新增的鍵會被忽略。
  • 主版本不同("2.0"、…):檔案會被拒絕。
  • site 與目前頁面的網站不同:檔案會被拒絕。數學題無法在程式網站載入,反之亦然。
  • 沒有 ces_question_format 鍵:視為 1.0 之前的檔案(見第 8 節),依照以往的方式讀取。
4兩個網站共用的欄位
鍵 型別 必要 預設值 意義
question_type 字串 是 — 題目種類。可用的值:見第 5 節(數學)及第 6 節(程式)。
question_title 字串 是* "" 顯示在題目清單中的標題。
question_content 字串 是* "" 顯示給學生的題目內容(第 7 節)。
score 整數 否 1 題目的配分(表單中的「分數設定」)。
evaluation_method 整數 否 數學 0,程式 1 作答的評分方式。可用的值:見第 5 節及第 6 節。
question_hint 字串 否 "" 學生可以開啟查看的「提示」。
q_solution_explanation 字串 否 "" 「解答說明」,與正確答案一起顯示給學生。
note 字串 否 "" 給教師看的「備註」。學生永遠看不到。

* question_title 與 question_content 至少要設定其中一個。建議兩者都設定。

5數學網站("site": "math")

5.1 題目種類

question_type 學生要… 使用的欄位
"text"(「在文字方塊中作答」) 輸入一個或多個算式 question_answer、question_variable、answer_const
"select"(「選擇題」) 從清單中選擇一項 answer_candidate、question_answer
"matrix"(「以矩陣作答」) 輸入向量或矩陣 question_answer、question_variable

5.2 欄位

鍵 型別 必要 意義
question_variable 字串 否 「參數」:隨機值,讓每位學生的題目都不同(5.3)。
question_answer 字串 是 正確答案。寫法依 question_type 而定(5.4)。
answer_candidate 字串陣列 僅 select 選項,依顯示順序排列。
answer_const 布林值 否(僅 text) true:與 question_answer 相差一個常數的答案也視為正確(不定積分)。對應表單中的「允許相差一個常數(例如不定積分)」。預設為 false。

5.3 參數(question_variable)

每行一個參數(行與行之間以 \n 分隔),寫成 名稱=值:

a=1,2,5
b_1=-3,...,-1,1,...,5
alpha=1,...,5
beta=a+b_1
  • 以逗號分隔的數字清單:為每位學生隨機抽取其中一個值。m,...,n 代表從 m 到 n 的所有整數。
  • 算式(含有字母,例如 beta=a+b_1):由其他參數計算得出。
  • 名稱:一個字母(a、b、x、…)或希臘字母名稱(alpha、beta、…;不可使用 lambda、pi 或 e),可加上一位數的下標(b_1、beta_9)。
  • E(或 e)、pi 與 I(虛數單位)為數學常數。
  • 在 question_content 中,寫在 $...$ 裡的參數會被替換成它的值。在那裡希臘字母要加反斜線($\\alpha$);在 question_variable 中則不加(alpha)。

5.4 答案(question_answer)

text:每個答案方塊一行,寫成 名稱=算式:

A=2*a*x+b
B=2*a+b
  • 名稱(A、B)是答案方塊的標籤。在題目內容中用 \ans{A} 標示方塊的位置(第 7 節)。
  • 算式的寫法如同計算機,採用 SymPy 語法:乘法用 *,次方用 ^ 或 **,以及 sqrt(x)、sin(x)、exp(x)、log(x)、pi、E、I、oo(無限大)。可以使用參數。
  • 一個方塊有多個正確答案時:以 ; 分隔(x=2;-2)。
  • 只對某一行指定評分方式:在該行末尾加上 # mode:1、# mode:2 或 # mode:3(A=x+1 # mode:3)。數字對應 5.5 的編號。

matrix:每行一列,元素之間以逗號分隔。行向量(column vector)則每行一個元素。

a+2, 2
1, 1

select:正確選項的文字,必須與 answer_candidate 中的寫法完全相同。

5.5 評分方式(evaluation_method)

值 表單中的名稱 判定為正確的條件
0 [mode:1] 等價性判定 (Equivalence check) 數學意義相同:(x-1)^2 = x^2-2x+1。
1 [mode:2] 形式判定 (Formal check) 形式相同(不計順序):(x-3)(x-1) = (x-1)(x-3),但 3x ≠ x+2x。
2 [mode:3] 嚴格判定 (Strict check) 字串完全相同:2x ≠ 2*x。

select 不使用此設定,一律比對所選的文字。

6程式網站("site": "code")

6.1 題目種類

question_type 學生要… 評分方式
"code"(「撰寫程式」) 撰寫程式 以相同輸入執行 sample_code 與學生的程式碼,並比對結果
"text"(「在文字方塊中作答」) 輸入簡短答案 與 question_answer 比對

6.2 code 題目的欄位

鍵 型別 必要 意義
code_language 字串 是 "Python"(Python 3)、"R" 或 "MATLAB"(以 Octave 執行)。預設為 "Python"。
answer_template 字串 否 學生編輯器中的初始程式碼。
sample_code 字串 是 參考解答。在評分伺服器上執行;學生看不到。
object_for_grade 字串 是 比對的對象(6.3)。
input_argument 字串 否 函式呼叫的輸入,每行一個測試案例(6.3)。
evaluation_method 整數 否 1:執行程式並比對結果(「檢查程式執行結果」,預設值)。

6.3 比對的對象(object_for_grade、input_argument)

有兩種方式。

函式。 object_for_grade 是一個呼叫,例如 add(a, b)。input_argument 的每一行是一個測試案例:以逗號分隔的各個值,依序代入引數的位置。對每個測試案例,分別在 sample_code 與學生的程式碼中呼叫該函式,兩者的回傳值必須一致。

"object_for_grade": "add(a, b)",
"input_argument": "1, 2\n-3, 5\n0.5, 0.25"
  • 值可以是清單或巢狀呼叫:[1,2], 5 與 c(1,2,3), 1000 各自是兩個值。
  • 也可以使用預留位置 var1、var2、…(只有一個值時用 var),在算式中也能使用:solve(var1, np.array([var2, var3]))。
  • 若沒有 input_argument,則不帶引數呼叫函式一次(f())。

變數。 object_for_grade 是以逗號分隔的變數名稱清單,例如 m, mx。兩個程式都會被執行,執行結束時這些變數的值必須一致。不使用 input_argument。

6.4 程式網站上的 text 題目

question_answer 每個答案方塊一行,寫成 名稱=值,與 5.4 相同。多個正確答案以 ; 分隔(PrimeNumber=3;13;23)。若答案本身含有分號,寫成 \;(在 JSON 檔案中為 "\\;")。

7題目內容、提示與解答說明的文字
  • question_content、question_hint 與 q_solution_explanation 採用 Markdown。空一行即開始新段落。程式碼可用反引號(backtick)標示。
  • 在數學網站上可以使用 LaTeX 公式:行內用 $...$,獨立區塊用 $$...$$。
  • \ans{name} 會在文字中、答案 name 的位置畫出一個答案方塊。
81.0 之前的檔案

沒有 ces_question_format 的檔案依照以往的方式讀取。僅為了相容性,在這類檔案中也接受下列其他名稱。新檔案請勿使用。

1.0 的鍵 同樣接受的其他名稱
question_type exercise_type、q_type
question_title title
question_content q_content
question_variable q_variable
question_answer answer
answer_candidate answer_choices
question_hint hint
q_solution_explanation solution_explanation
answer_template code_template
object_for_grade code_output

在 1.0 之前的檔案中,若缺少題目種類,或其值不是該網站的種類,系統會自動推測:在程式網站上,含有 answer_template 或 object_for_grade 的題目視為 code;否則視為 text。

9範例
檔案 網站 種類
code_python_function.json code code,含測試案例的函式
code_python_variables.json code code,變數
code_text.json code text
math_text.json math text,含參數,兩個答案
math_text_integral.json math text,含 answer_const
math_select.json math select
math_matrix.json math matrix
math_several_questions.json math 包含兩道題目的陣列

程式設計題範例:

{
  "ces_question_format": "1.0",
  "site": "code",
  "question_type": "code",
  "question_title": "Sum of two numbers",
  "question_content": "Write a function `add(a, b)` that returns the sum of `a` and `b`.",
  "score": 1,
  "evaluation_method": 1,
  "code_language": "Python",
  "answer_template": "def add(a, b):\n    # Write your code here.\n    return None\n",
  "sample_code": "def add(a, b):\n    return a + b\n",
  "object_for_grade": "add(a, b)",
  "input_argument": "1, 2\n-3, 5\n0.5, 0.25",
  "question_hint": "Use the + operator.",
  "q_solution_explanation": "Return `a + b`.",
  "note": "Week 1"
}

數學題範例:

{
  "ces_question_format": "1.0",
  "site": "math",
  "question_type": "text",
  "question_title": "Derivative of a polynomial",
  "question_content": "Let $f(x) = a x^2 + b x$. Find $f'(x)$ and $f'(1)$.\n\n$f'(x) = $ \\ans{A}, $f'(1) = $ \\ans{B}",
  "question_variable": "a=1,...,5\nb=-3,-2,-1,1,2,3",
  "question_answer": "A=2*a*x+b\nB=2*a+b",
  "evaluation_method": 0,
  "score": 2,
  "question_hint": "$(x^n)' = n x^{n-1}$",
  "q_solution_explanation": "$f'(x) = 2ax + b$, so $f'(1) = 2a + b$."
}
10給 AI 代理的指示

請將本節(或整份文件)提供給負責撰寫題目檔案的 AI 代理。

你要依照「CES-Alpha 題目 JSON 檔案格式 1.0」撰寫 CES-Alpha 的題目檔案。
- 只輸出有效的 JSON,使用 UTF-8,不加註解,前後不加任何文字。
- 每道題目是一個物件,開頭為 "ces_question_format": "1.0" 以及 "site": "code" 或 "math"。
- 若有多道題目,輸出由這些物件組成的 JSON 陣列。
- 只使用本格式定義的鍵。絕對不要使用第 8 節的舊名稱。
- 一律設定 question_type、question_title、question_content 與 question_answer
  (程式設計的 "code" 題目則改為設定 code_language、sample_code 與 object_for_grade,而非 question_answer)。
- 數學網站:question_type 為 "text"、"select" 或 "matrix";算式使用 SymPy 語法(2*x、x^2、sqrt(x)、pi、E)。
  "text" 的答案每個答案方塊一行 "name=expression";在題目內容中以 \ans{name} 標示每個方塊。
  "select" 的答案必須與 answer_candidate 中的某一項完全相同。
- 程式網站:question_type 為 "code" 或 "text";code_language 為 "Python"、"R" 或 "MATLAB"。
  sample_code 必須能無錯誤地執行,並定義 object_for_grade 所指名的對象。
  若比對函式,請在 input_argument 中提供多個測試案例,每行一個。
- JSON 字串內的跳脫:換行寫成 \n,反斜線寫成 \\(LaTeX 的 \frac 寫成 \\frac),雙引號寫成 \"。
- 寫出答案之前,先確認答案正確。
11變更紀錄
版本 日期 變更內容
1.0 2026-10 第一版:標頭 ces_question_format 與 site;answer_const;第 8 節的舊名稱僅為相容性而保留。