괄호 안의 항을 2, 3, 4 항으로 설정하는 기능 추가

This commit is contained in:
2026-05-31 13:40:45 +09:00
parent e148a957ea
commit ac3c939051
21 changed files with 708 additions and 344 deletions
+11 -14
View File
@@ -6,7 +6,6 @@ import AnswerResultLine from "@/components/game/AnswerResultLine";
import type {
VariableGradeResult,
VariableParenthesisProblem,
VariableParenthesisTerm,
} from "@/lib/engine/variable-types";
import { formatVariableTermLatex } from "@/lib/engine/variable-parenthesis";
@@ -21,12 +20,6 @@ function formatSignedNumber(value: number) {
return value < 0 ? `(${value})` : `${value}`;
}
function formatSignedTerm(term: VariableParenthesisTerm, sign: 1 | -1) {
const coefficient = term.coefficient * sign;
return formatVariableTermLatex({ ...term, coefficient });
}
export default function VariableFeedbackPanel({
result,
problem,
@@ -34,14 +27,18 @@ export default function VariableFeedbackPanel({
onNext,
}: VariableFeedbackPanelProps) {
const nextButtonRef = useRef<HTMLButtonElement>(null);
const signedTerms = [
formatSignedTerm(problem.firstTerm, 1),
formatSignedTerm(problem.secondTerm, problem.operator === "-" ? -1 : 1),
] as const;
const signedTerms = problem.terms.map((term, index) =>
formatVariableTermLatex({
...term,
coefficient:
index > 0 && problem.operators[index - 1] === "-"
? -term.coefficient
: term.coefficient,
}),
);
const feedbackItems = signedTerms.map((termLatex, index) => {
const termIndex = index as 0 | 1;
const userAnswer = result.userAnswer[termIndex];
const correctAnswer = result.correctAnswer[termIndex];
const userAnswer = result.userAnswer[index];
const correctAnswer = result.correctAnswer[index];
return {
formulaLatex: `${formatSignedNumber(problem.multiplier)}\\times ${termLatex}`,