123
This commit is contained in:
parent
0dc1bba456
commit
69ebafcceb
|
@ -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{
|
||||
}
|
|
@ -6,8 +6,9 @@ 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()
|
||||
|
@ -39,16 +40,19 @@ function TrainManage(){
|
|||
}
|
||||
|
||||
useEffect(()=>{
|
||||
getTrainData()
|
||||
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'>
|
||||
<p className='title'>已结束的实训</p>
|
||||
|
@ -56,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>
|
||||
|
@ -66,42 +70,33 @@ 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)}>×</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>
|
||||
<button onClick={()=>{
|
||||
console.log(TrainData);
|
||||
}}></button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -342,11 +342,9 @@ def appendQuestion():
|
|||
def getTrainData():
|
||||
testID=request.json['testID']
|
||||
print(testID)
|
||||
if testID:
|
||||
data = getTrainDataFunc(testID)
|
||||
return jsonify({'data': data})
|
||||
else:
|
||||
pass
|
||||
data = getTrainDataFunc(testID)
|
||||
return jsonify({'data': data})
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -456,10 +456,20 @@ def appendQuestionFunc(subject,chapter,inputValue,A,B,C,D,correct,judgeValue):
|
|||
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 data
|
||||
return dic
|
||||
|
||||
# getTrainDataFunc('71')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue