Skip to content

Latest commit

 

History

History
697 lines (393 loc) · 948 KB

README.md

File metadata and controls

697 lines (393 loc) · 948 KB

Quiz Application using MySQL and Python, Tkinter

Overview

As technology is getting more accessible day by day. Digitization is happening in every sector. With the digitization there arises the demand for new software applications that cater to the needs of the user. One such field is education which has witnessed new approaches to teach students using the Internet and Technology. Online learning is one such approach. Online learning also requires new methods to evaluate student performance. Quiz format tests are easy to evaluate and are perfect to test student’s knowledge. But it requires new software solutions to make it possible. One such solution is Quiz application using Python and MySQL. The application is simple yet powerful. It harnesses the power of data base management system and simplicity of Python language. It provides a graphical user interface to its user and provides data exchange capabilities. The quiz is stored in a widespread data format Json and Responses of quiz can be exported out of application in csv file to be analyzed using other applications too. The capabilities of this application can be expanded very easily. It makes it very maintainable. The application can be customized to the needs of organization easily. As the application uses a MySQL database it also has the potential of becoming a web application as well.

Introduction

Quiz application is a simple quiz application which takes quiz in digital format. The user has to create an account. Then the user can attempt quiz in the application. The user can also view their result in the quiz application through user dashboard. The result can also be saved into a pdf file. The admin can export all the responses of the quiz into a csv file which enables admin to perform analysis on the data and keep track of the user performances. The user can also reset their password in the user dashboard. It comes with a quiz editor also. Which enables the admin to create, edit and save quiz within the application. The quiz editor offers various key features like setting response limit, scheduling quiz for a particular date and time, setting time limit for the quiz.

The quiz can be divided into multiple sections and multiple questions can be added into any section. The questions are in multiple choice format. The admin can also add points to questions. The admin can set multiple options as answer key. The admin can save quiz in json file which enables the reusability of the data across other applications as well.

The application stores its data in a SQL database which can be hosted on a server and then the application can be turned into an online quiz application without much efforts.

Application Details

Development Environment

Language: Python 3.4

Operating System: Windows 10.

Processor: Intel Pentium.

Architecture: x86

Specifications

Operating System: Windows, Mac and Linux

Processor: Intel Pentium onwards.

Architecture: x86 and x64

RAM: 60 Mb

Project structure

Figure 3 project file structure

  1. app.py
  2. user.py
  3. quiz.py
  4. quizeditor.py

app.py

app.py contains the Application class. This class provides the user login and signup window. User can create a user or admin account for him/her from signup window. The signup for admin type account requires permission from the admin.

The user/admin can login or exit. If the user/admin logs in successfully he/she is provided with an admin or user menu depending upon the type of account he/she used to login.

The admin menu has three options

  • Quiz
  • Quiz editor
  • User dashboard

The user menu has three options

  • Quiz
  • User dashboard

quiz.py

quiz.py contains Quiz class which provides the user/admin to attempt the quizzes. It fetches all the available quizzes from the database and provides admin/user a menu of available quiz options. If there is no Quiz available at that moment it displays a message about it.

User/admin can select from the available options and attempt the quiz. It also checks following things before allowing the user to attempt the quiz.

  • Response limit
  • Date and time

If the above parameters are not satisfied the user is not allowed to attempt the quiz and the message about it is displayed on the right side of the option.

If the above parameters are satisfied it allows the user to attempt the quiz. It displays instructions about the quiz which are auto generated. The user can either accept or decline. If the user accepts response is counted and if the user declines response is not counted. If the quiz has time limit set it starts a timer and automatically submits the response when the time limit is exceeded.

User is provided with multiple choice questions to attempt.

User can either exit or submit from the quiz. In the both scenario response is counted.

quizeditor.py

quizeditor.py contains QuizEditor class which is used to create and edit quizzes. The admin can only edit and save quizzes. The quizzes are added to MySQL database when saved. The QuizEditor has a menu at the top it has two options

  • File
  • About

File option has

  • New
  • Open
  • Save
  • Close
  • Exit

New option creates a new quiz.

Open option fetches an already saved quiz from MySQL Database after asking to save any opened or new quiz.

Save option saves the quiz opened or new quiz.

Close option closes any quiz if it’s opened or new quiz after asking to save it.

Exit option exits from the Quiz Editor.

About option opens a window showing information about the Qui Editor

user.py

It contains the User class which stores user/admin details during run time and provide the user/admin dashboard. The user dashboard has two view admin mode and user mode.

User mode view has options to reset password and view previous quiz responses. If there are no responses available it shows a message about it. The user can view their individual response and export them into a file.

Admin mode view has all the capabilities of User mode and admin has the ability to export all the individual quiz responses into a file. Which he/she can then use to analyze the data.

Dependencies

  • sqlite3

sqlite3 is a standard python module used for accessing, storing and modifying data in a database from a python application.

  • tkinter

tkinter is a standard python module used for creating graphical user interface applications in python. It is available with a standard python installation and is cross-platform i.e compatible with Windows, Mac, and Linux operating systems.

  • json

json is a standard python module used to parse and create JSON files.

  • matplotlib

