[免费]基于Python的Django+Vue3在线考试系统【论文+源码+SQL脚本】

大家好,我是java1234_小锋老师,看到一个不错的基于Python的Django+Vue3在线考试系统,分享下哈。

项目视频演示

【免费】基于Python的Django+Vue3在线考试系统 Python毕业设计_哔哩哔哩_bilibili

项目介绍

本论文提出并实现了一种基于Python的Django和Vue3技术栈的在线考试系统,旨在为教育机构提供高效、便捷的考试管理与评估解决方案。随着在线教育的快速发展,传统的考试模式面临诸多挑战,包括时间限制、资源分配及评分效率等问题。针对这些挑战,我们设计了一个集题库管理、在线答题、自动评分、统计分析等功能于一体的系统,以提高考试的灵活性和效率。

系统的后端采用Django框架,充分利用其强大的ORM(对象关系映射)功能,便于数据的管理与操作。通过Django REST framework构建RESTful API,实现了前后端的高效通信,确保数据的实时更新与处理。系统的数据库设计包括用户管理、考试管理、题库管理等模块,能够满足不同类型考试的需求。

前端方面,我们选择了Vue3作为主要开发框架,利用其响应式数据绑定和组件化开发的优势,实现了一个友好且易于操作的用户界面。用户可以通过直观的操作界面进行考试报名、在线答题、查看成绩等功能,提升了用户体验。此外,系统还集成了实时反馈机制,允许考生在答题过程中查看答题状态和剩余时间,提高了考试的透明度和紧迫感。

为了确保系统的稳定性和安全性,我们进行了严格的测试,包括功能测试、性能测试和安全性测试。结果表明,该系统在高并发场景下仍能保持良好的响应速度,自动评分功能能够快速且准确地处理考试结果,并生成详细的统计报表,帮助教师和管理人员分析考生表现。

综上所述,基于Django和Vue3的在线考试系统不仅解决了传统考试模式中的一些痛点,还为用户提供了便捷的操作体验。未来,我们计划进一步扩展系统功能,例如引入智能题库推荐、实时监考功能以及数据挖掘分析,以适应更加复杂的在线考试需求。该系统的实现对于推动教育信息化进程具有重要意义,有助于提升在线教育的质量和效率。

系统展示

部分代码

