This commit is contained in:
nopy 2024-07-10 13:59:29 +08:00
commit 8f821edb7e
9 changed files with 136 additions and 60 deletions

View File

@ -11,10 +11,9 @@ function TrainPods(){
const FindPodsFunc=await axios.post('/api/teacher/list_pods')
setPods(FindPodsFunc.data)
}catch{
alert('出错')
}
}
useEffect(()=>{
FindPodsFunc()
},[])
@ -25,8 +24,7 @@ function TrainPods(){
name,
})
alert('删除成功')
// eslint-disable-next-line no-restricted-globals
location.reload();
window.location.reload();
}catch{
alert('出错')
}
@ -42,11 +40,9 @@ function TrainPods(){
setSrcData(FindSrcc.data['data'])
setisTrue(false)
}catch{
alert('SrcDAta出错')
alert('SrcData出错')
}
}
// // eslint-disable-next-line no-restricted-globals
//
return(
<div className='body-right-Pods'>
@ -93,9 +89,6 @@ function TrainPods(){
</div>
<button onClick={()=>setisTrue(!isTrue)} style={{marginLeft:'600px'}} className='srcbtn'>返回</button>
</table>}
<button onClick={()=>{
console.log(Pods);
}}></button>
</div>
)
}

View File

@ -113,3 +113,17 @@
font-size: 14px;
margin-left: 52px;
}
.TrainBox{
width: 1000px;
height: 500px;
background-color: aqua;
}
.TrainBox table{
margin-top: 200px;
margin-left: 400px;
width: 500px;
text-align: center;
border: 1px solid black;
}
.TrainBox th{
}

View File