matplotlib is a python module used to plot graphs and charts.

  • os

Os is a standard python module used to access operating system functions.

  • datetime

datetime is a standard python module used to manipulate access date and date related data

  • time

    time is a standard python module used to access time and manipulate time related data.

  • fpdf

fpdf is a python module used to create, edit and save pdf files

Database structure

The Quiz.db database consists of three tables

  1. quizzes

  2. responses

  3. users

    quizzes table

Table 1 quiz table

id name path
1 Samplequiz1 C:/Samplequiz1.json
2 Samplequiz2 C:/Samplequiz2.json
3 Samplequiz3 C:/Samplequiz3.json
4 Samplequiz34 C:/Samplequiz4.json

responses table

Table 2 response table

user quiz response response_count
1 23 response/name1_quiz.json 1
2 12 Response/name2_quiz.json 2

users table

privilege 1 for admin and privilege 0 for user

Table 3 user table

id username password privilege
1 admin password 1
2 user1 password1 0
3 user2 password2 0

Quiz File

File format JSON file.

Sample File structure.

{

"id": 61,

"test": "sample quiz name\n",

"response_limit": 1,

"date": {

"day": 1,

"month": 8,

"year": 2020

},

"time": {

"hour": 10,

"minute": 30,

"second": 0

},

"time_limit": {

"hour": "1",

"minute": "0",

"second": "0"

},

"sections": [

{

"id": 0,

"section": "sample section name",

"questions": [

{

"id": 0,

"question": "sample question",

"options": [

{

"option": "sample option",

"id": 0,

"key": true

}

],

"type": "single",

"point": 1

}

]

}

],

"instructions": [

{

"instruction": "You have 1 hours"

},

{

"instruction": "There are 1 sections in total"

},

{

"instruction": "In the section sample section name there are 1 questions in total"

}

]

}

Quiz response file

File format JSON file.

Sample File structure.

{

"test": 61,

"response": [

[ 0, 0, [0],1,[0], 1 ]

],

"max_points": 1,

"score": 1,

"correct": 1,

"incorrect": 0,

"no_response": 0

}

Flow chart

Figure 4 Flowchart

Usage

  1. How to make a user account
    1. Start the application
    2. A login window will appear on the screen like below. ![ref1]

Figure 5 quiz app login

  1. Click on the signup button
  2. Signup window like below will appear.

Figure 6 user signup

  1. Enter username and password of your choice both should be at least 8 digit long.
  2. Select the type of account. By default, it is set to User type.
  3. Click Submit Button.
  4. A message will appear after successful account creation. ![ref2]

Figure 7 account creation

  1. Press continue button to login.
  2. How to make Admin Account
    1. Follow 1.1.1 to 1.1.6.
    2. For creating admin type account select admin option.
    3. It will ask for permission from Administrator of the application like below

Figure 8 admin permission

  1. Enter username and password of any administrator account to continue
  2. Click submit button.
  3. A message will appear after successful account creation. ![ref2]

Figure 9 account creation

  1. How to login
    1. Start the application
    2. A login window will appear on the screen like below. ![ref3]

Figure 10 quiz login

  1. Enter your username and password.

Figure 11 quiz login username and password

  1. Click login.
  2. After successful login user or admin menu will appear.

Figure 12 admin menu

  1. or

Figure 13 user admin

  1. How to start a quiz
    1. Select Quiz option from user or admin menu.
    2. Quiz menu will appear like this is there are no quizzes available.

Figure 14 no quiz available

  1. Quiz menu will appear like this if there are quizzes available.

Figure 15 quiz available

  1. Click on the quiz you want to attempt.
  2. If you have exceeded response limit of quiz a message will appear

Figure 16 quiz response limit

  1. If the scheduled date does not match the current date a message will appear

Figure 17 quiz schedule

  1. If the scheduled time does not match the current time a message will appear

Figure 18 quiz schedule time

  1. Instruction will appear if 3.5 to 3.7 is satisfied

Figure 19 quiz instruction

  1. Click Accept to start the quiz
  2. Click Decline to quit the quiz but response won’t be counted
  3. How to attempt a quiz

Figure 20 quiz attempt

  1. Name of quiz
  2. Time limit of quiz
  3. Name of section in the quiz
  4. Question and options
  5. Back button to go to previous question in section in quiz
  6. Next button to go to next question in section in quiz
  7. Previous section button to go to previous section in quiz
  8. Next section button to go to next section in quiz
  9. Submit button to submit the response.
  10. Exit button to exit the quiz.
  11. Jump to any question of any section by clicking the question number.
  12. How to reset password
    1. From user menu or quiz menu select user dashboard option.
    2. A user or admin dashboard will appear. ![ref4]

Figure 21 user or admin dashboard

  1. Click show to view password

Figure 22 view password

  1. Click edit and change the password

Figure 23 change password

  1. Click save to save the reset password

Figure 24 save password

  1. How to View Quiz result
    1. From user menu or quiz menu select user dashboard option.
    2. A user or admin or user dashboard will appear. ![ref4]

