This commit is contained in:
30404 2024-07-04 10:00:31 +08:00
parent 00391c6857
commit f0407650bc
11 changed files with 91 additions and 41 deletions

View File

@ -77,7 +77,7 @@ function Marking(){
<img src={Test} alt="" width='35px' height='35px'/> <img src={Test} alt="" width='35px' height='35px'/>
<p> <p>
<p className='p-mark'><span>实训ID:{MarkData[key][0][10]}</span>{eval(MarkData[key][0][11])}</p> <p className='p-mark'><span>实训ID:{MarkData[key][0][10]}</span>{eval(MarkData[key][0][11])}</p>
<div id='TF'>{MarkData[key][0][6]>currentTime?'未开始':''}</div> <div id='TF'>{MarkData[key][0][6]>currentTime? ' ':'未开始'}</div>
<span>{MarkData[key][0][6]}</span> <span>{MarkData[key][0][6]}</span>
</p> </p>
</li> </li>

View File

@ -8,3 +8,7 @@
float: right; float: right;
background-color: #f7f8fa; background-color: #f7f8fa;
} }
.submit{
margin-left: 1000px;
margin-top: 20px;
}

View File

@ -13,7 +13,8 @@ function StudentLink(){
try{ try{
const sumbitScoreSrc=await axios.post('/api/teacher/UpdateTest',{ const sumbitScoreSrc=await axios.post('/api/teacher/UpdateTest',{
score, score,
testID testID,
suggestion
}) })
}catch{ }catch{
alert('提交出错') alert('提交出错')
@ -21,7 +22,6 @@ function StudentLink(){
} }
const submit=()=>{ const submit=()=>{
console.log('a');
sumbitScore() sumbitScore()
alert('批改成功') alert('批改成功')
window.location.href='http://localhost:3000/teacher/mark' window.location.href='http://localhost:3000/teacher/mark'
@ -43,6 +43,7 @@ function StudentLink(){
},[]) },[])
const [score,setscore]=useState([]) const [score,setscore]=useState([])
const [suggestion,setsuggestion]=useState([])
const handleInputChange = (event) => { const handleInputChange = (event) => {
const { name, value } = event.target; const { name, value } = event.target;
@ -51,27 +52,44 @@ function StudentLink(){
[name]: value [name]: value
}); });
} }
const handleInputChange2=(event)=>{
const { name, value } = event.target;
setsuggestion({
...suggestion,
[name]: value
});
}
return( return(
<div className='body-right-studentlink'> <div className='body-right-studentlink'>
<table> {TestLink&&<table>
<thead> <thead>
<tr> <tr>
<th>学生</th> <th>学生</th>
<th>链接</th> <th>链接1</th>
<th>链接2</th>
<th>链接3</th>
<th>分数</th> <th>分数</th>
<th>建议</th>
</tr> </tr>
</thead> </thead>
{TestLink&&<tbody> <tbody>
{Object.keys(TestLink).map((key)=>( {Object.keys(TestLink).map((key)=>(
<tr key={key}> <tr key={key}>
<td>{key}</td> <td>{key}</td>
<td><Link to={TestLink[key][6]} target="_blank">{TestLink[key][6]}</Link></td> <td><Link to={TestLink[key][6]} target="_blank">{TestLink[key][6]}</Link></td>
<td><Link to={TestLink[key][7]} target="_blank">{TestLink[key][7]}</Link></td>
<td><Link to={TestLink[key][8]} target="_blank">{TestLink[key][8]}</Link></td>
<td><input type="text" onChange={handleInputChange} name={TestLink[key][0]}/></td> <td><input type="text" onChange={handleInputChange} name={TestLink[key][0]}/></td>
<td><input type="text" onChange={handleInputChange2} name={TestLink[key][0]} /></td>
</tr> </tr>
))} ))}
</tbody>} </tbody>
</table> </table>}
<button onClick={submit}>提交</button> <button onClick={submit} className='submit'>确定</button>
<button onClick={()=>{
console.log(score);
console.log(suggestion);
}}>测试</button>
</div> </div>
) )
} }

View File

