Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export const en = {
digitsLegend: "In the tables, 1 is ON and 0 is OFF.",
check: "Check",
passed: "Cleared! The circuit works for every combination of the inputs.",
passedSteps: (count: number) =>
`Cleared! The circuit works at every time step up to time step ${count}.`,
next: "Next stage",
backToStages: "Back to the stages",
missingPin: (pinType: "input" | "output", pinName: string) =>
Expand All @@ -176,6 +178,14 @@ export const en = {
actual: string | null,
) =>
`When ${listOf(inputs.map(({ name, value }) => `${name} is ${value}`))}, ${pinName} should be ${expected}, but it ${actual === null ? "has no value" : `is ${actual}`}.`,
wrongOutputAtStep: (
stepNumber: number,
inputs: readonly { name: string; value: string }[],
pinName: string,
expected: string,
actual: string | null,
) =>
`At time step ${stepNumber}${inputs.length > 0 ? ` (${listOf(inputs.map(({ name, value }) => `${name} is ${value}`))})` : ""}, ${pinName} should be ${expected}, but it ${actual === null ? "has no value" : `is ${actual}`}.`,
checkFailed:
"Something went wrong while checking. Change the circuit a little and press Check again.",
simulationFailed: (detail: string) =>
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export const ja: Messages = {
digitsLegend: "表の 1 は ON、0 は OFF です。",
check: "確かめる",
passed: "クリア!どの入力の組み合わせでも正しく動きます。",
passedSteps: (count) =>
`クリア!${count} ステップ目まで、どのステップでも正しく動きます。`,
next: "次の課題へ",
backToStages: "課題の一覧へ",
missingPin: (pinType, pinName) =>
Expand All @@ -116,6 +118,8 @@ export const ja: Messages = {
`${pinName} は ${expected}桁のはずですが、${actual}桁になっています。つないだ先を確かめてください。`,
wrongOutput: (inputs, pinName, expected, actual) =>
`${inputs.map(({ name, value }) => `${name} が ${value}`).join("、")} のとき、${pinName} は ${expected} になるはずが、${actual === null ? "値がありませんでした" : `${actual} でした`}。`,
wrongOutputAtStep: (stepNumber, inputs, pinName, expected, actual) =>
`${stepNumber} ステップ目${inputs.length > 0 ? `(${inputs.map(({ name, value }) => `${name} が ${value}`).join("、")})` : ""}に、${pinName} が ${expected} のはずが${actual === null ? "、値がありませんでした" : ` ${actual} でした`}。`,
checkFailed:
"確かめる途中で問題が起きました。回路を少し変えてから、もう一度押してください。",
simulationFailed: (detail) =>
Expand Down
27 changes: 27 additions & 0 deletions src/i18n/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,33 @@ describe("the message on a wrong output", () => {
});
});

describe("the message on a wrong output at a step", () => {
const { en, ja } = messagesByLanguage;
const start = [{ name: "Start", value: "ON" }];

it("puts the inputs of the step in brackets", () => {
expect(
en.tutorial.wrongOutputAtStep(3, start, "Count", "0011", "0010"),
).toBe(
"At time step 3 (Start is ON), Count should be 0011, but it is 0010.",
);
expect(
ja.tutorial.wrongOutputAtStep(3, start, "Count", "0011", "0010"),
).toBe(
"3 ステップ目(Start が ON)に、Count が 0011 のはずが 0010 でした。",
);
});

it("leaves the brackets out without inputs", () => {
expect(en.tutorial.wrongOutputAtStep(2, [], "Count", "0001", null)).toBe(
"At time step 2, Count should be 0001, but it has no value.",
);
expect(ja.tutorial.wrongOutputAtStep(2, [], "Count", "0001", null)).toBe(
"2 ステップ目に、Count が 0001 のはずが、値がありませんでした。",
);
});
});

describe("the message on a pin of the wrong width", () => {
it("counts digits in both languages", () => {
expect(messagesByLanguage.en.tutorial.wrongBitWidth("A", 4, 1)).toBe(
Expand Down
10 changes: 7 additions & 3 deletions src/pages/tutorial/stage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { StoreScope } from "../../store/react";
import { theme } from "../../style";
import {
type CheckResult,
checkCombinational,
checkCircuit,
goalTableOf,
} from "../../tutorial/check";
import { describeFailure } from "../../tutorial/failure";
Expand Down Expand Up @@ -96,7 +96,7 @@ function StageView({ stage }: { stage: TutorialStage }) {
}, [store]);

const check = () => {
const checked = checkCombinational(store, stage.componentId, stage.check);
const checked = checkCircuit(store, stage.componentId, stage.check);
if (checked.type === "checkFailed") console.error(checked.error);
setResult(checked);
if (checked.type === "passed") markStageCleared(stage.id);
Expand Down Expand Up @@ -228,7 +228,11 @@ function StageView({ stage }: { stage: TutorialStage }) {
</Button>
{result?.type === "passed" && (
<>
<Alert severity="success">{texts.passed}</Alert>
<Alert severity="success">
{stage.check.kind === "sequential"
? texts.passedSteps(stage.check.steps.length)
: texts.passed}
</Alert>
<Button
variant="outlined"
component={RouterLink}
Expand Down
Loading
Loading