Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added Domains/FullStack/MiniProjects/.DS_Store
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Domains/FullStack/MiniProjects/QuizMaster/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn app:app
23 changes: 23 additions & 0 deletions Domains/FullStack/MiniProjects/QuizMaster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Quiz Master application
**Contributor:** ekxnsh22005


The following project is a quizmaster app that has an admin dashboard and user dashboard.

The admin dashboard is hardcoded with the username and password as "admin"

The admin can perform the following actions:
1. Add Subject
2. Add Chapter under Subject
3. Add Quiz with timer and MCQs and caqn set the date
4. Add Questions for the quiz
5. Search for users and see their history
6. See some graphical statistics about the users

The user can perform the following actions:
1. Attempt quiz
2. View quiz history
3. Analyze the right and wrong options
4. See some graphical statistics

The following website is built using HTML, CSS (Bootstrap), Flask and SQLite.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions Domains/FullStack/MiniProjects/QuizMaster/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from flask import Flask, render_template
app = Flask(__name__)

import controller.config
import models
import controller.api
import controller.routes as routes


print(app.url_map)


if __name__ == '__main__':
app.run(debug=True)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
61 changes: 61 additions & 0 deletions Domains/FullStack/MiniProjects/QuizMaster/controller/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from flask_restful import Api, Resource
from app import app
from models import db, User, Subject, Chapter
from flask import request

api = Api(app)

class SubjectResource(Resource):
def get(self):
subjects = Subject.query.all()
return {'subjects':
[{
'id': subject.id,
'name': subject.subject_name,
'description': subject.subject_description
} for subject in subjects]}

def post(self):
data = request.get_json()
subject_name = data.get('name')
subject_description = data.get('description')

existing_subject = Subject.query.filter_by(subject_name=subject_name).first()
if existing_subject:
return {'message': 'Subject already exists.'}, 400

new_subject = Subject(subject_name=subject_name, subject_description=subject_description)
db.session.add(new_subject)
db.session.commit()

return {'message': 'Subject created successfully!', 'id': new_subject.id}, 201


class ChapterResource(Resource):
def get(self):
chapters = Chapter.query.all()
return {'chapters':
[{
'id': chapter.id,
'name': chapter.chapter_name,
'subject_id': chapter.subject_id
} for chapter in chapters]}

def post(self):
data = request.get_json()
chapter_name = data.get('name')
subject_id = data.get('subject_id')

existing_chapter = Chapter.query.filter_by(chapter_name=chapter_name, subject_id=subject_id).first()
if existing_chapter:
return {'message': 'Chapter already exists under this subject.'}, 400

new_chapter = Chapter(chapter_name=chapter_name, subject_id=subject_id)
db.session.add(new_chapter)
db.session.commit()

return {'message': 'Chapter created successfully!', 'id': new_chapter.id}, 201


api.add_resource(SubjectResource, '/api/subject')
api.add_resource(ChapterResource, '/api/chapter')
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from dotenv import load_dotenv
import os
from app import app
load_dotenv()
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('SQLALCHEMY_DATABASE_URI')
app.config['SQLALCHEMY_DATABASE_MODIFICATIONS'] = os.getenv('SQLALCHEMY_DATABASE_MODIFICATIONS')
Loading
Loading