Repository navigation
Releases
ABC-Quiz V1.0.1
Offical Rebranded to ABC-Quiz.
ABC-Quiz
A modern, responsive, and completely self-contained quiz platform built using only the Python standard library. It utilizes zero external dependencies (no Flask, no Django, no Pip packages) and follows a beautiful consistent dark theme featuring the IBM Plex Mono font.
System Overview
The platform consists of three independent web services running on separate ports:
- Student Quiz Portal (Port
8080): Handles student authentication, quiz sessions, JS countdown timers, backend timeout validation, and score records. - Admin Panel (Port
8081): Allows student account management, password resets, database stats inspection, and full scorecard visualization. - Question Editor (Port
8083): Single-page database management interface to create, update, or delete quiz questions.
Installation & Setup
Since the platform uses only the Python standard library, there is no package installation step (pip install is not required).
Prerequisites
- Python 3.8 or higher.
- Note: On most Unix/macOS environments, run commands using
python3instead ofpython(which might be unassigned).
Step 1: Initialize the Database
Run the setup script to create the necessary directories and default configuration/user/question databases:
python3 setup.pyThis command will:
- Create
/data/and/data/scorecards/subdirectories. - Write a default global config in
data/config.json. - Populate a set of photography questions in
data/questions.json. - Set up initial users in
data/users.json(1 administrator, 2 students).
How to Run
You can launch the entire ecosystem concurrently or run each component independently.
Option A: Run All Services Together (Recommended)
Launch the threaded startup coordinator script:
python3 start_all.pyThis will run all three servers simultaneously. Press Ctrl+C to shut down all servers gracefully.
Option B: Run Services Independently
If you want to run only a specific component or test them in separate shell windows, run:
# Start Student Quiz App (Port 8080)
python3 quiz_app.py
# Start Admin Management Panel (Port 8081)
python3 admin_app.py
# Start Question Editor (Port 8083)
python3 editor_app.pyScript Walkthrough
1. setup.py
The initialization script. Run this first to generate the template databases.
2. utils.py
Shared library containing core backend utilities:
- Atomic Operations:
load_jsonandsave_jsonwrite to temporary files first (.tmp) before moving them to prevent database corruption. - Session Handler:
SessionStoreimplements cookie-based sessions with a 30-minute idle timeout. - BaseHandler: Extends standard
BaseHTTPRequestHandlerto support cookie-buffering (ensuring correct HTTP status header sequence) and unhandled exception catchers (delivering a clean 500 error page).
3. quiz_app.py (Port 8080)
The client-facing portal.
- Access:
http://localhost:8080 - Default Accounts:
- Username:
student1| Password:pass1234 - Username:
student2| Password:pass1234
- Username:
- Dynamic Quiz Title: Resolves and displays the correct user-defined quiz label/title dynamically based on the active questions file specified in the configuration.
- Timer: A countdown timer is displayed for active question limits. It turns red in under 10 seconds and auto-submits on expiration.
- Anti-Cheat: If a student refreshes or stops Javascript, the backend checks the elapsed time against
start_time_of_current_questionstored in the session and marks it as a timeout if exceeded.
4. admin_app.py (Port 8081)
The dashboard for staff.
- Access:
http://localhost:8081 - Default Account:
- Username:
admin| Password:admin123
- Username:
- Features: View submission logs, check student success percentages, view question-by-question student scorecards, reset student credentials, or add/delete student profiles. Includes quiz labels alongside quiz filenames in the settings selection dropdown.
5. editor_app.py (Port 8083)
A single-page, split-panel questions dashboard.
- Access:
http://localhost:8083(No auth required). - Features: Add, modify, or delete questions. ID allocation (e.g.,
q001,q002...) is automatically incremented. - Quiz Labeling: Allows defining and saving a customized title/label for each individual quiz file (stored in
data/config.json), which displays next to the filename in dropdown selection menus across services.
ABC-Quiz (繁體中文)
一個現代、響應式且完全自包含的測驗平台,僅使用 Python 標準庫構建。它不需要任何外部依賴(無 Flask、無 Django、無需 Pip 安裝包),並採用基於 IBM Plex Mono 字型的精美一致深色主題。
系統概述
本平台由三個運行在不同連接埠(Port)的獨立網頁服務組成:
- 學生測驗入口網站(連接埠
8080):處理學生身分驗證、測驗工作階段、JS 倒數計時器、後端逾時驗證及分數記錄。 - 管理員控制面板(連接埠
8081):允許管理學生帳戶、重設密碼、檢查資料庫統計資訊以及完整計分卡視覺化展示。 - 題目編輯器(連接埠
8083):單頁式資料庫管理介面,用於新增、更新或刪除測驗題目。
安裝與設定
由於本平台僅使用 Python 標準庫,因此無需任何套件安裝步驟(不需要執行 pip install)。
系統需求
- Python 3.8 或更高版本。
- 注意:在大多數 Unix/macOS 環境中,請使用
python3替代python執行指令(後者可能未分配路徑)。
步驟 1:初始化資料庫
執行設定指令碼以建立必要的目錄以及預設的設定、使用者和題目資料庫:
python3 setup.py此指令將會:
- 建立
/data/與/data/scorecards/子目錄。 - 在
data/config.json中寫入預設的全域設定。 - 在
data/questions.json中填入一組攝影相關題目。 - 在
data/users.json中設定初始使用者(1 位管理員,2 位學生)。
如何執行
您可以同時啟動整個生態系統,或是獨立執行每個組件。
方案 A:同時執行所有服務(推薦)
啟動多執行緒啟動協調指令碼:
python3 start_all.py這將同時執行所有三個伺服器。按下 Ctrl+C 即可優雅地關閉所有伺服器。
方案 B:獨立執行各個服務
如果您只想執行特定組件,或是在不同的終端機視窗中進行測試,請執行:
# 啟動學生測驗應用程式 (連接埠 8080)
python3 quiz_app.py
# 啟動管理員管理面板 (連接埠 8081)
python3 admin_app.py
# 啟動題目編輯器 (連接埠 8083)
python3 editor_app.py指令碼與核心模組說明
1. setup.py
初始化指令碼。請先執行此指令碼以產生資料庫範本。
2. utils.py
包含核心後端公用程式的共享程式庫:
- 不可分割操作 (Atomic Operations):
load_json和save_json會先寫入暫存檔案(.tmp)然後再進行移轉,以防止資料庫損壞。 - 工作階段管理器 (Session Handler):
SessionStore實作了基於 Cookie 的工作階段(Session),並設有 30 分鐘的閒置逾時限制。 - BaseHandler:擴充了標準的
BaseHTTPRequestHandler,以支援 Cookie 快取(確保正確的 HTTP 狀態標頭順序)與未處理例外狀況的擷取器(呈現乾淨的 500 錯誤頁面)。
3. quiz_app.py (連接埠 8080)
面向用戶端的入口網站。
- 存取網址:
http://localhost:8080 - 預設帳戶:
- 使用者名稱:
student1| 密碼:pass1234 - 使用者名稱:
student2| 密碼:pass1234
- 使用者名稱:
- 動態測驗標題:根據設定中指定的活動題目檔案,動態解析並顯示正確的使用者自訂測驗標籤/標題。
- 計時器:顯示當前題目時間限制的倒數計時器。在剩餘時間少於 10 秒時會變紅,並在逾時後自動送出答案。
- 防作弊機制:如果學生重新整理頁面或停用 JavaScript,後端會比對目前時間與儲存在工作階段(Session)中的
start_time_of_current_question,若超過時限則標記為逾時。
4. admin_app.py (連接埠 8081)
教職員管理控制台。
- 存取網址:
http://localhost:8081 - 預設帳戶:
- 使用者名稱:
admin| 密碼:admin123
- 使用者名稱:
- 功能:查看提交記錄、檢查學生成績百分比、逐題查看學生計分卡、重設學生登入憑證,以及新增/刪除學生設定檔。在設定選擇下拉選單中同時顯示測驗標籤與測驗檔案名稱。
5. editor_app.py (連接埠 8083)
單頁式、雙面板設計的題目管理主控台。
- 存取網址:
http://localhost:8083(無需身份驗證)。 - 功能:新增、修改或刪除題目。ID 分配(例如:
q001、q002等)會自動遞增。 - 測驗標籤設定:允許為每個獨立的測驗檔案(儲存在
data/config.json中)定義並儲存自訂的標題/標籤,該標籤會在各個服務的下拉選擇選單中顯示於檔案名稱旁。
ABC-Quiz
Release Notes: v1.0.0 (Initial Release)
We are excited to announce the first official release of the Python Multi-Service Quiz Platform. This lightweight, responsive, and completely self-contained ecosystem is designed to host, manage, and track quizzes without the overhead of external web frameworks or package dependencies.
Key Features
- Zero-Dependency Architecture
Built entirely using the Python standard library.
No pip install, Flask, Django, or external database configuration required—just pure Python 3.8+.
- Three Interconnected Web Services
The platform concurrently runs three independent applications on dedicated ports:
Student Quiz Portal (Port 8080): Features secure student authentication, active quiz sessions, an intuitive dark-themed UI, and a live JS countdown timer.
Admin Management Panel (Port 8081): Provides staff with student profile creation/deletion, credential resets, database metric insights, and granular student scorecard visualizations.
Question Editor (Port 8083): A single-page, split-panel dashboard allowing administrators to easily create, update, delete, and dynamically label custom quiz question files.
- Built-in Anti-Cheat & Robust Security
Backend Validation: Automatically calculates elapsed time on the backend (start_time_of_current_question) to prevent students from bypassing countdowns via page refreshes or disabling JavaScript.
Session Management: Implements secure cookie-based sessions backed by an automatic 30-minute idle timeout.
Atomic Data Integrity: Protects local databases (.json) from corruption during simultaneous reads/writes by utilizing a temporary file swap system (.tmp).
Getting Started
Quick Initialization
To set up your default database directories, configuration files, and pre-populated photography questions, run:
Bash
python3 setup.py
Launching the Platform
You can spin up all three services simultaneously using the provided threaded startup coordinator:
Bash
python3 start_all.py
For detailed multi-window manual execution or configuration adjustments, please refer to the README.md file included in the repository.