Skip to content

Afhrodite/Quest-for-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quest-for-Python

Python SQLite Tkinter

Created by Réka Gábosi

Table of Contents

Description

Quest for Python is made in Python, it's a graphical user interface program, designed to help users learn Python better by using a Quiz. The program allows users to add new questions or delete them within an SQLite database, and test themselves on various Python topics.

The interface is built using the Tkinter library, making it more user-friendly.

Features

User Interface

Graphical User Interface: built with Tkinter, using buttons and entry fields.

Windows Management

  • Main Window: Here we can find the description about the game, the Quiz button that lead us to the game and the Add & Delete button where we can add or delete a question.
Main Window
  • Add & Delete: Here we can add and delete a question.
Add & Delete
  • Quiz Window: Here is the main game, where we can select a type and answer all the questions a type has, when we finish the game it will show our score.
Quiz Window

The quiz will also show if the user answered a question correctly or not. If there is only one answer marked with a green color, then the user selected the correct answer. If there are two answers marked one with red and one with green, then the user didn't select the correct answer.

Green or Red

Project Files Overview

  • main.py - The main program, which runs the Quest for Python.
  • test_main.py - The code tester program.
  • images/ - Contains both the images for the GUI and README.
  • database/quiz.db - SQLite database which stores questions and answers.
  • requirements.txt - A file listing the dependencies required to run the application.
  • README.md - Project documentation.
  • LICENSE - The license file for the project (CC BY-ND 4.0).

Database Design

Scope

The database is designed to efficiently store and manage all the questions.

Functional Requirements

  • Stores all the questions, answers and decoys.
  • Allows easy modification and retrieval for any question.

Representation

The SQLite database has a single table named quiz with the following schema:

Main Menu
  • id: which specifies the unique ID for each question as an INTEGER. This will be the PRIMARY KEY.
  • type: which specifies the type of question as TEXT. Its required so it's put with NOT NULL.
  • question: which specifies the question as TEXT. Its required so it's put with NOT NULL.
  • answer: which specifies the correct answer as TEXT. Its required so it's put with NOT NULL.
  • decoy_1, decoy_2, decoy_3 which specifies the incorrect answers as TEXT.

While this structure supports multiple-choice questions (with 1 correct answer and 3 incorrect answers), the decoy fields are optional. This allows the database to be used in numerous ways, such as:

  • Quizzing: Standard miltiple-choice format
  • Learing: Flashcard style reptiton, where only the correct answer is provided This allow users to study with this applications but also test themselfs.

Installation

Prerequisites

  • Ensure you have Python installed (version 3.x recommended).
  • Library installed with:

Install all dependencies from requirements.txt

pip install -r requirements.txt

Running the Application

  1. Clone this repository or download the files.
  2. Run the application by entering in the terminal the following:
python main.py

Design Choices

Modularity

The project is structured with classes to clearly separate each part:

  • The Database class manages all SQLite operations (add, delete, query).

  • The Quiz class handles the quiz logic (scoring, question flow, answer checking).

  • The GUI classes (Start_GUI, Add_Delete_GUI, Quiz_GUI) each of them representing distinct parts of the interface, making it easier to update or extend one part without affecting the rest.

This modular design makes the application easier to maintain, test, and expand.

SQLite for Data Storage

SQLite is simple, easy to access and use. It stores all questions in a local file (quiz.db), which:

  • Ensures fast and efficient querying of quiz data.

  • Supports dynamic question management.

Tkinter for GUI

Tkinter is a simple built-in solution for creating graphical applications in Python. Making the project more user-friendly.

Testing

The core database functionality test is provvided in test_main.py using pytest. The tests are made in-memory SQLite database, to avoid modifying the real data. In addition, the full application was manually tested by interacting with the GUI to verify all features, like navigating through the interface, shuffling the questions order, shuffling the answers order, ensuring that the final result is valid.

Acknowledgments

  • This project was created as a final project for Harvard University's CS50’s Introduction to Programming with Python online course.
  • Additional skills and knowledge were gained through completing:
    • CS50’s Introduction to Computer Science
    • CS50’s Introduction to Databases with SQL
  • Special thanks to Codemy.com YouTube Channel for providing excellent tutorials on Tkinter GUI development.

About

A Python-based quiz with Tkinter GUI and SQLite database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages