feat(quiz): Add Quiz Generation Engine & Backend Architecture
What does this MR do?
This MR implements the mandatory "Quiz" feature's backend and business logic. It enables the app to generate a unique, playable quiz based on the user's local watchlist.
Key Components:
-
Quiz Generator Engine (
QuizGenerator):- A pure logic class that takes a list of movies and generates a 10-question quiz.
- Supports 3 dynamic question types:
- Release Year: "When was [Movie] released?" (Generates realistic fake years).
- Poster: "Which movie is this?" (Shows image, hides title).
- Plot: "Which movie has this plot?" (Obscures the movie title within the overview text).
-
Architecture:
-
QuizRepository: Fetches the user's watchlist from Room and passes it to the generator. -
QuizViewModel: Manages the game state (Loading,Playing,GameOver), tracks the user's score, and handles answer submission.
-
-
Database Update:
- Updated
MovieEntityto store theoverviewfield (required for Plot questions), and backdrop image field.
- Updated
How has this been tested?
-
Unit Tests:
QuizGeneratorTestverifies that:- Quizzes are only generated if the watchlist has at least 4 movies.
- Questions have exactly 4 unique options.
- The correct answer is always present in the options.
- Logic for specific types (e.g., hiding the title in plot questions) works correctly.
Why was this change needed?
This functionality fulfills the project requirement: "Create and play quiz based on watchlists." It provides the "Brain" of the quiz feature, allowing the UI dev to simply observe the QuizViewModel state to build the screens.