This commit is contained in:
30404 2024-07-11 14:23:10 +08:00
parent a7a03839b8
commit 01d11a6835
9 changed files with 96 additions and 62 deletions

View File

@ -7,6 +7,7 @@ import axios from 'axios';
function StudentLink(){
const testID=useParams()['key']
const [list,setlist]=useState([])
const sumbitScore=async()=>{
try{
@ -15,6 +16,10 @@ function StudentLink(){
testID,
suggestion
})
const delPods=await axios.post('/api/teacher/MarkDelPods',{
testID,
list
})
}catch{
alert('提交出错')
}
@ -33,6 +38,7 @@ function StudentLink(){
testID
})
setTestLink(NotMarkTestSrc.data['result'])
setlist(Object.keys(NotMarkTestSrc.data['result']).map(key => NotMarkTestSrc.data['result'][key][0]))
}catch{
alert('出错')
}
@ -58,6 +64,7 @@ function StudentLink(){
[name]: value
});
}
return(
<div className='body-right-studentlink'>
<div className='link-box'>

View File

@ -34,7 +34,7 @@ function SubjectPage(){
datasets: [
{
label: '得分情况分布',
data: [HistoryTrain[key][0][4],HistoryTrain[key][0][5]], //
data: [HistoryTrain[key][0][5],HistoryTrain[key][0][4]], //
backgroundColor: ['#FF6384','#36A2EB'], //
hoverOffset: 2,
},
@ -103,7 +103,7 @@ function SubjectPage(){
<ul>
<li>总得分{parseInt(PieData['datasets'][0]['data'][0])+parseInt(PieData['datasets'][0]['data'][1])}/{score}</li>
<li>分析:{HistoryTrain[testID][0][10]}</li>
<li>老师建议:{HistoryTrain[testID][0][9]}</li>
<li>老师建议:{HistoryTrain[testID][0][9]?`${HistoryTrain[testID][0][9]}`:'老师暂未批改该实训,请耐心等待'}</li>
</ul>
</div>}
</div>

View File

@ -146,7 +146,7 @@ function Operation1() {
localStorage.setItem('answeredJudge',answeredJudge)
localStorage.setItem('TrainData',JSON.stringify(TrainData))
localStorage.setItem('score',score)
localStorage.setItem('succeed',succeed)
localStorage.setItem('succeed',JSON.stringify(succeed))
};
@ -196,9 +196,7 @@ function Operation1() {
setscore(prevscore=>prevscore+5)
}else{
const itemText = item[0][9];
if (!succeed.includes(itemText)) {
setsucceed((prevSucceed) => [...prevSucceed, itemText]);
}
}
CHO_sum++
}
@ -206,10 +204,8 @@ function Operation1() {
if (item[0][2]===completion_answer[COM_sum]) {
setscore(prevscore=>prevscore+5)
}else{
const itemText = item[0][5];
if (!succeed.includes(itemText)) {
const itemText = item[0][9];
setsucceed((prevSucceed) => [...prevSucceed, itemText]);
}
}
COM_sum++
}
@ -217,10 +213,8 @@ function Operation1() {
if (item[0][2]===judge_answer[JUD_sum]) {
setscore(prevscore=>prevscore+5)
}else{
const itemText = item[0][5];
if (!succeed.includes(itemText)) {
const itemText = item[0][9];
setsucceed((prevSucceed) => [...prevSucceed, itemText]);
}
}
JUD_sum++
}
@ -275,7 +269,7 @@ function Operation1() {
)}
</li>
<Link to={`/operation2/${operateID}`} style={{color:'#000',textDecoration:'none'}}>
<li style={{ marginTop: isSubjectDropdownOpen ? '186px' : '0' }}>实训题</li>
<li style={{ marginTop: isSubjectDropdownOpen ? '186px' : '0' }} onClick={saveAnswers}>实训题</li>
</Link>
</ul>
{/* 题目预览框 */}
@ -373,10 +367,6 @@ function Operation1() {
<Link to={`/operation2/${operateID}`}>
<button onClick={saveAnswers} className='operation-btn2'>下一页</button>
</Link>
<button onClick={()=>{
console.log(TrainData);
console.log(succeed);
}}></button>
</div>
</div>
</div>

View File

@ -15,9 +15,10 @@ function Operation2() {
const score=localStorage.getItem('score')
const { operateID } = useParams();
const [isTrue,setisTrue]=useState(false)
const [TrainScore,setTrainScore]=useState()
const [TrainScore,setTrainScore]=useState(null)
const succeed=localStorage.getItem('succeed')
const TrainData=JSON.parse(localStorage.getItem('TrainData'))
const subject=(TrainData['operateID'][3])
//
const [Src,setSrc]=useState()
@ -99,7 +100,8 @@ function Operation2() {
TrainScore,
operateID,
student_ID,
succeed
succeed,
subject
})
}catch{
alert('submitTrainSrc出错')
@ -118,9 +120,9 @@ function Operation2() {
localStorage.removeItem('answeredJudge')
localStorage.removeItem('RemainingTime')
localStorage.removeItem('score')
localStorage.removeItem('succeed')
alert('提交成功')
window.location.href='/train'
localStorage.removeItem('TrainData')
}
//
@ -175,15 +177,23 @@ function Operation2() {
<div className='body-right2'>
{/* 前端连接数据库⬇ */}
{ !isTrue&&TrainData&&Src&&<div>
<p>题目{TrainData['operateID'][3][0]}</p>
<Link to={Src[6]} style={{fontSize:'18px',marginLeft:'50px'}}>{Src[6]}</Link>
<p style={{fontSize:'26px'}}>题目{TrainData['operateID'][3][0]}</p>
<span style={{fontSize:'18px',marginLeft:'50px'}}>点击此链接进入到ide编辑代码:</span>
<br />
<Link to={Src[7]} style={{fontSize:'18px',marginLeft:'50px'}}>{Src[7]}</Link>
<Link to={Src[6]} style={{fontSize:'18px',marginLeft:'90px'}} target='_blank'>{Src[6]}</Link>
<br />
<Link to={Src[8]} style={{fontSize:'18px',marginLeft:'50px'}}>{Src[8]}</Link>
<br />
<p>点击以上链接前往实训</p>
<span style={{fontSize:'18px',marginLeft:'50px'}}>5000端口映射到:</span>
<br />
<Link to={Src[7]} style={{fontSize:'18px',marginLeft:'90px'}} target='_blank'>{Src[7]}</Link>
<br />
<br />
<span style={{fontSize:'18px',marginLeft:'50px'}}>3000端口映射到:</span>
<br />
<Link to={Src[8]} style={{fontSize:'18px',marginLeft:'90px'}} target='_blank'>{Src[8]}</Link>
<br />
</div>
}
{/* 前端连接数据库 ⬆*/}
@ -191,11 +201,10 @@ function Operation2() {
{ isTrue&&TrainData&&
<div>
<p>{TrainData['operateID'][3][0]}</p>
{/* {Src&&<Test ip={Src[6]}/>} */}
{Src&&<Test ip={Src[6]}/>}
<div className='detection'><button onClick={detection}>检测</button></div>
</div>}
{/* 达梦数据库连接⬆ */}
</div>
<Link className='btn-back2' to={`/operation1/${operateID}`} style={{color:'#000',textDecoration:'none'}}>
<p>上一页</p>
@ -205,6 +214,7 @@ function Operation2() {
<img src={arrowright} alt="" width='40px' height='40px' />
<p>完成</p>
</button>
</div>
</div>

View File

@ -7,7 +7,7 @@ import axios from 'axios';
const WarningModal = ({ isOpen, onClose }) => {
//
const [isClosing, setIsClosing] = useState(false);
localStorage.removeItem('TrainData')
//
const handleClose = () => {
setIsClosing(true); //

View File

@ -4,9 +4,9 @@ import time
import paramiko
from k8s_func import *
from teacher_func import *
from student_func import *
# from k8s_func import *
from flask import Flask, render_template, request, jsonify, send_from_directory, session
from flask_cors import CORS
@ -178,10 +178,19 @@ def FindTrain1Src():
@app.route('/api/student/EntryTrainScore',methods=['POST'])
def EntryTrainScore():
score=request.json['score']
TrainScore=request.json['trainScore']
TrainScore=request.json['TrainScore']
operateID=request.json['operateID']
student_ID=request.json['student_ID']
AddTrainScoreFunc(score,TrainScore,student_ID,operateID)
succeed=request.json['succeed']
subject=request.json['subject']
print(subject[0])
print(type(subject))
if subject[0]=="达梦数据库连接":
Name='n'+student_ID+'-'+operateID
delete_pod(Name)
else:
print(False)
AddTrainScoreFunc(student_ID,operateID,score,TrainScore,succeed)
return jsonify({'result': '成功'})
@ -346,32 +355,40 @@ def getTrainData():
return jsonify({'data': data})
# @app.route("/api/teacher/list_pods",methods=['POST']) # 列出pod
# def teacher_list_pods():
# return list_pods()
# @app.route("/api/teacher/list_services") # 列出服务
# def teacher_list_services():
# return list_services()
@app.route("/api/teacher/list_pods",methods=['POST']) # 列出pod
def teacher_list_pods():
return list_pods()
@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/DelPods",methods=['POST']) # 删除服务
# def teacher_delete_pod():
# name=request.json['name']
# studentID=name[1:9]
# testID=name[10:]
# delDMFunc(studentID,testID)
# return delete_pod(name=name)
@app.route("/api/teacher/DelPods",methods=['POST']) # 删除服务
def teacher_delete_pod():
name=request.json['name']
studentID=name[1:9]
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"]
# testID=request.json["operateID"]
# name= 'n' + str(name) + '-' + str(testID)
# result = check_dm(name)
# return jsonify(result)
@app.route('/api/teacher/MarkDelPods',methods=['POST'])
def teacher_mark_del_pods():
studentList=request.json['list']
testID=request.json['testID']
for i in studentList:
Name='s'+i+'-'+testID
delete_pod(Name)
return '删除成功'
@app.route("/api/student/check_pod",methods=['POST']) # 检测数据库是否安装成功 若成功返回OK 否则返回NO
def teacher_check_pod():
name=request.json["student_ID"]
testID=request.json["operateID"]
name= 'n' + str(name) + '-' + str(testID)
result = check_dm(name)
return jsonify(result)
@app.route('/')
@app.route('/<path:path>')

View File

@ -4,6 +4,7 @@ from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
import base64
from datetime import datetime
import re
# 获取当前日期和时间
current_datetime = datetime.now()
@ -344,12 +345,23 @@ def FindTrain1SrcFunc(ID,testID):
def AddTrainScoreFunc(ID,testID,score,trainResult,succeed):
a=[]
# 打印结果字符串
succeed=json.loads(succeed)
succeed=list(succeed)
for i in succeed:
a.append(succeed[i])
a=set(a)
print(a)
a.append(i)
a=list(set(a))
if None in a:
a.remove(None)
if len(a)==0:
result_string='全能高手'
else:
result_string = ','.join(a)+'需要加强'
cursor=db.cursor()
cursor.execute("UPDATE TRAINSCORE SET TF='true', RESULT=(?), TRAINRESULT=(?) WHERE STUDENT_ID=(?) AND TEST_ID=(?)",(score,trainResult,ID,testID))
cursor.execute("UPDATE TRAINSCORE SET TF='true', RESULT=(?), TRAINRESULT=(?) ,ANALYSE=(?) WHERE STUDENT_ID=(?) AND TEST_ID=(?)",(score,trainResult,result_string,ID,testID))
print('加入成绩成功')
db.commit()
cursor.close()
return '添加成功'

View File

@ -291,8 +291,8 @@ def SendLink():
Link = 'http://36.138.114.105:' + str(j['ports'][0]['node_port'])
Link2 = 'http://36.138.114.105:' + str(j['ports'][1]['node_port'])
Link3 = 'http://36.138.114.105:' + str(j['ports'][2]['node_port'])
cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?,?)",(
i,i[0:6],testID,'false','NULL','NULL',Link,Link2,Link3,'NULL'
cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?,?,?)",(
i,i[0:6],testID,'false','NULL','NULL',Link,Link2,Link3,'NULL','NULL'
))
else:
pass
@ -304,8 +304,8 @@ def SendLink():
for j in item['list']:
if j['name'] == name + '-service':
Link = j['ip']
cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?,?)", (
i, i[0:6], testID, 'false', 'NULL', 'NULL', Link, 'NULL', 'NULL','NULL'
cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?,?,?)", (
i, i[0:6], testID, 'false', 'NULL', 'NULL', Link, 'NULL', 'NULL','NULL','NULL'
))
print('加入链接成功')

View File

@ -1,7 +1,5 @@
list1=[1,2,3,4,5]
name='asd'
dic={name:list1}
print(dic)
import k8s_func
k8s_func.delete_pod('20240101')