Aptituderator: Easy difficulty ignored because getQuizDifficulty treats 0 as unset #1016

Closed
opened 2026-08-12 07:29:42 +00:00 by spikerj · 1 comment
Owner

Summary

Selecting Easy on an Aptituderator quiz card does not stick. getQuizDifficulty uses map.get(id) || Medium, and QuizAttemptDifficulty.Easy = 0 is falsy, so Easy always falls back to Medium.

Location

projects/spikersoft/src/app/_components/learning/aptituderator/aptituderator.component.ts — getQuizDifficulty.

Expected

After clicking the Easy chip, getQuizDifficulty(quizId) returns QuizAttemptDifficulty.Easy (0), and starting the quiz budgets 5 minutes/question.

Actual

The map stores Easy correctly (selectedDifficulties().get(id) === 0), but getQuizDifficulty returns Medium. Start flow then uses Medium timing.

Fix

Use nullish coalescing / has():

const d = this.selectedDifficulties().get(quizId);
return d !== undefined ? d : QuizAttemptDifficulty.Medium;

Caught by

Wave 6 a2 tick7 adversarial DOM coverage (aptituderator.render.spec.ts).

## Summary Selecting **Easy** on an Aptituderator quiz card does not stick. `getQuizDifficulty` uses `map.get(id) || Medium`, and `QuizAttemptDifficulty.Easy = 0` is falsy, so Easy always falls back to Medium. ## Location `projects/spikersoft/src/app/_components/learning/aptituderator/aptituderator.component.ts` — `getQuizDifficulty`. ## Expected After clicking the Easy chip, `getQuizDifficulty(quizId)` returns `QuizAttemptDifficulty.Easy` (0), and starting the quiz budgets 5 minutes/question. ## Actual The map stores Easy correctly (`selectedDifficulties().get(id) === 0`), but `getQuizDifficulty` returns Medium. Start flow then uses Medium timing. ## Fix Use nullish coalescing / `has()`: ```ts const d = this.selectedDifficulties().get(quizId); return d !== undefined ? d : QuizAttemptDifficulty.Medium; ``` ## Caught by Wave 6 a2 tick7 adversarial DOM coverage (`aptituderator.render.spec.ts`).
Author
Owner

Already present on spikersoft-angular master. getQuizDifficulty uses nullish coalescing (??), so Easy (0) is no longer treated as unset. Closing.

Already present on `spikersoft-angular` `master`. `getQuizDifficulty` uses nullish coalescing (`??`), so Easy (`0`) is no longer treated as unset. Closing.
Sign in to join this conversation.