@ -6,9 +6,12 @@ import React, { useEffect, useState } from 'react';
function TrainManage(){
const teacher_ID=localStorage.getItem('islogin')
const [isTrue,setisTrue]=useState(false)
const [Data,setData]=useState([])
const [showModal, setShowModal] = useState(false);
const [showModal, setShowModal] = useState(true);
const [selectedTrain, setSelectedTrain] = useState(null);
const [testID,settestID]=useState()
const [TrainData,setTrainData]=useState()
//
const getTrainfunc=async()=>{
try{
@ -25,11 +28,30 @@ function TrainManage(){
getTrainfunc()
},[])
const getTrainData=async ()=>{
try{
const getTrainDataSrc=await axios.post('/api/teacher/getTrainData',{
testID
})
setTrainData(getTrainDataSrc.data['data'])
}catch{
alert('getTrainData出错')
}
}
useEffect(()=>{
if(isTrue){
getTrainData()
}else{
setisTrue(true)
}
},[testID])
const Click=(testID,train)=>{
settestID(testID)
setSelectedTrain(train)
}
const handleTrainClick = (train) => {
setSelectedTrain(train);
setShowModal(true);
};
return(
<div className='body-trainmanage'>
@ -38,7 +60,7 @@ function TrainManage(){
{Data&&<div className='train-list-trainmanage'>
<ul className="ul-trainmanage">
{Object.keys(Data).map((key)=>(
<li key={key} onClick={() => handleTrainClick(key)}>
<li key={key} onClick={()=>Click(Data[key][10],eval(Data[key][11]))}>
<span>实训ID:{Data[key][10]}</span>
<h6 className='TrainTitle'>实训名称:{eval(Data[key][11])}</h6>
<p>关闭时间{Data[key][6]}</p>
@ -48,41 +70,30 @@ function TrainManage(){
<Link to='/teacher/trainmanage/TrainPods' className='ManagePods' >管理实训</Link>
<Link to='/teacher/SendTrain' className='sendtestpage'>发布实训</Link>
</div>}
{/* 弹窗组件 */}
{showModal && (
<div className='modal'>
<div className='modal-content'>
<span className='close' onClick={() => setShowModal(false)}>&times;</span>
<h2>实训信息</h2>
<table>
<thead>
<tr>
<th>实训ID</th>
<th>实训名称</th>
<th>学号</th>
<th>基础成绩</th>
<th>实训成绩</th>
<th>总成绩</th>
</tr>
</thead>
<tbody>
{selectedTrain && selectedTrain.students.map((student, index) => (
<tr key={index}>
<td>{selectedTrain[10]}</td>
<td>{eval(selectedTrain[11])}</td>
<td>{student.studentID}</td>
<td>{student.baseScore}</td>
<td>{student.trainScore}</td>
<td>{student.totalScore}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
<div className='TrainBox'>
<table>
<thead>
<tr>
<th>姓名</th>
<th>ID</th>
<th>基础成绩</th>
<th>实训成绩</th>
<th>总成绩</th>
</tr>
</thead>
<tbody>
{Object.keys(TrainData).map((key)=>(
<tr key={key}>
<td>{key}</td>
<td>{TrainData[key][0]}</td>
<td>{TrainData[key][4]}</td>
<td>{TrainData[key][5]}</td>
<td>{parseInt(TrainData[key][4])+parseInt(TrainData[key][5])}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)

View File

@ -43,7 +43,7 @@ function HeaderNavTeacher() {
</div>
<div className='left-nav-li'>
<ul>
{[{name:'班级管理',path:'/teacher',ImgSrc:ClassManage},{name:'实训管理',path:'/teacher/trainmanage',ImgSrc:Send},{name:'批改',path:'/teacher/mark',ImgSrc:Mark},{name:'考试管理',path:'/teacher/managetest',ImgSrc:SubjectManage},{name:'题库管理',path:'questionmange',ImgSrc:Question},{name:'设置',ImgSrc:Set,onClick:handleSettingsClick}].map((item)=>
{[{name:'班级管理',path:'/teacher',ImgSrc:ClassManage},{name:'实训管理',path:'/teacher/trainmanage',ImgSrc:Send},{name:'批改',path:'/teacher/mark',ImgSrc:Mark},{name:'考试管理',path:'/teacher/managetest',ImgSrc:SubjectManage},{name:'题库管理',path:'questionmange',ImgSrc:Question},{name:'设置',ImgSrc:Set,onClick:handleSettingsClick}].map((item)=>
<li onClick={item.onClick}>
<div className='nav-li-box'>
<Link to={item.path} className="custom-link-home" style={{color:'black'}}>

View File

@ -15,6 +15,7 @@ function Operation2() {
const score=localStorage.getItem('score')
const { operateID } = useParams();
const [isTrue,setisTrue]=useState(false)
const [TrainScore,serTrainScore]=(null)
const TrainData=JSON.parse(localStorage.getItem('TrainData'))
@ -91,7 +92,21 @@ function Operation2() {
//
const [isSubjectDropdownOpen, setIsSubjectDropdownOpen] = useState(false);
const submitTrain=async()=>{
try{
const submitTrainSrc=await axios.post('/api/student/EntryTrainScore',{
score,
TrainScore,
operateID,
student_ID
})
}catch{
alert('submitTrainSrc出错')
}
}
const tijiao = ()=>{
submitTrain()
setCountdown(0)
localStorage.removeItem('time')
localStorage.removeItem('choice_answers');
@ -117,8 +132,10 @@ function Operation2() {
const result=detectionSrc.data['result']
if(result==='NO'){
alert('连接失败')
TrainScore(0)
}else{
alert('连接成功')
TrainScore(50)
}
}catch{
alert('detection出错')

View File

@ -4,7 +4,7 @@ module.exports = function(app) {
app.use(
'/api', // 如果请求路径匹配'/api',则进行代理
createProxyMiddleware({
target: 'http://127.0.0.1:5000s', // 目标后端服务地址
target: 'http://127.0.0.1:5000', // 目标后端服务地址
changeOrigin: true,
})
);

View File

@ -135,7 +135,6 @@ def fetch_result():
@app.route('/api/student/score_entry', methods=['POST'])
def score_entry():
data = request.json
@ -176,6 +175,14 @@ def FindTrain1Src():
result=FindTrain1SrcFunc(ID,testID)
return jsonify({'Src':result})
@app.route('/api/student/EntryTrainScore',methods=['POST'])
def EntryTrainScore():
score=request.json['score']
TrainScore=request.json['trainScore']
operateID=request.json['operateID']
student_ID=request.json['student_ID']
AddTrainScoreFunc(score,TrainScore,student_ID,operateID)
return jsonify({'result': '成功'})
# 以下为教师功能—————————————————————————————————————————————————————————————————————
@ -294,6 +301,8 @@ def GetTrain():
data=getTrainFunc(teacherID)
return jsonify({'data':data})
@app.route('/api/teacher/FindSrc',methods=["POST"])
def FindSrc():
testID=request.json['key']
@ -329,6 +338,14 @@ def appendQuestion():
appendQuestionFunc(subject,chapter,inputValue,A,B,C,D,correct,judgeValue)
return '添加成功'
@app.route('/api/teacher/getTrainData',methods=["POST"])
def getTrainData():
testID=request.json['testID']
print(testID)
data = getTrainDataFunc(testID)
return jsonify({'data': data})
# @app.route("/api/teacher/list_pods",methods=['POST']) # 列出pod
@ -337,11 +354,11 @@ def appendQuestion():
# @app.route("/api/teacher/list_services") # 列出服务
# def teacher_list_services():
# return list_services()
#
# # @app.route("/api/teacher/create_pod") # 创建服务 1为项目实训 0为安装实训
# # def teacher_create_pod():
# # create_pod(1, "test2")
#
# @app.route("/api/teacher/create_pod") # 创建服务 1为项目实训 0为安装实训
# def teacher_create_pod():
# create_pod(1, "test2")
# @app.route("/api/teacher/DelPods",methods=['POST']) # 删除服务
# def teacher_delete_pod():
# name=request.json['name']
@ -349,7 +366,7 @@ def appendQuestion():
# testID=name[10:]
# delDMFunc(studentID,testID)
# return delete_pod(name=name)
#
# @app.route("/api/student/check_pod",methods=['POST']) # 检测数据库是否安装成功 若成功返回OK 否则返回NO
# def teacher_check_pod():
# name=request.json["student_ID"]

View File

@ -342,6 +342,12 @@ def FindTrain1SrcFunc(ID,testID):
# FindTrain1SrcFunc('20240101','54')
def AddTrainScoreFunc(ID,testID,score,trainResult):
cursor=db.cursor()
cursor.execute("UPDATE TRAINSCORE SET TF='true', RESULT=(?), TRAINRESULT=(?) WHERE STUDENT_ID=(?) AND TEST_ID=(?)",(score,trainResult,ID,testID))
db.commit()
cursor.close()
return '添加成功'

View File

@ -455,3 +455,21 @@ def appendQuestionFunc(subject,chapter,inputValue,A,B,C,D,correct,judgeValue):
print('插入成功')
return 'INSERT'
def getTrainDataFunc(testID):
dic={}
cursor = db.cursor()
cursor.execute(f'SELECT * FROM TRAINSCORE WHERE TEST_ID=? ',(testID,))
data = cursor.fetchall()
for i in data:
cursor.execute(f'SELECT NAME FROM STUDENT WHERE ID=? ', (i[0],))
name=cursor.fetchall()[0][0]
dic[name]=i
print(dic)
cursor.close()
return dic
# getTrainDataFunc('71')