Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7e217ff
add bg music and slight UI changes
HamidKab Nov 29, 2025
6693751
feat: add difficulty slider (easy/medium/hard)
jaysonkiggundu Nov 30, 2025
295dd63
Minor UI changes & addition of light and dark mode toggle
HamidKab Nov 30, 2025
91b3159
Merge pull request #1 from HamidKab/hamid-ui
HamidKab Nov 30, 2025
44bbf5c
Fixed dark mode difficulty toggle
HamidKab Nov 30, 2025
5487656
Merge pull request #2 from HamidKab/jayson-difficulty-slider
HamidKab Nov 30, 2025
ccd1449
creating a default django backend that stores questions and categories
Obinna84 Nov 30, 2025
c2d0b2b
Merge pull request #3 from HamidKab/create-backend
Obinna84 Dec 1, 2025
184875d
creating game result model to eventually handle leaderboard logic
Obinna84 Dec 1, 2025
4caadab
creating a documentation directory
Obinna84 Dec 1, 2025
6dca3fe
Merge pull request #5 from HamidKab/documentation-storage-directory
Obinna84 Dec 1, 2025
9db8ced
Merge pull request #4 from HamidKab/backend-models
HamidKab Dec 1, 2025
35b362a
connected frontend to backend to POST game results and added categori…
Obinna84 Dec 2, 2025
9af15b2
Merge pull request #6 from HamidKab/connect-gameresult-model-to-front…
Obinna84 Dec 2, 2025
3f0fc1a
adding leaderboard functionality to backend
Obinna84 Dec 4, 2025
b8fb671
Merge pull request #7 from HamidKab/leaderboard-model-backend
Obinna84 Dec 4, 2025
f6470ac
Updated Readme
HamidKab Dec 6, 2025
60c9ad7
Merge branch 'main' of https://github.com/HamidKab/quiz-game
HamidKab Dec 6, 2025
a7ece72
Login functionality
HamidKab Dec 6, 2025
6a48a6a
player name collection
Dec 7, 2025
ad8ec77
update backend logic for leaderboard display
Dec 8, 2025
4783d8f
frontend logic for leaderboard
Dec 8, 2025
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
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<!-- PROJECT LOGO -->
<div align="center">
<a href="https://quizi.vercel.app"><img src="./readme/header.webp" alt="Instagram" /></a>
<a href="https://quizi.vercel.app"><img src="./readme/quizard.png" alt="Instagram" /></a>
<br/>
<br />

# 🟥🟦 Quizi 🟨🟩
# 🟥🟦 Quizard 🟨🟩

