[免费]基于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代码控制 创建敌人目标敌人模型敌人…

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

前两天&#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;经调整…

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

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

只因把 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;而当…

木马病毒相关知识

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. 元素和组件的区别 元素…

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…

17.快递物流仓库管理系统(基于springboot和vue)

目录 1.系统的受众说明 2.系统详细设计 2.1 需求分析 2.2 系统功能设计 2.3 开发环境分析 ​​​​​​​2.4 E-R图设计 2.5 数据库设计 3. 系统实现 3.1 环境搭建 ​​​​​​​3.2 员工信息管理模块 3.3 销售订单信息管理模块 ​​​​​​​3.4 图表分析模块…

Shortcut Learning in In-Context Learning: A Survey

为我们的综述打一打广告&#xff0c;目前是初级版本&#xff0c;欢迎各位批评指正&#xff01;后续的论文列表、测评基准会在Github更新[/(ㄒoㄒ)/~~最近比较忙容许我拖一拖] 这里是arxiv链接&#xff1a;Linking!!! Abstract&#xff1a;捷径学习是指模型在实际任务中使用简单…

第三十四章 Vue路由进阶之声明式导航(导航高亮)

目录 一、导航高亮 1.1. 基于语法 1.2. 主要代码 二、声明式导航的两个类名 2.1. 声明式导航类名匹配方式 2.2. 声明式导航类名样式自定义 ​2.3. 核心代码 一、导航高亮 1.1. 基于语法 在Vue中通过VueRouter插件&#xff0c;我们可以非常简单的实现实现导航高亮效果…

第七部分:1. STM32之ADC实验--单通道实验

主要利用一个模拟量的电位器来实时改变电压值&#xff0c;通过STM32自带的ADC通道来采集这个数据&#xff0c;并打印出来&#xff01; 一句话&#xff0c;学完STM32&#xff0c;我就往南走&#xff0c;我的工资只有5000.~~~~Whappy

Ubuntu20.04两种安装及配置中文界面、输入法、换源、共享文件夹实现,及注意事项

虚拟机安装法 1、新建虚拟机&#xff0c;自定义下一步 任意指定路径 提高处理器数量能加快系统响应 完成以后不要运行&#xff0c;添加镜像文件 导入镜像文件&#xff0c;点击浏览 选择后打开->确认->运行虚拟机 出现这种情况就需要检查虚拟机的配置&#xff0c;操作系统…

记录解决vscode 登录leetcode中遇到的问题

1. 安装完 leetcode 点击sign in to leetcode 点击打开网站登录leetcode&#xff0c;发现网页无法打开。 解决办法&#xff1a;将leetcode.cn.js文件中的leetcode-cn.com路径都改成leetcode.cn 2. 继续点击 sign in to leetcode &#xff0c;选择使用账号登录&#xff0c;始…

docker镜像仓库实战

docker镜像仓库实战 搭建一个nginx服务基础知识(Web服务器)查找nginx镜像拉取镜像启动nginx镜像 搭建一个nginx服务 基础知识(Web服务器) Web 服务器&#xff0c;一般是指“网站服务器”&#xff0c;是指驻留于互联网上某种类型计算机的程序。Web 服务器可以向 Web 浏览器等客…