# exam **Repository Path**: ccming11/exam ## Basic Information - **Project Name**: exam - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-07 - **Last Updated**: 2025-05-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 在线考试平台 一个基于 Flask 和 SQLite 构建的在线考试平台,支持多种题型,包括单选题、多选题、判断题和填空题,并能自动评分。 ## 功能特点 - 用户注册和登录 - 考试列表展示 - 多种题型支持(单选、多选、判断、填空) - 考试时计时功能 - 自动评分系统 - 查看历史考试记录和成绩 ## 技术栈 - Flask - Web框架 - SQLite - 数据库 - Flask-SQLAlchemy - ORM工具 - Flask-Login - 用户认证 - Flask-WTF - 表单处理 - Bootstrap 5 - 前端框架 ## 安装与运行 1. 克隆仓库 ```bash git clone https://github.com/your-username/online-exam-platform.git cd online-exam-platform ``` 2. 创建并激活虚拟环境 ```bash # Windows python -m venv venv venv\Scripts\activate # Linux/Mac python -m venv venv source venv/bin/activate ``` 3. 安装依赖 ```bash pip install -r requirements.txt ``` 4. 运行应用 ```bash python app.py ``` 5. 在浏览器中访问 `http://127.0.0.1:5000/` ## 管理员添加考试 目前系统未实现管理员界面,需要通过Python脚本添加考试数据。您可以使用以下示例脚本添加测试数据: ```python from app import create_app from app.models.models import db, Exam, Question import json app = create_app() with app.app_context(): # 创建考试 exam = Exam( title='Python编程基础测试', description='本测试旨在评估您的Python基础知识水平,包含单选、多选、判断和填空题。', time_limit=30, # 30分钟 is_active=True ) db.session.add(exam) db.session.commit() # 添加单选题 q1 = Question( exam_id=exam.id, content='Python中,以下哪个不是基本数据类型?', type='single_choice', options=json.dumps({ 'A': 'int', 'B': 'float', 'C': 'list', 'D': 'str' }), correct_answer='C', score=5 ) # 添加多选题 q2 = Question( exam_id=exam.id, content='以下哪些是Python的循环语句?(多选)', type='multiple_choice', options=json.dumps({ 'A': 'for', 'B': 'while', 'C': 'loop', 'D': 'do-while' }), correct_answer='A,B', score=10 ) # 添加判断题 q3 = Question( exam_id=exam.id, content='Python是一种解释型语言。', type='true_false', options=json.dumps({ 'true': '正确', 'false': '错误' }), correct_answer='true', score=5 ) # 添加填空题 q4 = Question( exam_id=exam.id, content='Python列表的长度可以使用____函数获取。', type='fill_blank', options=json.dumps({}), correct_answer='len', score=5 ) db.session.add_all([q1, q2, q3, q4]) db.session.commit() print('测试数据添加成功!') ``` 将上述代码保存为 `add_test_data.py` 文件,然后运行: ```bash python add_test_data.py ``` ## 项目结构 ``` online-exam-platform/ ├── app/ # 应用主目录 │ ├── controllers/ # 控制器 │ │ ├── auth.py # 身份验证控制器 │ │ └── exams.py # 考试控制器 │ ├── models/ # 数据模型 │ │ └── models.py # 数据库模型定义 │ ├── static/ # 静态文件 │ │ ├── css/ # CSS文件 │ │ ├── js/ # JavaScript文件 │ │ └── images/ # 图片文件 │ ├── templates/ # 模板文件 │ │ ├── base.html # 基础模板 │ │ ├── index.html # 首页 │ │ ├── login.html # 登录页面 │ │ ├── register.html # 注册页面 │ │ └── ... │ └── __init__.py # 应用初始化 ├── config.py # 配置文件 ├── app.py # 主应用文件 ├── add_test_data.py # 添加测试数据脚本 └── requirements.txt # 依赖包列表 ``` ## 后续改进计划 - 添加管理员界面,方便管理考试和题目 - 实现更多题型,如编程题 - 增加考试结果分析功能 - 实现题目随机抽取功能 - 支持图片和附件上传