Skip to content

Write a Boolean answer as 1 or 0, compared as a string - #97

Merged
peterbjohnson merged 4 commits into
mainfrom
boolean-as-number
Nov 8, 2026
Merged

peterbjohnson merged 4 commits into
mainfrom
boolean-as-number

Conversation

@peterbjohnson

Copy link
Copy Markdown
Member

Boolean areas built on Lambda Feedback mark correctly. Boolean areas exported by in2lambda don't.

When the platform runs a Boolean area's teacher test, it sends isExactEqual the following:

  • answer: 1
  • submission: 1
  • gradeParams: {type: "str"}

in2lambda wrote "answer": true and "gradeParams": null. So a student's 1 was compared with true, and the evaluation function had no type to cast them to. The platform's response area code (TrueFalse in the response area sandbox) also saves the answer, and sends each student's choice, as 1 or 0.

  • The Python API keeps bool. In the JSON, a Boolean area's answer and its test payloads are written as 1 or 0.
  • gradeParams for a Boolean area default to {"type": "str"}, with any grade_params the author sets merged over them. This is how NumericUnits adds physical_quantity.

Not yet checked by importing a set to the platform and running its teacher test.

🤖 Generated with Claude Code

peterbjohnson and others added 4 commits November 8, 2026 05:15
- Test.payload takes any type, as NUMBER tests in real exports store
  numbers.
- Each response area's answer is written as a passing test, first,
  unless the answer is empty or a passing test already has it.
- InputSymbol.greek builds the aliases of a Greek symbol from its
  unicode forms, with and without braces around a subscript.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An empty-list answer is no answer, so it is written as a failing test.
- A set with a multiple choice that marks no option correct raises
  ValueError before export, ahead of the output directory being
  cleared, naming the question and part.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The converter called a MultipleChoice-specific check and so had to import
that type. Each ResponseArea now declares payload_types, the types a test
payload may take, and a _validate method that subclasses extend; the
converter calls _validate on every area without naming any type. Number
refuses bool payloads, and MultipleChoice refuses an answer or test whose
length differs from its options. An empty answer now adds no test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnCY3kcqP1vQ7UixMtuRep
Lambda Feedback's own teacher test of a Boolean area sends isExactEqual
answer 1, submission 1 and gradeParams {type: "str"}. in2lambda wrote
the answer as true and no gradeParams, so a correct response of 1 never
matched. The Python API keeps bool; the JSON now holds 1 or 0, for the
answer and test payloads, with type "str" unless the author sets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peterbjohnson
peterbjohnson merged commit d8bb8db into main Nov 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants