Skip to content

feat(quiz): Add Quiz Generation Engine & Backend Architecture

AGHARAHIMOV AGHASALIM requested to merge feature/quiz-engine into main

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:

  1. 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).
  2. 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.
  3. Database Update:
    • Updated MovieEntity to store the overview field (required for Plot questions), and backdrop image field.

How has this been tested?

  • Unit Tests: QuizGeneratorTest verifies 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.

Merge request reports