It's a simple Server + Android App system which can be used to conduct a quiz game for a relatively moderate amount of users. This enables a group of participants to sit together and play a quiz game on their phones and find out who scored the most.
This repository contains the code for the server written in Python3 using the Flask framework. It just provides a REST API to be used by the app and some web pages that help the host conduct the quiz game.
This project is named after the show "Kaun Banega Crorepati" or "KBC". I built this because my housing society wanted to conduct a small quiz event for the children on the eve of Children's Day 2018.
- Python3
- Flask
run pip3 install -r requirements.txt
NOTE: use
piporpip3as specified in your operating system
- Add your local ip on the first lines of
static/js/registered.jsandstatic/js/submissions.js - The run
python3 app.py
NOTE: Don't forget the first step, else your js won't have a valid ip to make requests to.
After this you will be able to view it on http://<your ip>:8000/ in your browser.
The .apk file is available here
The code for the app is availabe on : https://github.com/junaidrahim/KBC-Quiz-App
NOTE: The js won't execute if you do
localhostdue to same origin policy, instead put the ip of your pc/server.
Well, the basics are pretty simple. This repository has the code for the server. You start the server and then use an android app that makes appropriate requests to the server and you get to conduct your game.
Check the players who registered on the page http://localhost:8000/resgistered
And then you can check/display the submissions on the page http://localhost:8000/submissions. The javascript
on this page will fetch the submission data, add up the scores and sort the players, and display them in ranks
accordingly.
├── app.py
├── LICENSE
├── README.md
├── requirements.txt
├── screenshots
│ ├── header.png
│ ├── index.png
│ ├── registered.png
│ └── submissions.png
├── static
│ ├── css
│ │ ├── index.css
│ │ ├── registered.css
│ │ └── submissions.css
│ ├── js
│ │ ├── jquery.min.js
│ │ ├── registered.js
│ │ └── submissions.js
│ └── KBC-quizapp.apk
└── templates
├── index.html
├── questions.html
├── registered.html
└── submissions.html
5 directories, 19 fileshttp://localhost:8000/. This is the main Homepage.http://localhost:8000/resgistered. This page shows the Registered users (updates in real time).http://localhost:8000/submissions. This page shows the Submissions. (updates in real time)http://localhost:8000/questions. This page can be used to display the questions to the audience after the quiz is over
Note: Replace
localhostwith the ip of your computer on the network
-
URL :
/api/post/register- Method :
POST - Description : Will register the user and send a unique id.
- Required Params :
name=[string] - Sample Request :
{ "name" : "John Doe" } - Success Response :
{ "success":True, "id":"<some unique id>", "error": "none" } - Error Response :
{ "success":False, "error": <details about the error> }
- Method :
-
URL :
/api/post/delete_registration- Method :
POST - Description: Will delete the user whose corresponding details were sent.
- Required Params :
name=[string], id=[string] - Sample Request :
{ "name" : "John Doe", "id":"89jes1s" } - Success Response :
{ "success":True, "error":"none" } - Error Response :
{ "success":False, "error":"request to delete a non-existing user" }
- Method :
-
URL :
/api/post/submission- Method :
POST - Description : Will append the score sent for the corresponding user. Total score will be the sum of the array
- Required Params :
name=[string], id=[string], score=[int] - Sample Request :
{ "name" : "John Doe", "id":"89jes1s", "score": 4 } - Success Response :
{ "success":True, "error":"none" } - Error Response :
{"success":False, "error": "User is not registered"}
- Method :
-
URL :
/api/get/registered_users- Method :
GET - Description : Will return details of all the registered users in the following json format
- Required Params :
none - Success Response :
{ "t1x7l": "Elliot Alderson", "zwokr": "John Doe" }
- Method :
-
URL :
/api/get/submissions- Method :
GET - Description : Will return the submissions of all the users in the following json format.
- Required Params :
none - Success Response :
{ "t1x7l": [ "Elliot Alderson", [3, 4, 0, 0, 0, 5] ], "zwokr": [ "John Doe", [4, 0, 0, 0, 2, 3] ] }
- Method :
This is a very dead simple project to conduct the game. My userbase was like 20 so I kept it simple 😅. This needs a lot of improvement and security features, it will work fine if you're using this in a closed network for limited amount of people.
We will have to add a lot of features to make this system a solid one. Some of them are below, I am always open to new suggestions and PRs. 😁✌️
- Database Support, probably mongodb
- Adding more security to the API
- More Sophisticated Authentication
- A cap on max amount of score the API accepts.
Copyright(c) Junaid H Rahim. All Rights Reserved
Licensed under the MIT License.
Header Icon made by Prosymbols from www.flaticon.com



