Python课程设计:Python语言实现自动组卷评卷考试系统

您所在的位置:网站首页 高考自动阅卷系统 Python课程设计:Python语言实现自动组卷评卷考试系统

Python课程设计:Python语言实现自动组卷评卷考试系统

2024-05-25 04:52| 来源: 网络整理| 查看: 265

Python实现自动组卷评卷考试系统 课程设计要求一、各个模块介绍及实现1. Configure.py2. File_Texture_Tree.py3. 后端:Test_Problem_Control.py4. 前端:Test_Window.py 二、程序运行结果1.生成的文档结构图2.生成的答题GUI窗口附1:题库文档截图及文件夹的存放附2:一些文件的内容

课程设计要求

用Python语言编程实现自动组卷评卷考试系统,软件主要功能包括: 1. 从题库中随机抽取试题自动组成试卷(满分100分); 2. 实现考生考试答题操作界面; 3. 实现自动阅卷评分功能 要求: (1)题型包括单项选择题、填空题、判断题等等。 (2)题库可以采用文本文件、CSV文件或数据库等来实现。 (3)要求在源程序中标注必要的注释。 (4)要求对程序的使用和运行方法进行必要说明。

一、各个模块介绍及实现 1. Configure.py

存储一些全局变量和函数。

# -*- coding: utf-8 -*- """ Created on Fri Jan 22 12:34:46 2021 @author: stack """ import os ResourcePath='\\'+'data'+'\\' STATE_INIT = 1 STATE_SINGLE = 2 STATE_MULTI = 3 STATE_JUDGE = 4 STATE_DONE = 5 def getCurrentPath(): path=os.getcwd() #当前工作路径 # print(path) return path def list2str(changList) -> str: res='' for i in range(len(changList)): res=res+str(changList[i]) return res 2. File_Texture_Tree.py

产生文档结构树图,仅在windows环境下实现,未做linux扩展,如有需要,可以加if+os库判断平台进行修改。

# -*- coding: utf-8 -*- """ Created on Fri Jan 22 17:16:37 2021 @author: stack """ from pathlib import Path tree_str = '' def generate_tree(pathname, n=0): global tree_str if pathname.is_file(): tree_str += ' |' * n + '-' * 4 + pathname.name + '\n' elif pathname.is_dir(): tree_str += ' |' * n + '-' * 4 + \ str(pathname.relative_to(pathname.parent)) + '\\' + '\n' for cp in pathname.iterdir(): generate_tree(cp, n + 1) if __name__ == '__main__': generate_tree(Path.cwd()) print(tree_str) 3. 后端:Test_Problem_Control.py

此为软件的后端,主要实现了以下几个功能:

1. 检测用户是否存在,并检查账号和密码是否正确 2. 添加新用户 3. 设置单选题的分值,并从题库中随机抽取10道单选题,返回数据至前端 4. 设置多选题的分值,并从题库中随机抽取10道多选题,返回数据至前端 5. 设置判断题的分值,并从题库中随机抽取10道判断题,返回数据至前端 6. 编写与前端的数据接口

# -*- coding: utf-8 -*- """ Created on Fri Jan 22 15:38:33 2021 @author: stack """ import pandas as pd import random from Configure import * ResourcePath='\\'+'data'+'\\' '''检测用户是否存在,并检查账号和密码是否正确''' def checkAccount(filename) -> tuple: path = getCurrentPath() + ResourcePath + filename fid = open(path, 'r+') accountList = [] userNameList, userPasswordList = [], [] line = fid.readlines() for child in line: accountList.append(child.strip("\n").split('\t')) for name, password in accountList: userNameList.append(name) userPasswordList.append(password) fid.close() return userNameList, userPasswordList '''添加新用户''' def addUser(filename, userName:str, userPassword:str) -> int: path = getCurrentPath() + ResourcePath + filename txtfile = open(path, 'a') data = '\n' + userName + '\t' + userPassword txtfile.write(data) txtfile.close() return 1 '''单选题''' class SingleChoiceSubject: def __init__(self): self.scorePer = 3 # 每道题的分值 self.totalNum = 10 # 总共10道单选 self.subjectList = {} # 存放所有题目信息 self.path = getCurrentPath() + ResourcePath + '原题集合.xlsx' self.df = pd.read_excel(self.path, sheet_name='单选题') self.tempList = [] # 存储一行信息 self.randList = [] # 存储已经选用的题目,防止随机题目 def generateRand(self): """ 产生随机题目序号 """ count = 0 while count } #存放所有题目的信息 self.path=getCurrentPath()+ResourcePath+'原题集合.xlsx' self.df=pd.read_excel(self.path,sheet_name='多选题') self.randList=[] def generateRand(self): """ 产生随机题目序号 """ count = 0 while count } # 存放所有题目信息 self.path = getCurrentPath() + ResourcePath + '原题集合.xlsx' self.df = pd.read_excel(self.path, sheet_name='判断题') self.randList = [] def generateRand(self): count = 0 while count


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3