How to Build a Web-Based Quiz App with Angular, Firebase Deployment, and JSON-Based Questions
Introduction
A quiz app is a great way to test knowledge in various domains. This tutorial will guide you through building a quiz app with Angular, where questions are stored in JSON files inside the assets folder, and the app has the ability to shuffle questions to prevent repetitive patterns. Finally, we'll deploy the app on Firebase Hosting.
🚀 GitHub Source Code: Smart-Quiz-App
Features of the Web App
- Questions stored as JSON files in assets folder
- Shuffle questions randomly on each quiz session
- Multiple-choice questions with instant feedback
- Score calculation at the end of the quiz
- Responsive UI using Angular Material
- Deployed on Firebase Hosting
Tech Stack
- Frontend: Angular 17, Angular Material
- Storage: JSON files inside the
assetsfolder - Deployment: Firebase Hosting
Step 1: Setting Up the Angular Project
1. Install Angular CLI
Ensure you have Node.js installed, then install Angular CLI globally:
2. Create a New Angular Project
Select SCSS for styling.
3. Install Required Dependencies
Step 2: Creating the Quiz JSON File
Inside the src/assets folder, create a file named questions.json and add quiz questions:
Step 3: Fetching and Shuffling Quiz Questions
1. Create a Quiz Service (quiz.service.ts)
Step 4: Creating the Quiz Component
1. Generate Quiz Component
2. Implement the Quiz Component (quiz.component.ts)
Step 5: Adding Quiz UI in quiz.component.html
Step 6: Styling the Quiz (quiz.component.scss)
Step 7: Configuring App Module
In app.module.ts, import necessary modules:
Step 8: Deploying the App on Firebase
1. Initialize Firebase Hosting
Follow the prompts and select:
- "dist/quiz-app" as the public directory
- Configure as a single-page app (Yes)
2. Build and Deploy
🎉 Your quiz app is now live on Firebase Hosting!
Conclusion
You've successfully built and deployed a web-based quiz app using Angular, with questions stored as JSON files and shuffled each time.
🚀 GitHub Repository: Complete Source Code Here




0 comments:
Post a Comment