@ -5,7 +5,7 @@ import { useLocation } from 'react-router-dom';
import io, { Socket } from "socket.io-client"; import io, { Socket } from "socket.io-client";
export default function Test({ ip = "10.106.152.68", port = "22", password = "123456", user = "dmdba" }) { export default function Test({ ip = "", port = "22", password = "123456", user = "dmdba" }) {
const location = useLocation(); const location = useLocation();
const terminalObj = useRef(null); const terminalObj = useRef(null);
const [terminal, setTerminal] = useState(null); const [terminal, setTerminal] = useState(null);
@ -21,7 +21,7 @@ export default function Test({ ip = "10.106.152.68", port = "22", password = "12
if (terminal !== null) { if (terminal !== null) {
terminal.open(terminalObj.current); terminal.open(terminalObj.current);
const newSocket = io("ws://36.138.114.105:32087"); const newSocket = io("ws://36.138.114.105:31055");
setSocket(newSocket); setSocket(newSocket);
terminal.onData((data) => { terminal.onData((data) => {
@ -63,7 +63,7 @@ export default function Test({ ip = "10.106.152.68", port = "22", password = "12
return ( return (
<div> <div>
<div ref={terminalObj} onContextMenu={pasteContent} style={{ height: "100vh", width: "100%" }}> <div ref={terminalObj} onContextMenu={pasteContent} style={{ height: "500px", width: "100%" }}>
</div> </div>
</div> </div>
); );

View File

@ -75,7 +75,7 @@
/* 第二页(实训题题)的右边页面 */ /* 第二页(实训题题)的右边页面 */
.body-right2{ .body-right2{
width: 1415px; width: 1415px;
height: 845px; height: 550px;
position: absolute; position: absolute;
top: 64px; top: 64px;
left: 230px; left: 230px;
@ -84,6 +84,7 @@
} }
/* 返回按钮 */ /* 返回按钮 */
.btn-back2{ .btn-back2{
height: 50px; height: 50px;
@ -119,4 +120,8 @@
font-size: 20px; font-size: 20px;
margin-left: 5px; margin-left: 5px;
} }
.detection{
position: absolute;
margin-left: 1300px;
margin-top: -50px;
}

View File

@ -55,10 +55,6 @@ function Operation2() {
setisTrue(false) setisTrue(false)
} }
},[]) },[])
const click=()=>{
console.log(Src);
}
// //
// const { OperationId } = useParams(); // const { OperationId } = useParams();
@ -109,6 +105,24 @@ function Operation2() {
localStorage.removeItem('TrainData') localStorage.removeItem('TrainData')
} }
//
const detection=async()=>{
try{
const detectionSrc=await axios.post('/api/student/check_pod',{
student_ID,
operateID
})
const result=detectionSrc.data['result']
if(result==='OK'){
alert('连接成功')
}else{
alert('连接失败')
}
}catch{
alert('detection出错')
}
}
return ( return (
<div> <div>
<div className='nav-operation2'> <div className='nav-operation2'>
@ -139,24 +153,29 @@ function Operation2() {
</ul> </ul>
</div> </div>
<div className='body-right2'> <div className='body-right2'>
<button onClick={click}>测试按钮</button>
{/* 前端连接数据库⬇ */} {/* 前端连接数据库⬇ */}
{ !isTrue&&TrainData&&<div> { !isTrue&&TrainData&&Src&&<div>
<Link to={Src}>{TrainData['operateID'][3][0]}</Link> <p>{TrainData['operateID'][3][0]}</p>
<Link to={Src[6]}>{Src[6]}</Link>
<br />
<Link to={Src[7]}>{Src[7]}</Link>
<br />
<Link to={Src[8]}>{Src[8]}</Link>
<br /> <br />
点击以上链接前往实训 点击以上链接前往实训
</div>} <button onClick={()=>{
console.log(Src);
}}>dads</button>
</div>
}
{/* 前端连接数据库 ⬆*/} {/* 前端连接数据库 ⬆*/}
{/* 达梦数据库连接 ⬇*/} {/* 达梦数据库连接 ⬇*/}
{ isTrue&&TrainData&& { isTrue&&TrainData&&
<div> <div>
<p>{TrainData['operateID'][3][0]}</p> <p>{TrainData['operateID'][3][0]}</p>
<Test/> {Src&&<Test ip={Src[6]}/>}
<div className=''><button>检测</button></div> <div className='detection'><button onClick={detection}>检测</button></div>
</div>} </div>}
{/* 达梦数据库连接⬆ */} {/* 达梦数据库连接⬆ */}

View File

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

View File

@ -288,7 +288,8 @@ def NotMarkTest():
def UpdateTest(): def UpdateTest():
testID=request.json['testID'] testID=request.json['testID']
score=request.json['score'] score=request.json['score']
submitScoreFunc(score,testID) suggestion=request.json['suggestion']
submitScoreFunc(score,testID,suggestion)
print('修改成功') print('修改成功')
return '修改成功' return '修改成功'
@ -316,9 +317,13 @@ def teacher_create_pod():
def teacher_delete_pod(): def teacher_delete_pod():
return delete_pod("test2") return delete_pod("test2")
@app.route("/api/teacher/check_pod") # 检测数据库是否安装成功 若成功返回OK 否则返回NO @app.route("/api/student/check_pod",methods=['POST']) # 检测数据库是否安装成功 若成功返回OK 否则返回NO
def teacher_check_pod(): def teacher_check_pod():
return check_dm("test") name=request.json["student_ID"]
testID=request.json["operateID"]
name= 'n' + str(name) + '-' + str(testID)
result = check_dm(name)
return jsonify({'result':result})
@app.route('/') @app.route('/')
@app.route('/<path:path>') @app.route('/<path:path>')

View File

@ -1,5 +1,5 @@
import k8s_func import k8s_func
studentList=['s20240103-44'] studentList=['n20240101-53','s20240101-50','s20240102-50']
for i in studentList: for i in studentList:
k8s_func.delete_pod(i) k8s_func.delete_pod(i)

View File

@ -334,13 +334,12 @@ def HistoryTrainFunc(ID):
def FindTrain1SrcFunc(ID,testID): def FindTrain1SrcFunc(ID,testID):
cursor=db.cursor() cursor=db.cursor()
cursor.execute("SELECT LINK FROM TRAINSCORE WHERE STUDENT_ID=? AND TEST_ID=?",(ID,testID)) cursor.execute("SELECT * FROM TRAINSCORE WHERE STUDENT_ID=? AND TEST_ID=?",(ID,testID))
result=cursor.fetchall()[0][0] result=cursor.fetchall()[0]
print(result)
cursor.close() cursor.close()
return result return result
# FindTrain1SrcFunc('20240101','3') # FindTrain1SrcFunc('20240101','54')

View File

@ -288,9 +288,9 @@ def SendLink():
item = k8s_func.list_services() item = k8s_func.list_services()
for j in item['list']: for j in item['list']:
if j['name'] == name + '-service': if j['name'] == name + '-service':
Link = 'http://36.138.114.105/' + str(j['ports'][0]['node_port']) Link = 'http://36.138.114.105:' + str(j['ports'][0]['node_port'])
Link2 = 'http://36.138.114.105/' + str(j['ports'][1]['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']) Link3 = 'http://36.138.114.105:' + str(j['ports'][2]['node_port'])
cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?)",( cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?)",(
i,i[0:6],testID,'false','NULL','NULL',Link,Link2,Link3 i,i[0:6],testID,'false','NULL','NULL',Link,Link2,Link3
)) ))
@ -369,10 +369,10 @@ def NotMarkTestFunc(testID):
return dic return dic
# NotMarkTest('9') # NotMarkTest('9')
def submitScoreFunc(score,testID): def submitScoreFunc(score,testID,suggestion):
cursor = db.cursor() cursor = db.cursor()
for i in score: for i in score:
cursor.execute(f'UPDATE TRAINSCORE SET TRAINRESULT=? WHERE TEST_ID=? AND STUDENT_ID=?', (score[i], testID,i)) cursor.execute(f'UPDATE TRAINSCORE SET TRAINRESULT=? ,CRECOMMENDATION=?WHERE TEST_ID=? AND STUDENT_ID=?', (score[i],suggestion[i], testID,i))
cursor.execute(f'UPDATE TEACHERMARK SET TF=? WHERE TRAINID=?',('true',testID)) cursor.execute(f'UPDATE TEACHERMARK SET TF=? WHERE TRAINID=?',('true',testID))
db.commit() db.commit()