Public Access
feat: add redo functionality for failed exam questions and update translations
This commit is contained in:
1 parent
acbcfde617
commit
028c732716
8 files changed
+86
-31
No files matched your search
@@ -12,10 +12,11 @@ interface Props {
|
||||
state: ExamState
|
||||
onRestart: () => void
|
||||
onExit: () => void
|
||||
onRedoFailed?: () => void
|
||||
reviewOnly?: boolean
|
||||
}
|
||||
|
||||
export default function Results({ exam, state, onRestart, onExit, reviewOnly }: Props) {
|
||||
export default function Results({ exam, state, onRestart, onExit, onRedoFailed, reviewOnly }: Props) {
|
||||
const { t } = useTranslation()
|
||||
const { answers, startedAt, completedAt } = state
|
||||
const elapsedMs = (completedAt ?? Date.now()) - startedAt
|
||||
@@ -30,6 +31,7 @@ export default function Results({ exam, state, onRestart, onExit, reviewOnly }:
|
||||
const scorePoints = graded.reduce((a, g) => a + g.result.points, 0)
|
||||
const gradedCount = graded.filter((g) => g.result.status !== 'ungraded').length
|
||||
const correctCount = graded.filter((g) => g.result.correct).length
|
||||
const failedCount = gradedCount - correctCount
|
||||
const pct = totalPoints ? Math.round((scorePoints / totalPoints) * 100) : 0
|
||||
const passing = exam.passingScore ?? 60
|
||||
const passed = pct >= passing
|
||||
@@ -137,7 +139,16 @@ export default function Results({ exam, state, onRestart, onExit, reviewOnly }:
|
||||
})}
|
||||
|
||||
<div style={{ marginTop: 48, display: 'flex', gap: 12 }}>
|
||||
{!reviewOnly && <button className="btn btn-primary" onClick={onRestart}>{t('results.retakeExam')}</button>}
|
||||
{!reviewOnly && (
|
||||
<>
|
||||
<button className="btn btn-primary" onClick={onRestart}>{t('results.retakeExam')}</button>
|
||||
{onRedoFailed && failedCount > 0 && (
|
||||
<button className="btn" onClick={onRedoFailed}>
|
||||
{t('results.redoFailed')}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<button className="btn" onClick={onExit}>{t('results.backToHome')}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user