Project Overview

Project File Structure:

russian-millionaire/
app.py (Main application file)
questions.json (All quiz questions)
templates/
index.html (Home page)
game.html (Game screen)
static/
style.css (All styling)
script.js (Game interaction)

Pro Tip: All project files are available at https://gitea.techshare.cc/technolyceum/ai6-m2.git

Installation Instructions
STEP 1

Clone the Repository

Open your terminal and run the following command to get the project files:

1 git clone https://gitea.techshare.cc/technolyceum/ai6-m2.git
STEP 2

Navigate to Project Directory

Move into the project directory using:

1 cd ai6-m2
STEP 3

Install Requirements

Install the necessary Python packages:

1 pip install -r requirements.txt
Database Setup - Danil
STEP 1

Open Database File

Navigate to the database file at:

1 /Users/home/YandexDisk/TECHNOLYCEUM/ict_repos/ai6-m2/starter_templates/docs/roles/database-designer-danil.md
STEP 2

Set Up MongoDB Connection (Lines 1-5)

Add the MongoDB connection information:

1 // 1. Import MongoDB driver (line 1)
2 from pymongo import MongoClient
3
4 // 2. Connect to MongoDB using the connection URI (line 3-5)
5 client = MongoClient('mongodb://localhost:27017/')
6
7 // 3. Select the appropriate database (line 7)
8 db = client['student_db']
9
10 // 4. Select the questions collection (line 9)
11 questions_collection = db['questions']
12
13 // 5. Add error handling for database connection (line 11)
14 try:
15 client.admin.command('ping')
16 print("Successfully connected to MongoDB!")
17 except Exception as e:
18 print(f"MongoDB connection error: {e}")
STEP 3

Insert Questions into Database

Add your quiz questions to the database:

1 // Sample question format
2 question = {
3 // 1. Question text (line 1)
4 "question": "What is the capital of Russia?",
5 // 2. Answer options (line 2-5)
6 "options": ["Moscow", "St. Petersburg", "Novosibirsk", "Kazan"],
7 // 3. Correct answer index (line 6)
8 "correct_answer": 0
9 }
10
11 // Insert question into collection (line 8)
12 questions_collection.insert_one(question)
Backend Setup - Dima
STEP 1

Open Backend File

Navigate to the backend developer documentation:

1 /Users/home/YandexDisk/TECHNOLYCEUM/ict_repos/ai6-m2/starter_templates/docs/roles/backend-developer-dima.md
STEP 2

Set Up Flask Application (Lines 1-6)

Add the Flask setup code:

1 // 1. Import Flask and PyMongo (line 1-2)
2 from flask import Flask, session, redirect, url_for, request, jsonify
3 from flask_pymongo import PyMongo
4
5 // 2. Connect to MongoDB database (line 4-6)
6 app = Flask(__name__)
7 app.config['MONGO_URI'] = 'mongodb://localhost:27017/student_db'
8 mongo = PyMongo(app)
STEP 3

Define API Endpoints (Lines 8-14)

Add the API endpoints for getting questions and submitting answers:

1 // 3. Define API endpoint for getting questions (line 8-10)
2 @app.route('/get_question')
3 def get_question():
4 // 1. Get current question number from session
5 question_num = session.get('current_question', 0)
6
7 // 2. Get question from database
8 question = mongo.db.questions.find_one({"question_number": question_num})
9
10 // 3. Format response
11 if question:
12 return jsonify({
13 "question": question['question'],
14 "options": question['options'],
15 "question_number": question_num,
16 "current_prize": calculate_prize(question_num)
17 })
18 else:
19 return jsonify({"game_over": True, "final_score": calculate_final_score()})
20
21 // 4. Define API endpoint for submitting answers (line 12-14)
22 @app.route('/answer', methods=['POST'])
23 def answer_question():
24 // 1. Get user's answer
25 user_answer = request.json.get('answer')
26
27 // 2. Get current question
28 question_num = session.get('current_question', 0)
29 current_question = mongo.db.questions.find_one({"question_number": question_num})
30
31 // 3. Check if answer is correct
32 is_correct = current_question['options'][current_question['correct_answer']] == user_answer
33
34 // 4. Update game state
35 if is_correct:
36 session['current_question'] = question_num + 1
37 return jsonify({
38 "correct": True,
39 "correct_answer": current_question['correct_answer'],
40 "game_over": question_num + 1 >= TOTAL_QUESTIONS
41 })
42 else:
43 return jsonify({
44 "correct": False,
45 "correct_answer": current_question['correct_answer'],
46 "game_over": True
47 })
Frontend Setup - Inna
STEP 1

Open Frontend File

Navigate to the frontend developer documentation:

1 /Users/home/YandexDisk/TECHNOLYCEUM/ict_repos/ai6-m2/starter_templates/docs/roles/frontend-developer-inna.md
STEP 2

Create HTML Structure (Lines 1-5)

Add the basic HTML structure with game container:

1 // 1. Create HTML structure with game container (line 1-5)
2
3
4
5
6 Russian Quiz
7
8
9
10
11

Russian Quiz

12
Prize: 0
13
14
15
Question 1/5
16
Loading...
17
18
19
20
21
STEP 3

Add Game Controls (Lines 17-20)

Add the game control elements:

1 // 4. Implement game controls and lifelines (line 17-20)
2
3
4
5
6 // 5. Add game over screen UI (line 22-25)
7
8

Game Over!

9

You won: 0

10
11
Final Steps
STEP 1

Start MongoDB

Make sure MongoDB is running:

1 // Start MongoDB service
2 sudo service mongod start
STEP 2

Run the Application

Start the Flask application:

1 // Run the app
2 python app.py
STEP 3

Access the Game

Open your browser and go to:

1 http://localhost:5000/start