123
This commit is contained in:
parent
71d7956e65
commit
7e3578391b
|
@ -86,10 +86,6 @@ function StudentLink(){
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>}
|
</table>}
|
||||||
<button onClick={submit} className='submit'>确定</button>
|
<button onClick={submit} className='submit'>确定</button>
|
||||||
<button onClick={()=>{
|
|
||||||
console.log(score);
|
|
||||||
console.log(suggestion);
|
|
||||||
}}>测试</button>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,31 @@
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
float: right;
|
float: right;
|
||||||
background-color: #f7f8fa;
|
background-color: #f7f8fa;
|
||||||
}
|
}
|
||||||
|
.body-right-Pods-table{
|
||||||
|
margin-left: 20px;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.body-right-Pods-table th{
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
.body-right-Pods-table td{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
span{
|
||||||
|
all: unset;
|
||||||
|
}
|
||||||
|
.SrcBox{
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
.SrcBox th{
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
width: 220px;
|
||||||
|
}
|
||||||
|
.SrcBox td{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.thd{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,86 @@ import axios from 'axios';
|
||||||
import './TrainPods.css'
|
import './TrainPods.css'
|
||||||
|
|
||||||
function TrainPods(){
|
function TrainPods(){
|
||||||
|
const teacher_ID=localStorage.getItem('islogin')
|
||||||
|
const[isTrue,setisTrue]=useState(true)
|
||||||
|
const [Pods,setPods]=useState()
|
||||||
|
const FindPodsFunc=async ()=>{
|
||||||
|
try{
|
||||||
|
const FindPodsFunc=await axios.post('/api/teacher/list_pods')
|
||||||
|
setPods(FindPodsFunc.data)
|
||||||
|
}catch{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
FindPodsFunc()
|
||||||
|
},[])
|
||||||
|
|
||||||
|
const handleDelete=async(name)=> {
|
||||||
|
try{
|
||||||
|
const delPods=await axios.post('/api/teacher/DelPods',{
|
||||||
|
name
|
||||||
|
})
|
||||||
|
alert('删除成功')
|
||||||
|
}catch{
|
||||||
|
alert('出错')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const [SrcData,setSrcData]=useState()
|
||||||
|
const FindSrc=async(ID,key)=>{
|
||||||
|
try{
|
||||||
|
const FindSrcc=await axios.post('/api/teacher/FindSrc',{
|
||||||
|
ID,
|
||||||
|
key
|
||||||
|
})
|
||||||
|
setSrcData(FindSrcc.data['data'])
|
||||||
|
setisTrue(false)
|
||||||
|
}catch{
|
||||||
|
alert('SrcDAta出错')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// // eslint-disable-next-line no-restricted-globals
|
||||||
|
//
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div className='body-right-Pods'>asdas</div>
|
<div className='body-right-Pods'>
|
||||||
|
{isTrue&&<table className='body-right-Pods-table'>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>学号</th><th>实训类型</th><th>实训ID</th><th>IP</th><th>实训链接</th><span className='thd'>操作</span>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{Pods&&<tbody>
|
||||||
|
{Object.keys(Pods['list']).map((key,index)=>(
|
||||||
|
index>1&&
|
||||||
|
<tr key={key}>
|
||||||
|
<td>{Pods['list'][key]['name'].substring(1, 9)}</td>
|
||||||
|
<td>{Pods['list'][key]['name'].substring(0,1)==='n'? '终端实训':'网页实训'}</td>
|
||||||
|
<td>{Pods['list'][key]['name'].substring(10)}</td>
|
||||||
|
<td>{Pods['list'][key]['ip']}</td>
|
||||||
|
<td><button onClick={()=>FindSrc(Pods['list'][key]['name'].substring(1, 9),Pods['list'][key]['name'].substring(10))}>查看链接</button></td>
|
||||||
|
<td><button onClick={()=>handleDelete(Pods['list'][key]['name'])}>删除</button></td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>}
|
||||||
|
</table>}
|
||||||
|
{!isTrue&& <table>
|
||||||
|
<span className='spanBox'>此学生的实训地址为:</span>
|
||||||
|
<div className='SrcBox'>
|
||||||
|
<tr>
|
||||||
|
<th>LINK</th><th>LINK2</th><th>LINK3</th>
|
||||||
|
</tr>
|
||||||
|
{Object.keys(SrcData).map((key)=>(
|
||||||
|
<tr key={key}>
|
||||||
|
<td>{SrcData[0][0]}</td><td>{SrcData[0][1]}</td><td>{SrcData[0][2]}</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<button onClick={()=>setisTrue(!isTrue)} style={{marginLeft:'600px'}}>返回</button>
|
||||||
|
</table>}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,19 @@
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #000;
|
color: #000;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 50px;
|
bottom: 170px;
|
||||||
right: 100px;
|
right: 100px;
|
||||||
background-color: rgb(186, 237, 237);
|
background-color: rgb(186, 237, 237);
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
.ManagePods{
|
||||||
|
border-radius: 20px;
|
||||||
|
position: absolute;
|
||||||
|
padding: 20px 30px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #000;
|
||||||
|
right: 300px;
|
||||||
|
bottom: 170px;
|
||||||
|
background-color: rgb(186, 237, 237);
|
||||||
}
|
}
|
|
@ -48,12 +48,9 @@ function TrainManage(){
|
||||||
<p>关闭时间:2024-11-5</p>
|
<p>关闭时间:2024-11-5</p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<Link to='/teacher/trainmanage/TrainPods' >管理实训</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>}
|
||||||
<button onClick={()=>{
|
|
||||||
console.log(Data);
|
|
||||||
}}></button>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,7 @@ function Operation1() {
|
||||||
localStorage.setItem('answeredComple',answeredComple)
|
localStorage.setItem('answeredComple',answeredComple)
|
||||||
localStorage.setItem('answeredJudge',answeredJudge)
|
localStorage.setItem('answeredJudge',answeredJudge)
|
||||||
localStorage.setItem('TrainData',JSON.stringify(TrainData))
|
localStorage.setItem('TrainData',JSON.stringify(TrainData))
|
||||||
|
localStorage.setItem('score',score)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,6 +206,7 @@ function Operation1() {
|
||||||
}
|
}
|
||||||
JUD_sum++
|
JUD_sum++
|
||||||
}
|
}
|
||||||
|
alert('保存成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 题目预览框
|
// 题目预览框
|
||||||
|
@ -349,9 +351,7 @@ function Operation1() {
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)}
|
)}
|
||||||
<button onClick={click}>测试</button>
|
<button onClick={submit}>保存答案</button>
|
||||||
<button onClick={clear}>清除测试</button>
|
|
||||||
<button onClick={submit}>假提交按钮</button>
|
|
||||||
<Link to={`/operation2/${operateID}`}><button onClick={saveAnswers}>下一页</button></Link>
|
<Link to={`/operation2/${operateID}`}><button onClick={saveAnswers}>下一页</button></Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import axios from 'axios';
|
||||||
import Test from '../../../TeacherPages/TestManage/Test';
|
import Test from '../../../TeacherPages/TestManage/Test';
|
||||||
function Operation2() {
|
function Operation2() {
|
||||||
const student_ID=localStorage.getItem('islogin')
|
const student_ID=localStorage.getItem('islogin')
|
||||||
|
const score=localStorage.getItem('score')
|
||||||
const { operateID } = useParams();
|
const { operateID } = useParams();
|
||||||
const [isTrue,setisTrue]=useState(false)
|
const [isTrue,setisTrue]=useState(false)
|
||||||
|
|
||||||
|
@ -100,6 +101,7 @@ function Operation2() {
|
||||||
localStorage.removeItem('answeredComple')
|
localStorage.removeItem('answeredComple')
|
||||||
localStorage.removeItem('answeredJudge')
|
localStorage.removeItem('answeredJudge')
|
||||||
localStorage.removeItem('RemainingTime')
|
localStorage.removeItem('RemainingTime')
|
||||||
|
localStorage.removeItem('score')
|
||||||
alert('提交成功')
|
alert('提交成功')
|
||||||
window.location.href='/train'
|
window.location.href='/train'
|
||||||
localStorage.removeItem('TrainData')
|
localStorage.removeItem('TrainData')
|
||||||
|
@ -163,9 +165,6 @@ function Operation2() {
|
||||||
<Link to={Src[8]}>{Src[8]}</Link>
|
<Link to={Src[8]}>{Src[8]}</Link>
|
||||||
<br />
|
<br />
|
||||||
点击以上链接前往实训
|
点击以上链接前往实训
|
||||||
<button onClick={()=>{
|
|
||||||
console.log(Src);
|
|
||||||
}}>dads</button>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{/* 前端连接数据库 ⬆*/}
|
{/* 前端连接数据库 ⬆*/}
|
||||||
|
|
|
@ -299,23 +299,30 @@ def GetTrain():
|
||||||
data=getTrainFunc(teacherID)
|
data=getTrainFunc(teacherID)
|
||||||
return jsonify({'data':data})
|
return jsonify({'data':data})
|
||||||
|
|
||||||
|
@app.route('/api/teacher/FindSrc',methods=["POST"])
|
||||||
|
def FindSrc():
|
||||||
|
testID=request.json['key']
|
||||||
|
studentID=request.json['ID']
|
||||||
|
data=FindSrcFunc(studentID,testID)
|
||||||
|
return jsonify({'data':data})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/teacher/list_pods") # 列出pod
|
@app.route("/api/teacher/list_pods",methods=['POST']) # 列出pod
|
||||||
def teacher_list_pods():
|
def teacher_list_pods():
|
||||||
return jsonify(list_pods())
|
return list_pods()
|
||||||
@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/delete_pod") # 删除服务
|
@app.route("/api/teacher/delete_pod",methods=['POST']) # 删除服务
|
||||||
def teacher_delete_pod():
|
def teacher_delete_pod():
|
||||||
return delete_pod("test2")
|
name=request.json['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():
|
||||||
|
@ -323,7 +330,7 @@ def teacher_check_pod():
|
||||||
testID=request.json["operateID"]
|
testID=request.json["operateID"]
|
||||||
name= 'n' + str(name) + '-' + str(testID)
|
name= 'n' + str(name) + '-' + str(testID)
|
||||||
result = check_dm(name)
|
result = check_dm(name)
|
||||||
return jsonify({'result':result})
|
return jsonify(result)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@app.route('/<path:path>')
|
@app.route('/<path:path>')
|
||||||
|
|
|
@ -17,8 +17,8 @@ spec:
|
||||||
runAsGroup: 0
|
runAsGroup: 0
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: '1'
|
|
||||||
memory: 1.2Gi
|
|
||||||
requests:
|
|
||||||
cpu: '0.2'
|
cpu: '0.2'
|
||||||
memory: 0.2Gi
|
memory: 0.2Gi
|
||||||
|
requests:
|
||||||
|
cpu: '0.1'
|
||||||
|
memory: 0.1Gi
|
|
@ -15,8 +15,8 @@ spec:
|
||||||
runAsGroup: 0
|
runAsGroup: 0
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: '1.3'
|
cpu: '0.2'
|
||||||
memory: 1.3Gi
|
memory: 0.2Gi
|
||||||
requests:
|
requests:
|
||||||
cpu: '0.3'
|
cpu: '0.1'
|
||||||
memory: 0.3Gi
|
memory: 0.1Gi
|
|
@ -1,5 +1,5 @@
|
||||||
import k8s_func
|
import k8s_func
|
||||||
studentList=['n20240101-56','n20240102-56','s20240101-52','s20240102-52']
|
studentList=['n20240101-63','n20240102-63','s20240101-66']
|
||||||
|
|
||||||
for i in studentList:
|
for i in studentList:
|
||||||
k8s_func.delete_pod(i)
|
k8s_func.delete_pod(i)
|
||||||
|
|
|
@ -388,3 +388,13 @@ def getTrainFunc(teacherID):
|
||||||
data = cursor.fetchall()
|
data = cursor.fetchall()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def FindSrcFunc(studentID, testID):
|
||||||
|
cursor = db.cursor()
|
||||||
|
cursor.execute(f'SELECT LINK,LINK2,LINK3 FROM TRAINSCORE WHERE STUDENT_ID=? AND TEST_ID=?',(studentID,testID))
|
||||||
|
data = cursor.fetchall()
|
||||||
|
cursor.close()
|
||||||
|
return data
|
||||||
|
|
||||||
|
# FindSrcFunc('20240101','68')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,4 @@
|
||||||
import json
|
print('a')
|
||||||
import dmPython
|
|
||||||
import k8s_func
|
|
||||||
db = dmPython.connect(user='SYSDBA', password='dameng!!', host="36.138.114.105", port="32522")
|
|
||||||
cursor=db.cursor()
|
|
||||||
studentList=['20240101','20240102']
|
|
||||||
testID='5'
|
|
||||||
type1=2
|
|
||||||
for i in studentList:
|
|
||||||
if type1==1:
|
|
||||||
name='s'+i+'-'+testID
|
|
||||||
# k8s_func.create_pod(type1,name)
|
|
||||||
item=k8s_func.list_services()
|
|
||||||
for j in item['list']:
|
|
||||||
if j['name']==name+'-service':
|
|
||||||
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'])
|
|
||||||
else:
|
|
||||||
name='n'+i+'-'+testID
|
|
||||||
# k8s_func.create_pod(0,name)
|
|
||||||
item=k8s_func.list_services()
|
|
||||||
for j in item['list']:
|
|
||||||
if j['name']==name+'-service':
|
|
||||||
Link=j['ip']
|
|
||||||
print(Link)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue