Fix test correction: remove transaction, add error handling

Replaced db.transaction() wrapper (unreliable in node:sqlite at this
version) with a plain loop. Added try/catch in the JS save handler so
any server error surfaces as a visible toast instead of failing silently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Nate EmmertandClaude Sonnet 4.6 committed 2026-08-21 09:06:12 -04:00
1 parent 0744ba9e39
commit 4ad11ea4ee
2 files changed
+14 -12

No files matched your search

+11 -7
View File
@@ -2119,13 +2119,17 @@ $('#correct-test-save').addEventListener('click', async () => {
wordId: Number(cb.dataset.wordId),
correct: cb.checked,
}));
const { score, total } = await api(`/api/tests/${correctTestId}/correct`, {
method: 'PATCH',
body: { corrections },
});
$('#correct-test-modal').hidden = true;
msg(`Score updated: ${score}/${total}`);
loadSpellingTests();
try {
const { score, total } = await api(`/api/tests/${correctTestId}/correct`, {
method: 'PATCH',
body: { corrections },
});
$('#correct-test-modal').hidden = true;
msg(`Score updated: ${score}/${total}`);
loadSpellingTests();
} catch (err) {
msg(err.message || 'Failed to save corrections', 'error');
}
});
$('#gradebook-course').addEventListener('change', () => renderGradebook($('#gradebook-course').value));