diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 6829d44..5a3603b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -95,7 +95,7 @@ export default function App() { )} {screen === 'exam' && exam && examState && ( - + >} onSubmit={submit} onExit={exit} /> )} {(screen === 'results' || screen === 'review') && exam && examState && ( diff --git a/frontend/src/components/ExamRunner.tsx b/frontend/src/components/ExamRunner.tsx index 334bc3a..87b3b47 100644 --- a/frontend/src/components/ExamRunner.tsx +++ b/frontend/src/components/ExamRunner.tsx @@ -59,7 +59,8 @@ export default function ExamRunner({ exam, state, setState, onSubmit, onExit }: if (e.key === 'f') toggleFlag() if (/^[1-9]$/.test(e.key) && q.type === 'multiple-choice' && q.choices) { const ci = parseInt(e.key, 10) - 1 - if (q.choices[ci]) setState((s) => ({ ...s, answers: { ...s.answers, [q.id]: q.choices[ci].id } })) + const choices = q.choices + if (choices[ci]) setState((s) => ({ ...s, answers: { ...s.answers, [q.id]: choices[ci].id } })) } } window.addEventListener('keydown', handler) diff --git a/frontend/src/components/Tex.tsx b/frontend/src/components/Tex.tsx index 736f71d..cb37ebc 100644 --- a/frontend/src/components/Tex.tsx +++ b/frontend/src/components/Tex.tsx @@ -1,14 +1,16 @@ +import type React from 'react' import { renderLatex } from '../utils/latex' interface TexProps { children?: string | null - tag?: keyof JSX.IntrinsicElements + tag?: keyof React.JSX.IntrinsicElements className?: string style?: React.CSSProperties } // Safe: renderLatex only produces KaTeX-controlled HTML + HTML-escaped plain text. -export default function Tex({ children, tag: Tag = 'span', className, style }: TexProps) { +export default function Tex({ children, tag = 'span', className, style }: Readonly) { + const Tag = tag as React.ElementType const html = String(children ?? '').split('\n').map(renderLatex).join('
') return } diff --git a/frontend/src/components/questions/Essay.tsx b/frontend/src/components/questions/Essay.tsx index 12d269c..56c5c32 100644 --- a/frontend/src/components/questions/Essay.tsx +++ b/frontend/src/components/questions/Essay.tsx @@ -3,6 +3,7 @@ import type { Question } from '../../types' interface EssayValue { text?: string selfGrade?: number + [key: string]: unknown } interface Props { diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index ca9c11d..e761466 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,5 +1,4 @@ -/// -import { defineConfig } from 'vite' +import { defineConfig } from 'vitest/config' import react, { reactCompilerPreset } from '@vitejs/plugin-react' import babel from '@rolldown/plugin-babel'