Skip to content

quiz game currencies#4

Merged
yurtemre7 merged 5 commits into
mainfrom
yurtemre7/quiz-game-currencies
Jun 14, 2026
Merged

quiz game currencies#4
yurtemre7 merged 5 commits into
mainfrom
yurtemre7/quiz-game-currencies

Conversation

@yurtemre7

Copy link
Copy Markdown
Owner

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb314cd2-86cf-439c-bafc-91a587057478

📥 Commits

Reviewing files that changed from the base of the PR and between 1212471 and 788a382.

📒 Files selected for processing (1)
  • lib/screens/home/currency_quiz.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/screens/home/currency_quiz.dart

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added a “Currency Quiz” experience to Home, with a new quiz tab, scenario-based rounds, multiple-choice and free-input modes, streak tracking, and an end-of-quiz summary.
    • Added quiz-related UI translations and action labels across supported languages.
  • Enhancements
    • Expanded adaptive sheet options to allow customizing whether it can be dismissed by tapping the barrier and whether it can be dragged.
  • Bug Fixes
    • Fixed the compact-layout action button shown in the Home header.
  • Chores
    • Updated the recommended formatting commands in documentation.

Walkthrough

Adds a complete CurrencyQuizScreen feature with multiple-choice and free-input modes, deviation-based scoring, result sheets, and a summary screen; wires it into both desktop and mobile Home layouts; extends AppLocalizations and nine locale ARB/Dart files with quiz strings. Also updates HomeHeader's navigation index condition from 2 to 3, adds barrierDismissible/draggable parameters to adaptiveSheetRoute, and trims the AGENTS.md commands list.

Changes

Currency Quiz Feature

Layer / File(s) Summary
Quiz domain models and reactive state
lib/screens/home/currency_quiz.dart
Defines QuizMode, QuizScenario enums, _QuizPhase, QuizRound/QuizAnswer data classes; initializes GetX observables for score, streak, rounds, answers; hooks initState/dispose and implements startGame/_nextRound.
Round generation, option building, and scoring logic
lib/screens/home/currency_quiz.dart
Implements _buildRound with Paren currency conversion, _buildOptions with duplicate-avoidance and zero-decimal rounding, submission handlers for multiple-choice and free-input, _recordAnswer with deviation/streak/point calculation, and _showResultSheet with modal navigation.
Quiz UI components and layout
lib/screens/home/currency_quiz.dart
Builds formatters, settings dialog, primary build with AnimatedSwitcher, game layout with swipe gesture, top bar with metrics and mode toggle, question card, multiple-choice grid with animated card states, free-input field with numeric filtering, result sheet with closeness bar, summary screen with per-round list and metrics, helper tiles and scenario labels.
Integration into Home layout and navigation
lib/screens/home.dart
Imports CurrencyQuizScreen; inserts it in wide-layout Row between Conversion and Customization; adds it to narrow-layout PageView children; adds quiz_outlined bottom navigation tab.
AppLocalizations abstract API contract
lib/l10n/app_localizations.dart
Extends AppLocalizations with new getters (apply, submit, quiz, quiz UI labels) and parameterized methods (quizRoundsPerGame, quizEstimateInCurrency, quizCorrectAmount, quizYourGuess, quizYouWereOff, quizSummaryCorrect); includes all scenario label getters.
Localization strings in ARB and Dart files
lib/l10n/app_*.arb, lib/l10n/app_localizations_*.dart
Adds quiz string keys/values in nine ARB files (en, de, fr, hi, id, ja, tr, zh); regenerates corresponding AppLocalizations_* Dart override classes with matching getters and parameterized method implementations.

Minor Component and Documentation Updates

Layer / File(s) Summary
HomeHeader, adaptiveSheetRoute, and AGENTS updates
lib/components/home_header.dart, lib/components/adaptive_overlay.dart, AGENTS.md
Changes HomeHeader non-desktop right-button condition from index != 2 to index != 3; adds barrierDismissible and draggable optional parameters to adaptiveSheetRoute forwarded to StupidSimpleSheetRoute; removes integration_test entries from AGENTS useful commands list.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant Game as CurrencyQuizScreen
  participant Paren as Paren (converter)
  participant Sheet as adaptiveSheetRoute
  participant Summary as QuizSummaryScreen

  User->>Game: start game / tap quiz
  Game->>Paren: convert EUR via sourceCurrency to homeCurrency
  Paren-->>Game: correctAmount
  Game->>Game: _buildOptions randomized
  Game-->>User: show question card + answer UI
  User->>Game: submitMultipleChoice / submitFreeInput
  Game->>Game: _recordAnswer compute deviation, streak, points
  Game->>Sheet: _showResultSheet with ResultPanel
  Sheet-->>User: display closeness bar, correct amount, guess
  User->>Sheet: dismiss / swipe
  Sheet-->>Game: continueGame
  alt more rounds remain
    Game->>Game: _nextRound
    Game-->>User: next question
  else all rounds completed
    Game->>Summary: switch to summary phase
    Summary-->>User: show metrics, per-round results, play again
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 A bunny hopped in with a brand-new quiz,
"Guess how many yen for a coffee — what is it?"
Multiple choice or free-input you pick,
Streaks and calibration, scored real quick.
Nine languages ready, the locales are set,
The currency rabbit isn't done yet! 🪙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author. Add a description explaining the purpose of the quiz game feature, implementation details, and any relevant context for reviewers.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'quiz game currencies' clearly describes the main feature being added—a currency quiz game—matching the changeset's primary purpose.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/screens/home/currency_quiz.dart (1)

159-166: 💤 Low value

Consider narrowing the random factor range for quiz consistency.

The option-generation logic uses a wide random factor range (30%–170% via 0.3 + random.nextDouble() * 1.4 on line 159, plus conditional swaps). This can produce very easy or very hard rounds unpredictably. Tightening the range or using fixed difficulty tiers would improve quiz balance.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/screens/home/currency_quiz.dart` around lines 159 - 166, The random
factor range in the factors array initialization is too wide (from 0.3 to 1.7 or
30%-170%), which combined with the conditional factor modifications, produces
unpredictable quiz difficulty. Narrow the range for the random multiplier in the
expression `0.3 + random.nextDouble() * 1.4` by reducing the coefficient
(currently 1.4) to a smaller value, or replace the random logic with fixed
difficulty tiers to ensure consistent quiz balance across rounds. This affects
the factors array setup and the random.nextDouble() multiplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/l10n/app_en.arb`:
- Around line 152-183: The quiz-related localization strings have been added to
lib/l10n/app_en.arb but the generated Dart localization file
lib/l10n/app_localizations_en.dart is out of sync, causing a 25-entry mismatch
between the ARB source and the generated output. Run the command flutter
gen-l10n from the project root to regenerate the localization files and ensure
lib/l10n/app_localizations_en.dart reflects all the new quiz keys and methods.

In `@lib/screens/home/currency_quiz.dart`:
- Around line 179-187: The duplicate-removal loop in the currency_quiz.dart file
(the while loop checking options.toSet().length < options.length) can become
infinite when the rounding operation in _roundReadableAmount repeatedly produces
the same values, especially for zero-decimal currencies. Add an iteration limit
counter to the while loop to break after a maximum number of attempts (e.g., 10
iterations), and implement a fallback strategy when the limit is reached—such as
manually generating unique values using fixed percentage offsets (like 0.95x,
1.05x, 1.15x of the correctAmount) instead of relying solely on the random
range, or using a while-true loop with a max attempts check that throws an error
or uses a predefined set of alternatives if duplicates persist.

---

Nitpick comments:
In `@lib/screens/home/currency_quiz.dart`:
- Around line 159-166: The random factor range in the factors array
initialization is too wide (from 0.3 to 1.7 or 30%-170%), which combined with
the conditional factor modifications, produces unpredictable quiz difficulty.
Narrow the range for the random multiplier in the expression `0.3 +
random.nextDouble() * 1.4` by reducing the coefficient (currently 1.4) to a
smaller value, or replace the random logic with fixed difficulty tiers to ensure
consistent quiz balance across rounds. This affects the factors array setup and
the random.nextDouble() multiplication.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ab6c4108-e622-4275-96bc-fceaeab2111b

📥 Commits

Reviewing files that changed from the base of the PR and between 84af40d and b33f0ce.

📒 Files selected for processing (22)
  • AGENTS.md
  • lib/components/adaptive_overlay.dart
  • lib/components/home_header.dart
  • lib/l10n/app_de.arb
  • lib/l10n/app_en.arb
  • lib/l10n/app_fr.arb
  • lib/l10n/app_hi.arb
  • lib/l10n/app_id.arb
  • lib/l10n/app_ja.arb
  • lib/l10n/app_localizations.dart
  • lib/l10n/app_localizations_de.dart
  • lib/l10n/app_localizations_en.dart
  • lib/l10n/app_localizations_fr.dart
  • lib/l10n/app_localizations_hi.dart
  • lib/l10n/app_localizations_id.dart
  • lib/l10n/app_localizations_ja.dart
  • lib/l10n/app_localizations_tr.dart
  • lib/l10n/app_localizations_zh.dart
  • lib/l10n/app_tr.arb
  • lib/l10n/app_zh.arb
  • lib/screens/home.dart
  • lib/screens/home/currency_quiz.dart

Comment thread lib/l10n/app_en.arb
Comment thread lib/screens/home/currency_quiz.dart Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
lib/screens/home/currency_quiz.dart (2)

222-225: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Score multiple-choice answers against the same rounded amount you show to the player.

submitMultipleChoice treats _displayCorrectAmount as the exact answer, but _recordAnswer and the result UI still compare against round.correctAmount. That means picking the shown “correct” tile can still produce a non-zero miss and fewer than full base points when the raw conversion was rounded for display.

Also applies to: 247-279, 859-875

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/screens/home/currency_quiz.dart` around lines 222 - 225, The
submitMultipleChoice method passes the displayed rounded amount to _recordAnswer
via the exactChoice parameter, but _recordAnswer still compares the guess
against the unrounded round.correctAmount value instead of using the rounded
amount that was actually shown to the player. This causes answers that match the
displayed "correct" option to be marked incorrect if rounding created a
discrepancy. Update _recordAnswer to use the rounded displayed amount for
comparison instead of always comparing against round.correctAmount, and apply
this fix consistently across all instances where this comparison pattern appears
in the file including the affected locations at lines 247-279 and 859-875
referenced in the comment.

378-384: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Format each summary row with its own round currency.

QuizSummaryScreen formats every row with the last round’s homeCurrencyId, even though each QuizAnswer already carries answer.round.homeCurrency.id. This screen is mounted beside other live home panels on desktop, so changing currencies mid-quiz will mislabel earlier rounds in the summary.

💡 Minimal fix
-            homeCurrencyId: round.homeCurrency.id,
             formatAmount: _formatAmount,
             onRestart: startGame,
           ),
@@
-  final String homeCurrencyId;
   final String Function(double amount, String currencyId) formatAmount;
@@
-    required this.homeCurrencyId,
     required this.formatAmount,
     required this.onRestart,
   });
@@
               context.l10n.quizSummaryCorrect(
-                formatAmount(answer.round.correctAmount, homeCurrencyId),
+                formatAmount(
+                  answer.round.correctAmount,
+                  answer.round.homeCurrency.id,
+                ),
                 (answer.deviation * 100).round(),
               ),

Also applies to: 893-909, 983-986

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/screens/home/currency_quiz.dart` around lines 378 - 384, The
QuizSummaryScreen is being passed a single homeCurrencyId parameter set to the
final round's currency, which causes all summary rows to format with this
currency even though each QuizAnswer already contains its own
answer.round.homeCurrency.id. Modify QuizSummaryScreen to format each row using
its own answer's round currency instead of the shared homeCurrencyId parameter.
This fix should be applied at all locations where QuizSummaryScreen is
instantiated: the main location in the _QuizPhase.summary case (lines 378-384),
and at the other affected sites mentioned in lines 893-909 and 983-986, ensuring
each location removes or stops relying on the homeCurrencyId parameter in favor
of per-answer currency resolution.
♻️ Duplicate comments (1)
lib/screens/home/currency_quiz.dart (1)