A quiz/trivia game with different modes and categories that you can select, as well as wildcards to help you. The questions are generated by artificial intelligence using the [Cohere API](https://dashboard.cohere.ai/welcome/register).

Expand Down Expand Up @@ -35,7 +35,7 @@ A quiz/trivia game with different modes and categories that you can select, as w
<!-- ABOUT THE PROJECT -->
## About The Project

Quizi is a quiz/trivia game made with with [Cohere](https://cohere.ai). You can select different game modes and topics, you also have wildcards. Cohere's AI will generate the questions and answers for you.
Quizard is a quiz/trivia game made with with [Cohere](https://cohere.ai). You can select different game modes and topics, you also have wildcards. Cohere's AI will generate the questions and answers for you. This project was forked from cosmoart/quiz-game and modified to add a backend using Django Rest Framework to serve pre-generated questions.

> **Note:** Due to Cohere's policy change (from 100 to 5 free calls) now only some questions are generated by Cohere. The rest are pre-generated.

Expand All @@ -48,22 +48,16 @@ Quizi is a quiz/trivia game made with with [Cohere](https://cohere.ai). You can
<table>
<tr>
<td>
<img src="./readme/home_mobile.webp" width="100%" title="Home in Mobile" />
<img src="./readme/quizard_mobile.png" width="100%" title="Home in Mobile" />
</td>
<td>
<img src="./readme/home_tablet.webp" width="100%" title="Home in Tablet"/>
</td>
<td>
<img src="./readme/home_desktop.webp" width="100%" title="Home in Desktop"/>
<img src="./readme/quizard.png" width="100%" title="Home in Desktop"/>
</td>
</tr>
<tr>
<td>
<img src="./readme/play_classic_mobile.webp" width="100%" title="Play, classic mode in Mobile" />
</td>
<td>
<img src="./readme/play_classic_tablet.webp" width="100%" title="Play, classic mode in Tablet"/>
</td>
<td>
<img src="./readme/play_classic_desktop.webp" width="100%" title="Play, classic mode in Desktop"/>
</td>
Expand All @@ -72,9 +66,6 @@ Quizi is a quiz/trivia game made with with [Cohere](https://cohere.ai). You can
<td>
<img src="./readme/play_time_mobile.webp" width="100%" title="Play, time and infinity mode in Mobile" />
</td>
<td>
<img src="./readme/play_time_tablet.webp" width="100%" title="Play, time and infinity mode in Tablet"/>
</td>
<td>
<img src="./readme/play_time_desktop.webp" width="100%" title="Play, time and infinity mode in Desktop"/>
</td>
Expand Down Expand Up @@ -111,7 +102,7 @@ List of the frameworks, libraries and tools used to build the project.

1. Clone or fork the repo
```sh
git clone https://github.com/cosmoart/quiz-game
git clone https://github.com/hamidkab/quiz-game
```
2. Change directory to `source_code`
```sh
Expand All @@ -126,6 +117,32 @@ npm install
npm run dev
```

## Running Backend
1. From repository root:
```
cd backend
python3 -m venv .venv # if not already created
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
```
2. Run migrations (required if you later add models):
```
python manage.py makemigrations
python manage.py migrate
```
3. Run Tests
```
python manage.py test
```
4. Start Development Server
```
python manage.py runserver 8000
```
Verify endpoints:
- http://127.0.0.1:8000/api/questions/
- http://127.0.0.1:8000/api/categories/

If you are in development environment all the questions are pre-generated, if you want to use the Cohere API you have to create a `.env.local` file with the Cohere API key at `source_code` and comment the `if` in `source_code/src/helpers/getQuestions.js`. You can get one Cohere Api key [here](https://dashboard.cohere.ai/welcome/register).

The `.env.local` file should look like this:
Expand Down Expand Up @@ -160,11 +177,6 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/cosmoa

<p align="right"><a href="#top">⬆️ Back to top</a></p>

<!-- CONTACT -->
## Contact

- My website - [cosmoart.vercel.app](https://cosmoart.vercel.app)
- Twitter - [@CosmoArt0](https://twitter.com/cosmoart0)
- Instagram - [@cosmo_art0](https://www.instagram.com/cosmo_art0/)

<p align="right"><a href="#top">⬆️ Back to top</a></p>

247 changes: 247 additions & 0 deletions backend/.venv/bin/Activate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.
.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.
.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.
.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.
.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.
.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.
.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.
.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170
#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)

<# Function declarations --------------------------------------------------- #>

<#
.Synopsis
Remove all shell session elements added by the Activate script, including the
addition of the virtual environment's Python executable from the beginning of
the PATH variable.
.Parameter NonDestructive
If present, do not remove this function from the global namespace for the
session.
#>
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values

# The prior prompt:
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
}

# The prior PYTHONHOME:
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
}

# The prior PATH:
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
}

# Just remove the VIRTUAL_ENV altogether:
if (Test-Path -Path Env:VIRTUAL_ENV) {
Remove-Item -Path env:VIRTUAL_ENV
}

# Just remove VIRTUAL_ENV_PROMPT altogether.
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
}

# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
}

# Leave deactivate function in the global namespace if requested:
if (-not $NonDestructive) {
Remove-Item -Path function:deactivate
}
}

<#
.Description
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
given folder, and returns them in a map.
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
two strings separated by `=` (with any amount of whitespace surrounding the =)
then it is considered a `key = value` line. The left hand string is the key,
the right hand is the value.
If the value starts with a `'` or a `"` then the first and last character is
stripped from the value before being captured.
.Parameter ConfigDir
Path to the directory that contains the `pyvenv.cfg` file.
#>
function Get-PyVenvConfig(
[String]
$ConfigDir
) {
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"

# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue

# An empty map will be returned if no config file is found.
$pyvenvConfig = @{ }

if ($pyvenvConfigPath) {

Write-Verbose "File exists, parse `key = value` lines"
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath

$pyvenvConfigContent | ForEach-Object {
$keyval = $PSItem -split "\s*=\s*", 2
if ($keyval[0] -and $keyval[1]) {
$val = $keyval[1]

# Remove extraneous quotations around a string value.
if ("'""".Contains($val.Substring(0, 1))) {
$val = $val.Substring(1, $val.Length - 2)
}

$pyvenvConfig[$keyval[0]] = $val
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
}
}
}
return $pyvenvConfig
}


<# Begin Activate script --------------------------------------------------- #>

# Determine the containing directory of this script
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$VenvExecDir = Get-Item -Path $VenvExecPath

Write-Verbose "Activation script is located in path: '$VenvExecPath'"
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"

# Set values required in priority: CmdLine, ConfigFile, Default
# First, get the location of the virtual environment, it might not be
# VenvExecDir if specified on the command line.
if ($VenvDir) {
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
}
else {
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
Write-Verbose "VenvDir=$VenvDir"
}

# Next, read the `pyvenv.cfg` file to determine any required value such
# as `prompt`.
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir

# Next, set the prompt from the command line, or the config file, or
# just use the name of the virtual environment folder.
if ($Prompt) {
Write-Verbose "Prompt specified as argument, using '$Prompt'"
}
else {
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
$Prompt = $pyvenvCfg['prompt'];
}
else {
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
$Prompt = Split-Path -Path $venvDir -Leaf
}
}

Write-Verbose "Prompt = '$Prompt'"
Write-Verbose "VenvDir='$VenvDir'"

# Deactivate any currently active virtual environment, but leave the
# deactivate function in place.
deactivate -nondestructive

# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir

if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {

Write-Verbose "Setting prompt to '$Prompt'"

# Set the prompt to include the env name
# Make sure _OLD_VIRTUAL_PROMPT is global
function global:_OLD_VIRTUAL_PROMPT { "" }
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt

function global:prompt {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
$env:VIRTUAL_ENV_PROMPT = $Prompt
}

# Clear PYTHONHOME
if (Test-Path -Path Env:PYTHONHOME) {
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
Remove-Item -Path Env:PYTHONHOME
}

# Add the venv to the PATH
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
Loading