Figure 25 admin or user dashboard

  1. If there are no previous attempts a message will appear.

Figure 26 no response dashboard

  1. If there are attempts available it will appear like this.

Figure 27 quiz response available

  1. Click the quiz name you want to view the result.
  2. The result will appear on right side.

Figure 28 quiz result

  1. How to save the quiz result
    1. Follow 7.1 to 7.6
    2. Click the export button on the bottom of the result.
    3. It will ask the path and name to save.

Figure 29 save quiz result dialog

  1. If the quiz result was saved successfully a message will popup

Figure 30 quiz result save message

  1. If there are any errors occur whiling saving result a message will appear.
  2. The Result will be saved in a PDF file.
  3. How to export all the responses of a quiz
    1. Follow 7.1 to 7.6
    2. Requires admin account.
    3. Click on export button on right side of the quiz you want to export all the responses.
    4. It will ask for name and path of file to save

Figure 31 export all quiz response

  1. If the file was exported successfully a message will popup

Figure 32 all quiz response exported successfully

  1. How to create a quiz.
    1. Requires admin account.
    2. Click quiz editor option from admin menu.
    3. Press Ctrl + N or ![ref5]

Figure 33 create quiz

  1. Click File option from menu. ![ref6]

Figure 34 quiz editor menu

  1. Click New option

Figure 35 new quiz

  1. If there is quiz opened already it will ask to save the already opened quiz

Figure 36 save quiz message

  1. After that New quiz will be created to edit.

Figure 37 new quiz created

  1. How to open saved quiz.
    1. Requires admin account
    2. Press Ctrl + O or
    3. Click File option from menu in quiz editor ![ref7]

Figure 38 quiz editor file menu

  1. Click open option

Figure 39 open quiz

  1. Open window will appear like this if there are no quizzes saved already message will appear like this

Figure 40 no quiz to edit

  1. Open window will appear like this if there are quizzes available

Figure 41 quiz to edit

  1. Click the quiz you want to open.
  2. How to save quiz
    1. Requires admin account
    2. Press Ctrl + S or
    3. Click File option from menu in quiz editor. ![ref7]

Figure 42 quiz editor menu

  1. Click Save option.

Figure 43 save quiz

  1. A popup message will appear asking whether to save file or not.

Figure 44 save quiz message

  1. A popup message will appear saying file saved successfully.

Figure 45 quiz saved message

  1. How to remove quiz
    1. Follow 9.1 to 9.5
    2. Click Remove button on the right side of the quiz you want to remove.
    3. A message will popup asking are you sure you want to remove the quiz

Figure 46 remove quiz

  1. How to close quiz
    1. Requires admin account
    2. Press Ctrl + C or
    3. Click File option from menu in quiz editor. ![ref7]

Figure 47 quiz editor menu

  1. Click Close option.

Figure 48 close quiz

  1. A message will popup asking to save the file or not.

Figure 49 save quiz message

  1. A message will popup saying save file

Figure 50 quiz saved message

  1. How to edit quiz

Figure 51 quiz edit

  1. Enter quiz name here
  2. Enter section name here.
  3. Enter question here.
  4. Enter option here
  5. Click to Add Section
  6. Click to Add Question
  7. Click to Add Option
  8. Schedule date of quiz by checking.
  9. Scheduling time of quiz by checking.
  10. Set time limit by checking.
  11. Set response limit. NOTE 0 is default value meaning unlimited response.
  12. Click to Remove section
  13. Click to Remove question
  14. Click to remove option
  15. Set points of question by checking.
  16. Set the option as answer key by checking.
  17. How to exit quiz editor
    1. Requires admin account
    2. Press Ctrl + Q or
    3. Click File option from menu in quiz editor. ![ref7]

Figure 52 quiz editor menu

  1. Click Exit option

Figure 53 exit quiz

  1. If any quiz is opened it ask to save it.
  2. Then it will come back to user or admin menu
  3. How to view Quiz editor version
    1. Requires admin account
    2. Click About option from menu in quiz editor. ![ref7]

Figure 54 quiz editor menu

  1. A window will appear showing version of quiz editor

Figure 55 quiz editor version

Quiz database

Quiz.db

users table

  1. CREATE TABLE "users" (
  2. "id" INTEGER NOT NULL UNIQUE,
  3. "username" TEXT NOT NULL,
  4. "password" TEXT NOT NULL,
  5. "privilege" INTEGER NOT NULL,
  6. PRIMARY KEY("id" AUTOINCREMENT)
  7. )

 responses table

  1. CREATE TABLE "responses" (
  2. "user" INTEGER NOT NULL,
  3. "quiz" INTEGER NOT NULL,
  4. "response" TEXT NOT NULL UNIQUE,
  5. "response_count" INTEGER DEFAULT 1,
  6. PRIMARY KEY("user","quiz")
  7. )

 quizzes table

  1. CREATE TABLE "quizzes" (
  2. "id" INTEGER NOT NULL UNIQUE,
  3. "name" TEXT NOT NULL,
  4. "path" TEXT NOT NULL UNIQUE,
  5. PRIMARY KEY("id" AUTOINCREMENT)
  6. )