179-188: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a deterministic fallback when the retry cap is hit.

The loop is bounded now, but it can still return duplicate numeric options. In multiple-choice mode that leaves identical answer tiles on screen, and because correctness is checked by value equality, duplicated values are effectively scored as the same answer.

♻️ Suggested direction
   var cycleCount = 0;
   while (options.toSet().length < options.length && cycleCount++ < 10) {
     var duplicateIndex = options.indexWhere(
       (option) => options.where((other) => other == option).length > 1,
     );
     options[duplicateIndex] = _roundReadableAmount(
       correctAmount * (0.55 + random.nextDouble() * 1.2),
       currencyId,
     );
   }
+  if (options.toSet().length < options.length) {
+    // Fall back to deterministic offsets aligned with the display rounding step
+    // so the final grid always contains four distinct values.
+  }
   return options;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/screens/home/currency_quiz.dart` around lines 179 - 188, The while loop
in the currency quiz has a retry limit that can cause it to exit before all
duplicate options are eliminated, leaving the options list with duplicate
numeric values. After the while loop completes (when cycleCount reaches 10 or
all options are unique), add a deterministic fallback mechanism to replace any
remaining duplicates. Check if options.toSet().length still differs from
options.length after the loop, and if so, iteratively replace each remaining
duplicate with a deterministically generated value (such as using a different
multiplier offset from correctAmount) that ensures all options are unique,
preventing identical answer tiles from appearing on screen.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@lib/screens/home/currency_quiz.dart`:
- Around line 222-225: The submitMultipleChoice method passes the displayed
rounded amount to _recordAnswer via the exactChoice parameter, but _recordAnswer
still compares the guess against the unrounded round.correctAmount value instead
of using the rounded amount that was actually shown to the player. This causes
answers that match the displayed "correct" option to be marked incorrect if
rounding created a discrepancy. Update _recordAnswer to use the rounded
displayed amount for comparison instead of always comparing against
round.correctAmount, and apply this fix consistently across all instances where
this comparison pattern appears in the file including the affected locations at
lines 247-279 and 859-875 referenced in the comment.
- Around line 378-384: The QuizSummaryScreen is being passed a single
homeCurrencyId parameter set to the final round's currency, which causes all
summary rows to format with this currency even though each QuizAnswer already
contains its own answer.round.homeCurrency.id. Modify QuizSummaryScreen to
format each row using its own answer's round currency instead of the shared
homeCurrencyId parameter. This fix should be applied at all locations where
QuizSummaryScreen is instantiated: the main location in the _QuizPhase.summary
case (lines 378-384), and at the other affected sites mentioned in lines 893-909
and 983-986, ensuring each location removes or stops relying on the
homeCurrencyId parameter in favor of per-answer currency resolution.

---

Duplicate comments:
In `@lib/screens/home/currency_quiz.dart`:
- Around line 179-188: The while loop in the currency quiz has a retry limit
that can cause it to exit before all duplicate options are eliminated, leaving
the options list with duplicate numeric values. After the while loop completes
(when cycleCount reaches 10 or all options are unique), add a deterministic
fallback mechanism to replace any remaining duplicates. Check if
options.toSet().length still differs from options.length after the loop, and if
so, iteratively replace each remaining duplicate with a deterministically
generated value (such as using a different multiplier offset from correctAmount)
that ensures all options are unique, preventing identical answer tiles from
appearing on screen.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0acf746f-d243-4ded-a73e-1b9736b75143

📥 Commits

Reviewing files that changed from the base of the PR and between b33f0ce and 1212471.

📒 Files selected for processing (1)
  • lib/screens/home/currency_quiz.dart

@yurtemre7 yurtemre7 merged commit 2311193 into main Jun 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant