One Chance is a robust, real-time quiz platform designed for educational institutions, competitions, and interactive learning environments. Built with Next.js, Prisma, and MySQL, it offers seamless experiences for both hosts and participants, with a focus on reliability, security, and analytics.
- Intuitive Quiz Creation: Easily create, edit, and manage quizzes with multiple question types (MCQ, subjective, etc.).
- Real-Time Session Control: Start, pause, and end quizzes live; monitor participant activity and progress instantly.
- Live Participant Tracking: See who joins, monitor responses, and detect suspicious activity (proctoring-ready).
- Comprehensive Analytics: Get instant feedback, performance breakdowns, and exportable reports for each session.
- Team & Individual Modes: Host quizzes for individuals or teams, with automatic scoring and ranking.
- Session Management: Schedule quizzes, manage multiple concurrent sessions, and control access with unique codes.
- Secure Hosting: Only authorized users can create or host quizzes, with role-based access control.
- Easy Join with Codes: Enter a session code to join quizzes from any deviceβno installation required.
- Live Scoring & Feedback: See scores and feedback in real time after each question or at the end.
- Performance Dashboard: Track your progress, review answers, and analyze strengths/weaknesses.
- Team Collaboration: Join as a team, collaborate on answers, and compete in group quizzes.
- Accessible UI: Mobile-friendly, responsive design for seamless participation.
- Proctoring-Ready: Built-in hooks for proctoring and suspicious activity detection (expandable for AI proctoring).
- Scalable Architecture: Handles hundreds of concurrent users with efficient session and state management.
- Customizable & Extensible: Modular codebase for easy feature addition and integration with other systems.
- Comprehensive Error Handling: User-friendly error messages and troubleshooting guides.
- One-Command Setup: Automated scripts for fast local or cloud deployment.
- Security First: Secure authentication, environment validation, and safe data handling.
- Node.js 18+
- MySQL 8.0+
- npm or pnpm
cd quiz-app
chmod +x setup.sh
./setup.shcd quiz-app
setup.batcd quiz-app
npm run dev:setup-
Install dependencies
cd quiz-app npm install -
Set up environment variables Create a
.envfile in thequiz-appdirectory:DATABASE_URL="mysql://root:YOUR_MYSQL_PASSWORD@localhost:3306/NMIMS_QUIZ" NEXTAUTH_SECRET="your-secret-key-here" NEXTAUTH_URL="http://localhost:3000"
Important: Replace
YOUR_MYSQL_PASSWORDwith your actual MySQL root password. -
Set up the database
# Create database mysql -u root -p -e "CREATE DATABASE IF NOT EXISTS NMIMS_QUIZ;" # Generate Prisma client npm run prisma:generate # Run migrations npm run prisma:migrate # Seed the database npm run prisma:seed
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
After seeding, you can log in with these credentials:
- Username: Angshuman, Password: password123
- Username: Anshuman, Password: password123
- Username: Rayyan, Password: password123
- Username: Sarah, Password: password123
- Username: Mike, Password: password123
One_Chance_SE_Project/
βββ quiz-app/ # Next.js application
β βββ app/ # App router pages
β βββ components/ # UI components
β βββ lib/ # Database utilities
β βββ hooks/ # Custom React hooks
β βββ setup.sh # Unix/Linux setup script
β βββ setup.bat # Windows setup script
β βββ public/ # Static assets
βββ prisma/ # Database schema and migrations
β βββ schema.prisma # Database schema
β βββ seed.ts # Database seeding script
β βββ migrations/ # Database migrations
βββ generated/ # Generated Prisma client
- Create, edit, and delete quizzes
- Add questions of various types (MCQ, subjective, etc.)
- Set quiz schedules and time limits
- Monitor live sessions and participant activity
- View analytics: scores, participation rates, question-wise stats
- Export results as CSV/Excel
- Join quizzes via unique code or invite link
- Answer questions in real time
- See live leaderboard and instant feedback
- Review answers and analytics post-quiz
- Secure authentication (NextAuth.js)
- Role-based access (host/participant)
- Environment validation and error handling
- Data privacy: no sensitive data stored in client
- Next.js: Fast, modern React framework for SSR and API routes
- Prisma: Type-safe ORM for MySQL, easy migrations and seeding
- Tailwind CSS: Modern, responsive UI
- Proctoring Hooks: Ready for integration with webcam/microphone monitoring
- Secure by Design: All sensitive operations require authentication. Passwords are hashed. Environment variables are validated at startup.
- Scalable: Designed to support large quizzes with many participants. Efficient state management and database queries.
- Extensible: Modular codebaseβadd new question types, analytics, or integrations easily.
- Classroom Quizzes: Teachers can host live quizzes, track student performance, and export results.
- Online Competitions: Organizers can run large-scale contests with real-time leaderboards and anti-cheating features.
- Corporate Training: HR can assess employees with secure, analytics-driven quizzes.
-
Database Connection Error
- Make sure MySQL is running
- Verify your password in the
.envfile - Check if the database exists:
mysql -u root -p -e "SHOW DATABASES;"
-
bcrypt Module Error
- The project now uses
bcryptjsinstead ofbcryptto avoid native binary issues - This is automatically handled in the setup scripts
- The project now uses
-
Prisma Schema Not Found
- The schema is located in
../prisma/schema.prisma - This is automatically configured in the package.json scripts
- The schema is located in
-
Port Already in Use
- Kill existing processes:
pkill -f "next dev" - Or use a different port:
npm run dev -- -p 3001
- Kill existing processes:
If you need to start fresh:
cd quiz-app
rm -rf node_modules .next
rm .env
npm install
./setup.sh # or setup.bat on Windowsnpm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run prisma:generate- Generate Prisma clientnpm run prisma:migrate- Run database migrationsnpm run prisma:seed- Seed database with sample datanpm run setup- Full setup (install + database)npm run dev:setup- Setup + start dev server
Required environment variables in .env:
DATABASE_URL- MySQL connection stringNEXTAUTH_SECRET- Secret for NextAuth.jsNEXTAUTH_URL- Your application URL
This project has been updated to handle common setup issues:
- Fixed bcrypt native binary issues - Now uses
bcryptjs - Fixed Prisma schema location - Properly configured paths
- Added comprehensive setup scripts - One-command setup
- Improved error handling - Better error messages and guidance
- Added environment validation - Checks for prerequisites
We welcome contributions! To get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Make your changes (add tests if possible)
- Test thoroughly
- Submit a pull request with a clear description
For major changes, please open an issue first to discuss what youβd like to change.
Q: Can I use a different database?
A: The app is optimized for MySQL but can be adapted for PostgreSQL with minor changes in prisma/schema.prisma.
Q: How do I add new question types? A: Extend the question model in Prisma and update the quiz creation UI.
Q: Is it mobile-friendly? A: Yes! The UI is fully responsive and works on all modern devices.
Q: Who do I contact for help? A: Open an issue on GitHub or contact the maintainers listed in the repository.
This project is licensed under the MIT License.