import uuid
from datetime import timefrom django.core.cache import cache
from django.core.paginator import Paginator
from django.db import transaction
from django.db.models import Qfrom app import models
from comm import ExamUtils
from comm.BaseView import BaseView
from comm.CommUtils import SysUtil
from comm.CommUtils import DateUtil'''
系统处理
'''
class SysView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'info':return SysView.getUserInfo(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'login':return SysView.login(request)elif module == 'exit':return SysView.exit(request)elif module == 'info':return SysView.updUserInfo(request)elif module == 'pwd':return SysView.updUserPwd(request)else:return BaseView.error('请求地址不存在')# 获取指定用户信息def getUserInfo(request):user = models.Users.objects.filter(id=cache.get(request.GET.get('token'))).first()if user.type==0:return BaseView.successData({'id': user.id,'userName': user.userName,'name': user.name,'gender': user.gender,'age': user.age,'type': user.type,})elif user.type==1:teacher = models.Teachers.objects.filter(user__id=user.id).first()return BaseView.successData({'id': user.id,'userName': user.userName,'name': user.name,'gender': user.gender,'age': user.age,'type': user.type,'phone': teacher.phone,'record': teacher.record,'job': teacher.job,})elif user.type==2:student = models.Students.objects.filter(user__id=user.id).first()return BaseView.successData({'id': user.id,'userName': user.userName,'name': user.name,'gender': user.gender,'age': user.age,'type': user.type,'gradeId': student.grade.id,'gradeName': student.grade.name,'collegeId': student.college.id,'collegeName': student.college.name,})#登陆处理def login(request):userName = request.POST.get('userName')passWord = request.POST.get('passWord')user = models.Users.objects.filter(userName=userName)if user.exists():user = user.first()if user.passWord == passWord:token = uuid.uuid4()resl = {'token': str(token)}cache.set(token, user.id, 60*60*60*3)return SysView.successData(resl)else:return SysView.warn('用户密码输入错误')else:return SysView.warn('用户名输入错误')#退出系统def exit(request):cache.delete(request.POST.get('token'))return BaseView.success()# 修改用户信息def updUserInfo(request):user = models.Users.objects.filter(id=cache.get(request.POST.get('token')))if (request.POST.get('userName') != user.first().userName) & \(models.Users.objects.filter(userName=request.POST.get('userName')).exists()):return BaseView.warn('用户账号已存在')else:user.update(userName=request.POST.get('userName'),name=request.POST.get('name'),gender=request.POST.get('gender'),age=request.POST.get('age'),)return BaseView.success()# 修改用户密码def updUserPwd(request):user = models.Users.objects.filter(id=cache.get(request.POST.get('token')))if(request.POST.get('newPwd')!=request.POST.get('rePwd')):return BaseView.warn('两次输入的密码不一致')elif(request.POST.get('oldPwd')!=user.first().passWord):return BaseView.warn('原始密码输入错误')else:user.update(passWord=request.POST.get('newPwd'))return BaseView.success()'''
学院信息处理
'''
class CollegesView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'all':return CollegesView.getAll(request)elif module == 'page':return CollegesView.getPageInfos(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return CollegesView.addInfo(request)elif module == 'upd':return CollegesView.updInfo(request)elif module == 'del':return CollegesView.delInfo(request)else:return BaseView.error('请求地址不存在')# 获取全部的学院信息def getAll(request):colleges = models.Colleges.objects.all();return BaseView.successData(list(colleges.values()))# 分页获取学院信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')qruery = Q();if SysUtil.isExit(name):qruery = qruery & Q(name__contains=name)data = models.Colleges.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.id,'name': item.name,'createTime': item.createTime})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加学院信息def addInfo(request):models.Colleges.objects.create(name=request.POST.get('name'),createTime=DateUtil.getNowDateTime())return BaseView.success()# 修改学院信息def updInfo(request):models.Colleges.objects. \filter(id=request.POST.get('id')).update(name=request.POST.get('name'))return BaseView.success()# 删除学院信息def delInfo(request):if models.Students.objects.filter(college__id=request.POST.get('id')).exists():return BaseView.warn('存在关联记录无法移除')else:models.Colleges.objects.filter(id=request.POST.get('id')).delete()return BaseView.success()'''
班级信息处理
'''
class GradesView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'all':return GradesView.getAll(request)elif module == 'page':return GradesView.getPageInfos(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return GradesView.addInfo(request)elif module == 'upd':return GradesView.updInfo(request)elif module == 'del':return GradesView.delInfo(request)else:return BaseView.error('请求地址不存在')# 获取全部的班级信息def getAll(request):grades = models.Grades.objects.all();return BaseView.successData(list(grades.values()))# 分页获取班级信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')qruery = Q();if SysUtil.isExit(name):qruery = qruery & Q(name__contains=name)data = models.Grades.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.id,'name': item.name,'createTime': item.createTime})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加班级信息def addInfo(request):models.Grades.objects.create(name=request.POST.get('name'),createTime=DateUtil.getNowDateTime())return BaseView.success()# 修改班级信息def updInfo(request):models.Grades.objects. \filter(id=request.POST.get('id')).update(name=request.POST.get('name'))return BaseView.success()# 删除班级信息def delInfo(request):if models.Students.objects.filter(grade__id=request.POST.get('id')).exists():return BaseView.warn('存在关联学生无法移除')elif models.Exams.objects.filter(grade__id=request.POST.get('id')).exists():return BaseView.warn('存在关联考试无法移除')else:models.Grades.objects.filter(id=request.POST.get('id')).delete()return BaseView.success()'''
科目信息处理
'''
class ProjectsView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'all':return ProjectsView.getAll(request)elif module == 'page':return ProjectsView.getPageInfos(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return ProjectsView.addInfo(request)elif module == 'upd':return ProjectsView.updInfo(request)elif module == 'del':return ProjectsView.delInfo(request)else:return BaseView.error('请求地址不存在')# 获取全部的科目信息def getAll(request):projects = models.Projects.objects.all();return BaseView.successData(list(projects.values()))# 分页获取科目信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')qruery = Q();if SysUtil.isExit(name):qruery = qruery & Q(name__contains=name)data = models.Projects.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.id,'name': item.name,'createTime': item.createTime})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加科目信息def addInfo(request):models.Projects.objects.create(name=request.POST.get('name'),createTime=DateUtil.getNowDateTime())return BaseView.success()# 修改科目信息def updInfo(request):models.Projects.objects. \filter(id=request.POST.get('id')).update(name=request.POST.get('name'))return BaseView.success()# 删除科目信息def delInfo(request):if (models.Exams.objects.filter(project__id=request.POST.get('id')).exists() |models.Practises.objects.filter(project__id=request.POST.get('id')).exists()):return BaseView.warn('存在关联记录无法移除')else:models.Projects.objects.filter(id=request.POST.get('id')).delete()return BaseView.success()'''
教师信息处理
'''
class TeachersView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'page':return TeachersView.getPageInfos(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return TeachersView.addInfo(request)elif module == 'upd':return TeachersView.updInfo(request)elif module == 'del':return TeachersView.delInfo(request)else:return BaseView.error('请求地址不存在')# 分页查询教师信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')record = request.GET.get('record')job = request.GET.get('job')qruery = Q();if SysUtil.isExit(name):qruery = qruery & Q(user__name__contains=name)if SysUtil.isExit(record):qruery = qruery & Q(record=record)if SysUtil.isExit(job):qruery = qruery & Q(job=job)data = models.Teachers.objects.filter(qruery)paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.user.id,'userName': item.user.userName,'name': item.user.name,'gender': item.user.gender,'age': item.user.age,'type': item.user.type,'phone': item.phone,'record': item.record,'job': item.job})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加教师信息@transaction.atomicdef addInfo(request):if models.Users.objects.filter(userName=request.POST.get('userName')).exists():return BaseView.warn('账号已存在,请重新输入')elif models.Users.objects.filter(id=request.POST.get('id')).exists():return BaseView.warn('工号已存在,请重新输入')else:user = models.Users.objects.create(id=request.POST.get('id'),userName=request.POST.get('userName'),passWord=request.POST.get('userName'),name=request.POST.get('name'),gender=request.POST.get('gender'),age=request.POST.get('age'),type=1,)models.Teachers.objects.create(user=user,phone=request.POST.get('phone'),record=request.POST.get('record'),job=request.POST.get('job'))return BaseView.success()# 修改教师信息def updInfo(request):models.Teachers.objects. \filter(user__id=request.POST.get('id')).update(phone=request.POST.get('phone'),record=request.POST.get('record'),job=request.POST.get('job'))return BaseView.success()#删除教师信息@transaction.atomicdef delInfo(request):if models.Exams.objects.filter(teacher__id=request.POST.get('id')).exists():return BaseView.warn('存在关联记录无法移除')else:models.Users.objects.filter(id=request.POST.get('id')).delete()return BaseView.success()'''
学生信息处理
'''
class StudentsView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'page':return StudentsView.getPageInfos(request)elif module == 'info':return StudentsView.getInfo(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return StudentsView.addInfo(request)elif module == 'upd':return StudentsView.updInfo(request)elif module == 'del':return StudentsView.delInfo(request)else:return BaseView.error('请求地址不存在')# 获取指定学生信息def getInfo(request):student = models.Students.objects.filter(user__id=request.GET.get('id')).first()return BaseView.successData({'id': student.user.id,'userName': student.user.userName,'passWord': student.user.passWord,'name': student.user.name,'gender': student.user.gender,'gradeId': student.grade.id,'gradeName': student.grade.name,'collegeId': student.college.id,'collegeName': student.college.name,})#分页查询学生信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')collegeId = request.GET.get('collegeId')gradeId = request.GET.get('gradeId')qruery = Q();if SysUtil.isExit(name):qruery = qruery & Q(user__name__contains=name)if SysUtil.isExit(collegeId):qruery = qruery & Q(college__id=int(collegeId))if SysUtil.isExit(gradeId):qruery = qruery & Q(grade__id=int(gradeId))data = models.Students.objects.filter(qruery)paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.user.id,'userName': item.user.userName,'name': item.user.name,'gender': item.user.gender,'age': item.user.age,'type': item.user.type,'gradeId': item.grade.id,'gradeName': item.grade.name,'collegeId': item.college.id,'collegeName': item.college.name})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加学生信息@transaction.atomicdef addInfo(request):if models.Users.objects.filter(userName=request.POST.get('userName')).exists():return BaseView.warn('账号已存在,请重新输入')elif models.Users.objects.filter(id=request.POST.get('id')).exists():return BaseView.warn('学号已存在,请重新输入')else:user = models.Users.objects.create(id=request.POST.get('id'),userName=request.POST.get('userName'),passWord=request.POST.get('userName'),name=request.POST.get('name'),gender=request.POST.get('gender'),age=request.POST.get('age'),type=2,)models.Students.objects.create(user=user,grade=models.Grades.objects.get(id=request.POST.get('gradeId')),college=models.Colleges.objects.get(id=request.POST.get('collegeId')))return BaseView.success()# 修改学生信息def updInfo(request):models.Students.objects. \filter(user__id=request.POST.get('id')).update(grade=models.Grades.objects.get(id=request.POST.get('gradeId')),college=models.Colleges.objects.get(id=request.POST.get('collegeId')))return BaseView.success()#删除学生信息@transaction.atomicdef delInfo(request):if (models.ExamLogs.objects.filter(student__id=request.POST.get('id')).exists() |models.AnswerLogs.objects.filter(student__id=request.POST.get('id')).exists()):return BaseView.warn('存在关联记录无法移除')else:models.Users.objects.filter(id=request.POST.get('id')).delete()return BaseView.success()'''
习题信息处理
'''
class PractisesView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'page':return PractisesView.getPageInfos(request)elif module == 'info':return PractisesView.getInfo(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return PractisesView.addInfo(request)elif module == 'setanswer':return PractisesView.setAnswer(request)else:return BaseView.error('请求地址不存在')# 获取指定 ID 的习题信息def getInfo(request):practise = models.Practises.objects.filter(id=request.GET.get('id')).first()if practise.type==0:return  BaseView.successData({'id': practise.id,'name': practise.name,'answer': practise.answer,'analyse': practise.analyse,'type': practise.type,'createTime': practise.createTime,'projectId': practise.project.id,'projectName': practise.project.name,'options': list(models.Options.objects.filter(practise__id=practise.id).values())})else:return BaseView.successData({'id': practise.id,'name': practise.name,'answer': practise.answer,'analyse': practise.analyse,'type': practise.type,'createTime': practise.createTime,'projectId': practise.project.id,'projectName': practise.project.name,})#分页查询习题信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')type = request.GET.get('type')projectId = request.GET.get('projectId')qruery = Q();if SysUtil.isExit(name):qruery = qruery & Q(name__contains=name)if SysUtil.isExit(type):qruery = qruery & Q(type=int(type))if SysUtil.isExit(projectId):qruery = qruery & Q(project__id=int(projectId))data = models.Practises.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):if item.type==0:resl.append({'id': item.id,'name': item.name,'answer': int(item.answer) if SysUtil.isExit(item.answer) else '','analyse': item.analyse,'type': item.type,'projectId': item.project.id,'projectName': item.project.name,'createTime': item.createTime,'optionTotal': models.Options.objects.filter(practise__id=item.id).count()})else:resl.append({'id': item.id,'name': item.name,'answer': item.answer,'analyse': item.analyse,'type': item.type,'projectId': item.project.id,'projectName': item.project.name,'createTime': item.createTime,'optionTotal': 0})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)#添加习题信息def addInfo(request):models.Practises.objects.create(name=request.POST.get('name'),type=request.POST.get('type'),project=models.Projects.objects.get(id=request.POST.get('projectId')),createTime=DateUtil.getNowDateTime())return BaseView.success()#修改习题信息def setAnswer(request):models.Practises.objects. \filter(id=request.POST.get('id')).update(answer=request.POST.get('answer'),analyse=request.POST.get('analyse'))return BaseView.success()
'''
选项信息处理
'''
class OptionsView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'list':return OptionsView.getListByPractiseId(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return OptionsView.addInfo(request)elif module == 'upd':return OptionsView.updInfo(request)else:return BaseView.error('请求地址不存在')#依据习题编号获取选项信息def getListByPractiseId(request):options = models.Options.objects.filter(practise__id=request.GET.get('practiseId'))return BaseView.successData(list(options.values()))# 添加选项信息def addInfo(request):models.Options.objects.create(name=request.POST.get('name'),practise=models.Practises.objects.get(id=request.POST.get('practiseId')))return BaseView.success()#修改选项信息def updInfo(request):models.Options.objects. \filter(id=request.POST.get('id')).update(name=request.POST.get('name'))return BaseView.success()'''
考试信息处理
'''
class ExamsView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'page':return ExamsView.getPageInfos(request)elif module == 'info':return ExamsView.getInfo(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return ExamsView.addInfo(request)elif module == 'make':return ExamsView.createExamPaper(request)else:return BaseView.error('请求地址不存在')# 获取考试信息def getInfo(request):exam = models.Exams.objects.filter(id=request.GET.get('id')).first()return BaseView.successData({'id': exam.id,'name': exam.name,'createTime': exam.createTime,'examTime': exam.examTime,'teacherId': exam.teacher.id,'teacherName': exam.teacher.name,'projectId': exam.project.id,'projectName': exam.project.name,'gradeId': exam.grade.id,'gradeName': exam.grade.name,})#分页查询考试信息def getPageInfos(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)name = request.GET.get('name')gradeId = request.GET.get('gradeId')projectId = request.GET.get('projectId')teacherId = request.GET.get('teacherId')qruery = Q();if SysUtil.isExit(teacherId):qruery = qruery & Q(teacher__id=teacherId)if SysUtil.isExit(name):qruery = qruery & Q(name__contains=name)if SysUtil.isExit(gradeId):qruery = qruery & Q(grade__id=gradeId)if SysUtil.isExit(projectId):qruery = qruery & Q(project__id=projectId)data = models.Exams.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.id,'name': item.name,'examTime': item.examTime,'createTime': item.createTime,'projectId': item.project.id,'projectName': item.project.name,'teacherId': item.teacher.id,'teacherName': item.teacher.name,'gradeId': item.grade.id,'gradeName': item.grade.name,})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加考试信息def addInfo(request):if ExamUtils.CheckPractiseTotal.check(request.POST.get('projectId')):if models.Teachers.objects.filter(user__id=request.POST.get('teacherId')).exists():models.Exams.objects.create(name=request.POST.get('name'),examTime=request.POST.get('examTime'),project=models.Projects.objects.get(id=request.POST.get('projectId')),teacher=models.Users.objects.get(id=request.POST.get('teacherId')),grade=models.Grades.objects.get(id=request.POST.get('gradeId')),createTime=DateUtil.getNowDateTime())return BaseView.success()else:return BaseView.warn('指定工号的教师不存在')else:return BaseView.warn('相关题目数量不足,无法准备考试')# 生成考试试卷def createExamPaper(request):projectId = request.POST.get('projectId')paper = ExamUtils.MakeExam.make(projectId)return BaseView.successData(paper)'''
考试记录处理
'''
class ExamLogsView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'pagestu':return ExamLogsView.getPageStudentLogs(request)elif module == 'pagetea':return ExamLogsView.getPageTeacherLogs(request)elif module == 'info':return ExamLogsView.getInfo(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return ExamLogsView.addInfo(request)elif module == 'upd':return ExamLogsView.updInfo(request)elif module == 'put':return ExamLogsView.putExamLog(request)else:return BaseView.error('请求地址不存在')# 获取指定考试记录def getInfo(request):examLogs = models.ExamLogs.objects.filter(id=request.GET.get('id')).first()answers = []qruery = Q();qruery = qruery & Q(student__id=request.GET.get('studentId'))qruery = qruery & Q(exam__id=examLogs.exam.id)temps = models.AnswerLogs.objects.filter(qruery).order_by('no')for item in temps:answers.append({'id': item.id,'score': item.score,'status': item.status,'answer': item.answer,'no': item.no,'practiseId': item.practise.id,'practiseName': item.practise.name,'practiseAnswer': item.practise.answer,'practiseAnalyse': item.practise.analyse,'options': list(models.Options.objects.filter(id=item.practise.id).values()),})return BaseView.successData({'id': examLogs.id,'status': examLogs.status,'score': examLogs.score,'createTime': examLogs.createTime,'examId': examLogs.exam.id,'examName': examLogs.exam.name,'projectId': examLogs.exam.project.id,'projectName': examLogs.exam.project.name,'teacherId': examLogs.exam.teacher.id,'teacherName': examLogs.exam.teacher.name,'gradeId': examLogs.exam.grade.id,'gradeName': examLogs.exam.grade.name,'answers': answers})# 分页获取学生考试记录def getPageStudentLogs(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)examName = request.GET.get('examName')studentId = request.GET.get('studentId')projectId = request.GET.get('projectId')qruery = Q(student__id=studentId);if SysUtil.isExit(examName):qruery = qruery & Q(exam__name__contains=examName);if SysUtil.isExit(projectId):qruery = qruery & Q(exam__project__id=projectId)data = models.ExamLogs.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.id,'status': item.status,'createTime': item.createTime,'score': item.score,'examId': item.exam.id,'examName': item.exam.name,'teacherId': item.exam.teacher.id,'teacherName': item.exam.teacher.name,'projectId': item.exam.project.id,'projectName': item.exam.project.name,})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 分页获取教师审核记录def getPageTeacherLogs(request):pageIndex = request.GET.get('pageIndex', 1)pageSize = request.GET.get('pageSize', 10)examName = request.GET.get('examName')token = request.GET.get('token')gradeId = request.GET.get('gradeId')projectId = request.GET.get('projectId')qruery = Q(exam__teacher__id=cache.get(token));if SysUtil.isExit(examName):qruery = qruery & Q(exam__name__contains=examName)if SysUtil.isExit(gradeId):qruery = qruery & Q(exam__grade__id=gradeId)if SysUtil.isExit(projectId):qruery = qruery & Q(exam__project__id=projectId)data = models.ExamLogs.objects.filter(qruery).order_by('-createTime')paginator = Paginator(data, pageSize)resl = []for item in list(paginator.page(pageIndex)):resl.append({'id': item.id,'status': item.status,'createTime': item.createTime,'score': item.score,'examId': item.exam.id,'examName': item.exam.name,'studentId': item.student.id,'studentName': item.student.name,'projectId': item.exam.project.id,'projectName': item.exam.project.name,'gradeId': item.exam.grade.id,'gradeName': item.exam.grade.name,})pageData = BaseView.parasePage(int(pageIndex), int(pageSize),paginator.page(pageIndex).paginator.num_pages,paginator.count, resl)return BaseView.successData(pageData)# 添加考试记录def addInfo(request):models.ExamLogs.objects.create(student=models.Users.objects.get(id=cache.get(request.POST.get('token'))),exam=models.Exams.objects.get(id=request.POST.get('examId')),status=0,score=0,createTime=DateUtil.getNowDateTime())return BaseView.success()# 修改考试记录def updInfo(request):models.ExamLogs.objects. \filter(id=request.POST.get('id')).update(status=request.POST.get('status'))return BaseView.success()# 公布学生考核成绩def putExamLog(request):studentId = request.POST.get('studentId')examId = request.POST.get('examId')qruery = Q(student__id=studentId)qruery = qruery & Q(exam__id=examId)total = 0.0answers = models.AnswerLogs.objects.filter(qruery)for item in answers:if item.practise.type==0:temp = 2 if item.practise.answer==item.answer else 0total = total + tempmodels.AnswerLogs.objects. \filter(id=item.id).update(status=1,score = temp)elif item.practise.type==1:total = total + item.scoreelif item.practise.type==2:temp = 2 if item.practise.answer==item.answer else 0total = total + tempmodels.AnswerLogs.objects. \filter(id=item.id).update(status=1,score = temp)elif item.practise.type==3:total = total + item.scoremodels.ExamLogs.objects. \filter(qruery).update(status=2,score=total)return BaseView.success()'''
答题记录处理
'''
class AnswerLogsView(BaseView):def get(self, request, module, *args, **kwargs):if module == 'info':return AnswerLogsView.getInfo(request)elif module == 'answers':return AnswerLogsView.getAnswers(request)elif module == 'check':return AnswerLogsView.checkAnswers(request)else:return BaseView.error('请求地址不存在')def post(self, request, module, *args, **kwargs):if module == 'add':return AnswerLogsView.addInfo(request)elif module == 'audit':return AnswerLogsView.aduitAnswer(request)else:return BaseView.error('请求地址不存在')# 获取指定答题记录def getInfo(request):pass# 获取指定的答案列表def getAnswers(request):studentId = request.GET.get('studentId')type = request.GET.get('type')examId = request.GET.get('examId')qruery = Q(student__id=studentId);qruery = qruery & Q(exam__id=examId)resl = []data = models.AnswerLogs.objects.filter(qruery).order_by('no')for item in data:if item.practise.type == int(type):resl.append({'id': item.id,'practiseId': item.practise.id,'practiseName': item.practise.name,'practiseAnswer': item.practise.answer,'answer': item.answer,'score': item.score,'status': item.status,'no': item.no})elif item.practise.type == int(type):resl.append({'id': item.id,'practiseId': item.practise.id,'practiseName': item.practise.name,'practiseAnswer': item.practise.answer,'answer': item.answer,'score': item.score,'status': item.status,'no': item.no})return BaseView.successData(resl)#按照类型检查答题def checkAnswerType(studentId, examId, type):qruery = Q(student__id=studentId)qruery = qruery & Q(exam__id=examId)qruery = qruery & Q(status=0)qruery = qruery & Q(practise__type=type)return models.AnswerLogs.objects.filter(qruery).exists()# 检查手动审核题目def checkAnswers(request):studentId = request.GET.get('studentId')examId = request.GET.get('examId')qruery = Q(student__id=studentId)qruery = qruery & Q(exam__id=examId)qruery = qruery & Q(status=0)qruery = qruery & Q(practise__type=1)qruery = qruery | Q(practise__type=3)if AnswerLogsView.checkAnswerType(studentId, examId, 1):return BaseView.successData({'flag': True, 'msg': '填空题还有未审核的内容'})elif AnswerLogsView.checkAnswerType(studentId, examId, 3):return BaseView.successData({'flag': True, 'msg': '编程题还有未审核的内容'})else:return BaseView.successData({'flag': False, 'msg': '手动审核部分已完成'})# 添加答题记录@transaction.atomicdef addInfo(request):answers = request.POST.getlist('answers')nos = request.POST.getlist('nos')practiseIds = request.POST.getlist('practiseIds')examId = request.POST.get('examId')token = request.POST.get('token')for no in nos:models.AnswerLogs.objects.create(student=models.Users.objects.get(id=cache.get(token)),exam=models.Exams.objects.get(id=examId),practise=models.Practises.objects.get(id=practiseIds[int(no)-1]),status=0,answer=answers[int(no)-1],no=no)qruery = Q(exam__id=examId);qruery = qruery & Q(student__id=cache.get(token))models.ExamLogs.objects. \filter(qruery).update(status=1)return BaseView.success()# 审核答题def aduitAnswer(request):if int(request.POST.get('type'))==1:models.AnswerLogs.objects. \filter(id=request.POST.get('id')).update(status=1,score=2 if int(request.POST.get('flag'))==0 else 0,)else:models.AnswerLogs.objects. \filter(id=request.POST.get('id')).update(status=1,score=20 if int(request.POST.get('flag'))==0 else 0,)return BaseView.success()
<template><div class="login-body"><div class="login-win"><div class="login-form"><Form ref="loginForm" :rules="rules" :model="loginForm" :label-width="90"><FormItem prop="userName"><Input v-model="loginForm.userName" placeholder="请输入您的账号..."></Input></FormItem><FormItem prop="passWord"><Input type="password" v-model="loginForm.passWord" placeholder="请输入您的密码..."></Input></FormItem><FormItem style="margin-top: 50px;"><Button style="width:226px;" @click="submitForm('loginForm')"  class="login-btn" type="primary">用户登陆</Button></FormItem></Form></div></div></div>
</template><style>
.login-body{background-color: #2db7f5;background-image: url(../assets/2.jpg);position: fixed;left: 0;top: 0;bottom: 0;right: 0;
}
.login-win{position: absolute;top: 45%;left: 50%;transform: translate(-50%, -50%);width: 600px;height: 330px;padding: 15px;border-radius: 5px;border: 2px solid #fff;background-image: url('../assets/1.jpg');background-size: cover;
}
.login-form{position: absolute;left: 40%;top: 30%;width: 320px;
}
</style><script>
import initMenu from "../utils/menus.js";
import { login } from '../api/index.js';
export default {data() {return {loginForm: {userName: '',passWord: '',},rules: {userName: [{ required: true, message: '用户账号必须输入', trigger: 'blur' }],passWord: [{ required: true, message: '用户密码必须输入', trigger: 'blur' }],}}},methods: {submitForm (formName) {this.$refs[formName].validate((valid) => {if (valid) {login(this.loginForm).then(res => {if(res.code == 0){this.$store.commit('setToken', res.data.token);sessionStorage.setItem("token", res.data.token);initMenu(this.$router, this.$store);this.$router.push('/welcome');}else{this.$Message.warning(res.msg);}});} else {return false;}})}},
}
</script>

源码代码

链接:https://pan.baidu.com/s/10b83UvwFEA9b_47VJcJRMg 
提取码:1234

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/59205.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Unity3D学习FPS游戏(9)武器音效添加、创建敌人模型和血条

前言&#xff1a;虽然已经实现了基本玩家操作&#xff0c;但是游戏运行起来并没有音效。既然是FPS游戏有了玩家和武器&#xff0c;肯定还得有敌人。本篇演示如何给武器添加音效和创建敌人。 武器音效添加和创建敌人 武器音效添加Audio Source代码控制 创建敌人目标敌人模型敌人…

C 语言编程中的常见错误及解决方案

在 C 语言开发中&#xff0c;编译和链接错误是常见的问题&#xff0c;尤其是在处理多个源文件时。本文将总结一些常见的错误&#xff0c;并提供相应的解决方案&#xff0c;以帮助开发者更高效地排查和修复这些问题。 1. 结构体作用域问题 问题描述 在函数参数列表中定义结构体…

Kubernetes运行大数据组件-运行spark

在Kubernetes上运行Spark作业&#xff0c;你需要创建一个Spark的部署和相应的Kubernetes资源。以下是一个简化的例子&#xff0c;展示了如何使用Kubernetes部署Spark Driver和Executor。 首先&#xff0c;确保你有一个运行中的Kubernetes集群&#xff0c;并且kubectl 命令行工…

雷池社区版新版本功能防绕过人机验证解析

前两天&#xff0c;2024.10.31&#xff0c;雷池社区版更新7.1版本&#xff0c;其中有一个功能&#xff0c;新增请求防重放 更新记录&#xff1a;hhttps://docs.waf-ce.chaitin.cn/zh/%E7%89%88%E6%9C%AC%E6%9B%B4%E6%96%B0%E8%AE%B0%E5%BD%95 仔细研究了这个需求&#xff0c;…

PyCharm中pylint安装与使用

目录 1. 安装插件2. pycharm中使用该功能3. 命令行使用 1. 安装插件 然后重启 2. pycharm中使用该功能 3. 命令行使用 前提是先 pip install pylint pylint demo01.py下面红框内容的意思是&#xff0c;得到10分/ 满分10分&#xff0c;上次运行获得8.33分&#xff0c;经调整…

conda下安装volitility3

在github下载zip压缩包并解压。 创建虚拟环境 (base) C:\WINDOWS\system32>conda create -n volatility3 python3.8 激活虚拟环境 (base) C:\WINDOWS\system32>conda activate volatility3 安装工具所需要的依赖 (volatility3) C:\WINDOWS\system32>cd /d D:\CT…

IDEA加载通义灵码插件及使用指南

安装通义灵码插件 登录通义灵码IDE插件 下载登录参考教程 https://help.aliyun.com/zh/lingma/user-guide/download-the-installation-guide 本地工程和企业知识库准备 请下载本地工程和知识库压缩包&#xff0c;并在本地解压缩&#xff0c;其中包含demoProject和知识库文件…

Java入门(7)--网络编程

Java网络编程&#xff1a;构建网络应用的基石 &#x1f310; &#x1f3af; 掌握Java网络编程&#xff0c;打造强大的网络应用&#xff01; 在上一篇文章中&#xff0c;我们探讨了Java的I/O操作和反射机制。今天&#xff0c;让我们深入学习Java网络编程&#xff0c;了解如何构建…

只因把 https 改成 http,带宽减少了 70%!

起因 是一个高并发的采集服务上线后&#xff0c;100m的上行很快就被打满了。因为这是一条专线&#xff0c;并且只有这一个服务在使用&#xff0c;所以可以确定就是它导致的。 但是&#xff01;这个请求只是一个 GET 请求&#xff0c;同时并没有很大的请求体&#xff0c;这是为…

黑马官网最新2024前端就业课V8.5笔记---CSS篇(2)

盒子模型 画盒子 目标:使用合适的选择器画盒子 属性 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"view…

认识单双链表

认识单双链表 前置知识&#xff1a;无&#xff0c;会的可以直接跳过。 基本概念 内存空间是所有程序的公共资源&#xff0c;在一个复杂的系统运行环境下&#xff0c;空闲的内存空间可能散落在内存各处。我们知道&#xff0c;存储数组的内存空间必须是连续的&#xff0c;而当…

导师双选系统开发新解:Spring Boot技术

摘 要 如今的信息时代&#xff0c;对信息的共享性&#xff0c;信息的流通性有着较高要求&#xff0c;因此传统管理方式就不适合。为了让导师选择信息的管理模式进行升级&#xff0c;也为了更好的维护导师选择信息&#xff0c;卓越导师双选系统的开发运用就显得很有必要。并且通…

木马病毒相关知识

1、 木马的定义 相当于一个远控程序&#xff08;一个控制端[hack]、一个被控端[受害端]&#xff09; 在计算机系统中&#xff0c;“特洛伊木马”指系统中被植入的、人为设计的程序&#xff0c;目的包括通过网终远程控制其他用户的计算机系统&#xff0c;窃取信息资料&#xff0…

Oracle简介、环境搭建和基础DML语句

第一章 ORACLE 简介 1.1 什么是 ORACLE ORACLE数据库系统是美国ORACLE 公司&#xff08;甲骨文&#xff09;提供的以分布式数据库为核心的一组软件产品&#xff0c;是目前最流行的客户/服务器体系结构的数据库之一。 英文官网&#xff1a;Database | Oracle 中文官网&#xff…

【React】初学React

A. react中如何创建元素呢&#xff1f; 说明一点&#xff1a; 属性都改为驼峰形式&#xff08;无障碍属性aria-*除外&#xff09;&#xff0c; class改成className 创建元素 B. 变量或表达式如何表示呢&#xff1f;大括号{ }包起来 变量值用大括号包裹 C. 元素和组件的区别 元素…

GD32H7XX软件触发中断

这个在demo里没找到&#xff0c;有相关编程要求的可以直接套用。 先简单阐述一下&#xff0c;实际上就是用几个位来控制一根软件触发通道的中断情况。以GD32H7系列为例&#xff0c;中断使能寄存器EXTI_INTEN就是是否允许这条线启用中断&#xff0c;和平时的enableDMA一个意思。…

Leetcode 第 422 场周赛题解

Leetcode 第 422 场周赛题解 Leetcode 第 422 场周赛题解题目1&#xff1a;3340. 检查平衡字符串思路代码复杂度分析 题目2&#xff1a;3341. 到达最后一个房间的最少时间 I思路代码复杂度分析 题目3&#xff1a;3342. 到达最后一个房间的最少时间 II思路代码复杂度分析 题目4&…

Memento 备忘录模式

备忘录模式 意图结构适用性实例Java Web开发中的简单示例Originator 类Memento 类Caretaker 类 文本编辑器示例1. Originator (发起人) - TextEditor2. Memento (备忘录) - TextMemento3. Caretaker (负责人) - History4. 使用示例输出 备忘录模式&#xff08;Memento Pattern&…

导入项目时微信开发者工具如何自动识别项目APPID

一、需求 当我们在公司拉取小程序项目的时候&#xff0c;经常会在微信开发者工具中导入项目&#xff0c;需要我们手动输入自己的appid非常麻烦&#xff0c;我们可以用在导入项目的时候自动识别公司的appid 二、步骤 2.1 使用Hbuilder工具编译项目 编译成功后会有一个unpacka…

小语言模型介绍与LLM的比较

小模型介绍 小语言模型&#xff08;SLM&#xff09;与大语言模型&#xff08;LLM&#xff09;相比&#xff0c;具有不同的特点和应用场景。大语言模型通常拥有大量的参数&#xff08;如 GPT-3 拥有 1750 亿个参数&#xff09;&#xff0c;能够处理复杂的自然语言任务&#xff…