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
1 change: 1 addition & 0 deletions exam.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ <h3 class="help-title">How to use</h3>
<script src="./app-config.js"></script>
<script src="./data/irregular-verbs.js"></script>
<script src="./verb-utils.js"></script>
<script src="./flashcard-progress.js"></script>
<script src="./exam.js"></script>

</body>
Expand Down
4 changes: 3 additions & 1 deletion exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ function onPick(value, btn) {
locked = true;

const ans = window.VerbUtils.correctAnswer(currentV, currentT);
const isCorrect = value === ans;
choicesEl.querySelectorAll('button').forEach(b => b.disabled = true);
window.FlashcardProgress?.recordAnswer(currentV, isCorrect);

if (value === ans) {
if (isCorrect) {
score++;
btn.classList.add('correct');
feedbackEl.textContent = '✅ Correct!';
Expand Down
9 changes: 8 additions & 1 deletion tests/smoke.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test('Exercises can answer, save progress, and move to next question', async ({
expect(errors).toEqual([]);
});

test('Exam can complete 10 questions and show final result', async ({ page }) => {
test('Exam can complete 10 questions, save progress, and show final result', async ({ page }) => {
const errors = trackPageErrors(page);

await page.goto(pageUrl('exam.html'));
Expand All @@ -103,6 +103,13 @@ test('Exam can complete 10 questions and show final result', async ({ page }) =>
await page.locator('#nextExamBtn').click();
}

const progressRaw = await page.evaluate(() => window.localStorage.casualEnglishFlashcardProgress || null);
expect(progressRaw).not.toBeNull();

const progress = JSON.parse(progressRaw);
const totalViews = Object.values(progress).reduce((sum, entry) => sum + entry.views, 0);
expect(totalViews).toBe(10);

await expect(page.locator('#result')).toBeVisible();
await expect(page.locator('#resultScore')).toContainText('/ 10');
await expect(page.locator('#restartBtn')).toBeVisible();
Expand Down
Loading