Skip to content

Commit de8b16c

Browse files
committed
implement: Carry question metadata through to JSON (t4)
1 parent edbcb2e commit de8b16c

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎in2lambda/api/question.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class Question:
4545

4646
# Settings are left out of the repr so that printing a question still shows its
4747
# content rather than nine lines of configuration.
48-
skill: Optional[float] = field(default=None, repr=False)
48+
# An int too: Lambda Feedback's export is written by JavaScript, which writes the
49+
# lowest and highest skill levels as 0 and 1.
50+
skill: Optional[Union[int, float]] = field(default=None, repr=False)
4951
guidance: Optional[str] = field(default=None, repr=False)
5052
duration_lower_bound: Optional[int] = field(default=None, repr=False)
5153
duration_upper_bound: Optional[int] = field(default=None, repr=False)

‎tests/test_exports.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def test_question_settings_are_written(tmp_path: Path) -> None:
118118
question_set.questions = [
119119
Question(
120120
title="Configured",
121-
skill=1 / 3,
121+
# A whole number, as an export holds the highest skill level; the
122+
# fixture's questions cover fractional ones.
123+
skill=1,
122124
guidance="Try part a first.",
123125
duration_lower_bound=5,
124126
duration_upper_bound=10,
@@ -147,7 +149,7 @@ def test_question_settings_are_written(tmp_path: Path) -> None:
147149
"displayChatbot",
148150
]
149151
} == {
150-
"skill": 1 / 3,
152+
"skill": 1,
151153
"guidance": "Try part a first.",
152154
"durationLowerBound": 5,
153155
"durationUpperBound": 10,

0 commit comments

Comments
 (0)