asd
This commit is contained in:
commit
8f821edb7e
|
@ -11,10 +11,9 @@ function TrainPods(){
|
||||||
const FindPodsFunc=await axios.post('/api/teacher/list_pods')
|
const FindPodsFunc=await axios.post('/api/teacher/list_pods')
|
||||||
setPods(FindPodsFunc.data)
|
setPods(FindPodsFunc.data)
|
||||||
}catch{
|
}catch{
|
||||||
|
alert('出错')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
FindPodsFunc()
|
FindPodsFunc()
|
||||||
},[])
|
},[])
|
||||||
|
@ -25,8 +24,7 @@ function TrainPods(){
|
||||||
name,
|
name,
|
||||||
})
|
})
|
||||||
alert('删除成功')
|
alert('删除成功')
|
||||||
// eslint-disable-next-line no-restricted-globals
|
window.location.reload();
|
||||||
location.reload();
|
|
||||||
}catch{
|
}catch{
|
||||||
alert('出错')
|
alert('出错')
|
||||||
}
|
}
|
||||||
|
@ -42,11 +40,9 @@ function TrainPods(){
|
||||||
setSrcData(FindSrcc.data['data'])
|
setSrcData(FindSrcc.data['data'])
|
||||||
setisTrue(false)
|
setisTrue(false)
|
||||||
}catch{
|
}catch{
|
||||||
alert('SrcDAta出错')
|
alert('SrcData出错')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // eslint-disable-next-line no-restricted-globals
|
|
||||||
//
|
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div className='body-right-Pods'>
|
<div className='body-right-Pods'>
|
||||||
|
@ -93,9 +89,6 @@ function TrainPods(){
|
||||||
</div>
|
</div>
|
||||||
<button onClick={()=>setisTrue(!isTrue)} style={{marginLeft:'600px'}} className='srcbtn'>返回</button>
|
<button onClick={()=>setisTrue(!isTrue)} style={{marginLeft:'600px'}} className='srcbtn'>返回</button>
|
||||||
</table>}
|
</table>}
|
||||||
<button onClick={()=>{
|
|
||||||
console.log(Pods);
|
|
||||||
}}></button>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,3 +113,17 @@
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-left: 52px;
|
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,9 +6,12 @@ import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
function TrainManage(){
|
function TrainManage(){
|
||||||
const teacher_ID=localStorage.getItem('islogin')
|
const teacher_ID=localStorage.getItem('islogin')
|
||||||
|
const [isTrue,setisTrue]=useState(false)
|
||||||
const [Data,setData]=useState([])
|
const [Data,setData]=useState([])
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(true);
|
||||||
const [selectedTrain, setSelectedTrain] = useState(null);
|
const [selectedTrain, setSelectedTrain] = useState(null);
|
||||||
|
const [testID,settestID]=useState()
|
||||||
|
const [TrainData,setTrainData]=useState()
|
||||||
//获取发布的实训
|
//获取发布的实训
|
||||||
const getTrainfunc=async()=>{
|
const getTrainfunc=async()=>{
|
||||||
try{
|
try{
|
||||||
|
@ -25,11 +28,30 @@ function TrainManage(){
|
||||||
getTrainfunc()
|
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(
|
return(
|
||||||
<div className='body-trainmanage'>
|
<div className='body-trainmanage'>
|
||||||
|
@ -38,7 +60,7 @@ function TrainManage(){
|
||||||
{Data&&<div className='train-list-trainmanage'>
|
{Data&&<div className='train-list-trainmanage'>
|
||||||
<ul className="ul-trainmanage">
|
<ul className="ul-trainmanage">
|
||||||
{Object.keys(Data).map((key)=>(
|
{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>
|
<span>实训ID:{Data[key][10]}</span>
|
||||||
<h6 className='TrainTitle'>实训名称:{eval(Data[key][11])}</h6>
|
<h6 className='TrainTitle'>实训名称:{eval(Data[key][11])}</h6>
|
||||||
<p>关闭时间:{Data[key][6]}</p>
|
<p>关闭时间:{Data[key][6]}</p>
|
||||||
|
@ -48,41 +70,30 @@ function TrainManage(){
|
||||||
<Link to='/teacher/trainmanage/TrainPods' className='ManagePods' >管理实训</Link>
|
<Link to='/teacher/trainmanage/TrainPods' className='ManagePods' >管理实训</Link>
|
||||||
<Link to='/teacher/SendTrain' className='sendtestpage'>发布实训</Link>
|
<Link to='/teacher/SendTrain' className='sendtestpage'>发布实训</Link>
|
||||||
</div>}
|
</div>}
|
||||||
|
<div className='TrainBox'>
|
||||||
|
|
||||||
{/* 弹窗组件 */}
|
|
||||||
{showModal && (
|
|
||||||
<div className='modal'>
|
|
||||||
<div className='modal-content'>
|
|
||||||
<span className='close' onClick={() => setShowModal(false)}>×</span>
|
|
||||||
<h2>实训信息</h2>
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>实训ID</th>
|
<th>姓名</th>
|
||||||
<th>实训名称</th>
|
<th>ID</th>
|
||||||
<th>学号</th>
|
|
||||||
<th>基础成绩</th>
|
<th>基础成绩</th>
|
||||||
<th>实训成绩</th>
|
<th>实训成绩</th>
|
||||||
<th>总成绩</th>
|
<th>总成绩</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{selectedTrain && selectedTrain.students.map((student, index) => (
|
{Object.keys(TrainData).map((key)=>(
|
||||||
<tr key={index}>
|
<tr key={key}>
|
||||||
<td>{selectedTrain[10]}</td>
|
<td>{key}</td>
|
||||||
<td>{eval(selectedTrain[11])}</td>
|
<td>{TrainData[key][0]}</td>
|
||||||
<td>{student.studentID}</td>
|
<td>{TrainData[key][4]}</td>
|
||||||
<td>{student.baseScore}</td>
|
<td>{TrainData[key][5]}</td>
|
||||||
<td>{student.trainScore}</td>
|
<td>{parseInt(TrainData[key][4])+parseInt(TrainData[key][5])}</td>
|
||||||
<td>{student.totalScore}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ function HeaderNavTeacher() {
|
||||||
</div>
|
</div>
|
||||||
<div className='left-nav-li'>
|
<div className='left-nav-li'>
|
||||||
<ul>
|
<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}>
|
<li onClick={item.onClick}>
|
||||||
<div className='nav-li-box'>
|
<div className='nav-li-box'>
|
||||||
<Link to={item.path} className="custom-link-home" style={{color:'black'}}>
|
<Link to={item.path} className="custom-link-home" style={{color:'black'}}>
|
||||||
|
|
|
@ -15,6 +15,7 @@ function Operation2() {
|
||||||
const score=localStorage.getItem('score')
|
const score=localStorage.getItem('score')
|
||||||
const { operateID } = useParams();
|
const { operateID } = useParams();
|
||||||
const [isTrue,setisTrue]=useState(false)
|
const [isTrue,setisTrue]=useState(false)
|
||||||
|
const [TrainScore,serTrainScore]=(null)
|
||||||
|
|
||||||
const TrainData=JSON.parse(localStorage.getItem('TrainData'))
|
const TrainData=JSON.parse(localStorage.getItem('TrainData'))
|
||||||
|
|
||||||
|
@ -91,7 +92,21 @@ function Operation2() {
|
||||||
// 下拉菜单
|
// 下拉菜单
|
||||||
const [isSubjectDropdownOpen, setIsSubjectDropdownOpen] = useState(false);
|
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 = ()=>{
|
const tijiao = ()=>{
|
||||||
|
submitTrain()
|
||||||
setCountdown(0)
|
setCountdown(0)
|
||||||
localStorage.removeItem('time')
|
localStorage.removeItem('time')
|
||||||
localStorage.removeItem('choice_answers');
|
localStorage.removeItem('choice_answers');
|
||||||
|
@ -117,8 +132,10 @@ function Operation2() {
|
||||||
const result=detectionSrc.data['result']
|
const result=detectionSrc.data['result']
|
||||||
if(result==='NO'){
|
if(result==='NO'){
|
||||||
alert('连接失败')
|
alert('连接失败')
|
||||||
|
TrainScore(0)
|
||||||
}else{
|
}else{
|
||||||
alert('连接成功')
|
alert('连接成功')
|
||||||
|
TrainScore(50)
|
||||||
}
|
}
|
||||||
}catch{
|
}catch{
|
||||||
alert('detection出错')
|
alert('detection出错')
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = function(app) {
|
||||||
app.use(
|
app.use(
|
||||||
'/api', // 如果请求路径匹配'/api',则进行代理
|
'/api', // 如果请求路径匹配'/api',则进行代理
|
||||||
createProxyMiddleware({
|
createProxyMiddleware({
|
||||||
target: 'http://127.0.0.1:5000s', // 目标后端服务地址
|
target: 'http://127.0.0.1:5000', // 目标后端服务地址
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -135,7 +135,6 @@ def fetch_result():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/student/score_entry', methods=['POST'])
|
@app.route('/api/student/score_entry', methods=['POST'])
|
||||||
def score_entry():
|
def score_entry():
|
||||||
data = request.json
|
data = request.json
|
||||||
|
@ -176,6 +175,14 @@ def FindTrain1Src():
|
||||||
result=FindTrain1SrcFunc(ID,testID)
|
result=FindTrain1SrcFunc(ID,testID)
|
||||||
return jsonify({'Src':result})
|
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)
|
data=getTrainFunc(teacherID)
|
||||||
return jsonify({'data':data})
|
return jsonify({'data':data})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/teacher/FindSrc',methods=["POST"])
|
@app.route('/api/teacher/FindSrc',methods=["POST"])
|
||||||
def FindSrc():
|
def FindSrc():
|
||||||
testID=request.json['key']
|
testID=request.json['key']
|
||||||
|
@ -329,6 +338,14 @@ def appendQuestion():
|
||||||
appendQuestionFunc(subject,chapter,inputValue,A,B,C,D,correct,judgeValue)
|
appendQuestionFunc(subject,chapter,inputValue,A,B,C,D,correct,judgeValue)
|
||||||
return '添加成功'
|
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
|
# @app.route("/api/teacher/list_pods",methods=['POST']) # 列出pod
|
||||||
|
@ -337,11 +354,11 @@ def appendQuestion():
|
||||||
# @app.route("/api/teacher/list_services") # 列出服务
|
# @app.route("/api/teacher/list_services") # 列出服务
|
||||||
# def teacher_list_services():
|
# def teacher_list_services():
|
||||||
# return list_services()
|
# return list_services()
|
||||||
#
|
|
||||||
# # @app.route("/api/teacher/create_pod") # 创建服务 1为项目实训, 0为安装实训
|
# @app.route("/api/teacher/create_pod") # 创建服务 1为项目实训, 0为安装实训
|
||||||
# # def teacher_create_pod():
|
# def teacher_create_pod():
|
||||||
# # create_pod(1, "test2")
|
# create_pod(1, "test2")
|
||||||
#
|
|
||||||
# @app.route("/api/teacher/DelPods",methods=['POST']) # 删除服务
|
# @app.route("/api/teacher/DelPods",methods=['POST']) # 删除服务
|
||||||
# def teacher_delete_pod():
|
# def teacher_delete_pod():
|
||||||
# name=request.json['name']
|
# name=request.json['name']
|
||||||
|
@ -349,7 +366,7 @@ def appendQuestion():
|
||||||
# testID=name[10:]
|
# testID=name[10:]
|
||||||
# delDMFunc(studentID,testID)
|
# delDMFunc(studentID,testID)
|
||||||
# return delete_pod(name=name)
|
# return delete_pod(name=name)
|
||||||
#
|
|
||||||
# @app.route("/api/student/check_pod",methods=['POST']) # 检测数据库是否安装成功 若成功,返回OK 否则返回NO
|
# @app.route("/api/student/check_pod",methods=['POST']) # 检测数据库是否安装成功 若成功,返回OK 否则返回NO
|
||||||
# def teacher_check_pod():
|
# def teacher_check_pod():
|
||||||
# name=request.json["student_ID"]
|
# name=request.json["student_ID"]
|
||||||
|
|
|
@ -342,6 +342,12 @@ def FindTrain1SrcFunc(ID,testID):
|
||||||
# FindTrain1SrcFunc('20240101','54')
|
# 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 '添加成功'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -455,3 +455,21 @@ def appendQuestionFunc(subject,chapter,inputValue,A,B,C,D,correct,judgeValue):
|
||||||
print('插入成功')
|
print('插入成功')
|
||||||
return 'INSERT'
|
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')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue