diff --git a/app-dm/src/TeacherPages/MarkingPages/Marking.css b/app-dm/src/TeacherPages/MarkingPages/Marking.css index 5179ebd..2eae47d 100644 --- a/app-dm/src/TeacherPages/MarkingPages/Marking.css +++ b/app-dm/src/TeacherPages/MarkingPages/Marking.css @@ -61,4 +61,8 @@ font-size: 13px; margin-top: -12px; color: #525252; +} +#TF{ + position: absolute; + margin-left: 1200px; } \ No newline at end of file diff --git a/app-dm/src/TeacherPages/MarkingPages/Marking.jsx b/app-dm/src/TeacherPages/MarkingPages/Marking.jsx index e38c9df..4a07a49 100644 --- a/app-dm/src/TeacherPages/MarkingPages/Marking.jsx +++ b/app-dm/src/TeacherPages/MarkingPages/Marking.jsx @@ -9,6 +9,7 @@ import axios from 'axios'; // 批改 function Marking(){ const teacher_ID=localStorage.getItem('islogin') + const currentTime = new Date().toLocaleString() if(teacher_ID==null){ alert('登录过期,请重新登录') window.location.href='http://36.138.114.105:30294/' @@ -59,10 +60,6 @@ function Marking(){ const ClassChange=(event)=>{ setClassID(event.target.value) } - const click=()=>{ - console.log(ClassID); - console.log(MarkData); - } return(
@@ -80,13 +77,13 @@ function Marking(){

实训ID:{MarkData[key][0][10]}{eval(MarkData[key][0][11])}

- {MarkData[key][0][6]} +
{MarkData[key][0][6]>currentTime?'未开始':''}
+ {MarkData[key][0][6]}

))} -
} ) diff --git a/app-dm/src/TeacherPages/MarkingPages/StudentLink.jsx b/app-dm/src/TeacherPages/MarkingPages/StudentLink.jsx index 6687f35..f2ea93e 100644 --- a/app-dm/src/TeacherPages/MarkingPages/StudentLink.jsx +++ b/app-dm/src/TeacherPages/MarkingPages/StudentLink.jsx @@ -9,8 +9,22 @@ function StudentLink(){ const testID=useParams()['key'] + const sumbitScore=async()=>{ + try{ + const sumbitScoreSrc=await axios.post('/api/teacher/UpdateTest',{ + score, + testID + }) + }catch{ + alert('提交出错') + } + } + const submit=()=>{ - console.log(TestLink); + console.log('a'); + sumbitScore() + alert('批改成功') + window.location.href='http://localhost:3000/teacher/mark' } const [TestLink,setTestLink]=useState() @@ -28,6 +42,15 @@ function StudentLink(){ NotMarkTestFunc() },[]) + const [score,setscore]=useState([]) + + const handleInputChange = (event) => { + const { name, value } = event.target; + setscore({ + ...score, + [name]: value + }); + } return(
@@ -42,8 +65,8 @@ function StudentLink(){ {Object.keys(TestLink).map((key)=>( - - + + ))} } diff --git a/app-dm/src/TeacherPages/TestManage/Test.tsx b/app-dm/src/TeacherPages/TestManage/Test.jsx similarity index 77% rename from app-dm/src/TeacherPages/TestManage/Test.tsx rename to app-dm/src/TeacherPages/TestManage/Test.jsx index 5f7889d..0926e46 100644 --- a/app-dm/src/TeacherPages/TestManage/Test.tsx +++ b/app-dm/src/TeacherPages/TestManage/Test.jsx @@ -5,11 +5,11 @@ import { useLocation } from 'react-router-dom'; import io, { Socket } from "socket.io-client"; -export default function WebSSH({ ip = "10.233.183.99", port = "22", password = "123456", user = "dmdba" }) { +export default function Test({ ip = "10.106.152.68", port = "22", password = "123456", user = "dmdba" }) { const location = useLocation(); - const terminalObj = useRef(null); - const [terminal, setTerminal] = useState(null); - const [socket, setSocket] = useState(null); + const terminalObj = useRef(null); + const [terminal, setTerminal] = useState(null); + const [socket, setSocket] = useState(null); useEffect(() => { if (terminal === null) { @@ -19,7 +19,7 @@ export default function WebSSH({ ip = "10.233.183.99", port = "22", password = " useEffect(() => { if (terminal !== null) { - terminal.open(terminalObj.current as HTMLDivElement); + terminal.open(terminalObj.current); const newSocket = io("ws://36.138.114.105:32087"); setSocket(newSocket); @@ -38,7 +38,7 @@ export default function WebSSH({ ip = "10.233.183.99", port = "22", password = " newSocket.emit("heartbeat"); }, 1000); - newSocket.on("output", (data: string) => { + newSocket.on("output", (data) => { terminal.write(data); }); @@ -54,7 +54,7 @@ export default function WebSSH({ ip = "10.233.183.99", port = "22", password = " } }, [socket, ip, port, password, user]); - function pasteContent(event: React.MouseEvent) { + function pasteContent(event) { navigator.clipboard.readText().then((content) => { socket?.emit("input", content); }); diff --git a/app-dm/src/TeacherPages/Trainmanage/Trainmanage.jsx b/app-dm/src/TeacherPages/Trainmanage/Trainmanage.jsx index 1b98711..7a62671 100644 --- a/app-dm/src/TeacherPages/Trainmanage/Trainmanage.jsx +++ b/app-dm/src/TeacherPages/Trainmanage/Trainmanage.jsx @@ -1,16 +1,34 @@ +import axios from 'axios'; import './Trainmanage.css' import { Link } from 'react-router-dom'; -// import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; // import axios from 'axios'; function TrainManage(){ + const teacher_ID=localStorage.getItem('islogin') + const [Data,setData]=useState() + //获取发布的实训 + const getTrainfunc=async()=>{ + try{ + const getTrainSrc=await axios.post('/api/teacher/getTrain',{ + teacher_ID, + }) + setData(getTrainSrc.data['data']) + }catch{ + alert('aaaa') + } + } + + useEffect(()=>{ + getTrainfunc() + },[]) return(

已批改的试卷

-
-
    + {Data&&
    +
    • 111

      关闭时间:2024-11-5

      @@ -31,7 +49,10 @@ function TrainManage(){
    前往发布实训 -
    +
} +
) } diff --git a/app-dm/src/pages/Home/Home.jsx b/app-dm/src/pages/Home/Home.jsx index d0b28a2..908bb6e 100644 --- a/app-dm/src/pages/Home/Home.jsx +++ b/app-dm/src/pages/Home/Home.jsx @@ -12,21 +12,11 @@ import { max, min } from 'lodash'; // 首页 function Home(){ const [isChecked,setisChecked]=useState(false) - //判断是否登录 - // useEffect(()=>{ - // if (!isChecked){ - // const is_login=localStorage.getItem('islogin') - // if(!is_login){ - // alert('未登录') - // window.location.href='/signin' - // }else{ - // console.log(is_login); - // console.log('已登录'); - // setisChecked(true) - // } - // //组件加载时自动调用login函数进行登录检测 - // } - // },[]);//在组件加载时只调用一次 + const student_ID=localStorage.getItem('islogin') + if(student_ID==null){ + window.location.href='http://localhost:3000/signin' + alert('未登录,请前往登录') + } //课表数据 const [lesson, setLesson] = useState([]); diff --git a/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx b/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx index 6544e5f..e29d9e7 100644 --- a/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx +++ b/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx @@ -8,6 +8,7 @@ import moment from 'moment'; // 首页 题目集 function SubjectPage(){ const student_ID=localStorage.getItem('islogin') + if(student_ID==null){ alert('登录过期,请重新登录') window.location.href='http://36.138.114.105:30294/' @@ -33,11 +34,6 @@ function SubjectPage(){ test() },[]) - const click=()=>{ - console.log(testdata); - console.log(FalseData); - console.log(NotFalse); - } return(
@@ -68,7 +64,6 @@ function SubjectPage(){
))} - { NotFalse&& result&&
{Object.keys(NotFalse).map((key)=>{ return( diff --git a/app-dm/src/pages/ListPages/Training/Operation2.jsx b/app-dm/src/pages/ListPages/Training/Operation2.jsx index 1fb5dbc..b075d57 100644 --- a/app-dm/src/pages/ListPages/Training/Operation2.jsx +++ b/app-dm/src/pages/ListPages/Training/Operation2.jsx @@ -9,7 +9,7 @@ import arrowright from '../img/arrowright.jpg' import bottom from '../img/bottom.jpg' import top from '../img/top.jpg' import axios from 'axios'; - +import Test from '../../../TeacherPages/TestManage/Test'; function Operation2() { const student_ID=localStorage.getItem('islogin') const { operateID } = useParams(); @@ -32,8 +32,6 @@ function Operation2() { } //终端 - const terminalObj = useRef(null); - let sock = null; const [terminal, setTerminal] = useState(null); useEffect(()=>{ @@ -42,7 +40,6 @@ function Operation2() { Train1() setisTrue(true) - if (terminal == null){ setTerminal(new Terminal({ cols: 80, @@ -62,52 +59,6 @@ function Operation2() { console.log(Src); } - - // useEffect(() => { - // if (terminal == null){ - // setTerminal(new Terminal({ - // cols: 80, - // rows: 27, - // fontSize: 23 - // })); - // } - // }, []) - - // useEffect(() => { - - // if (terminal != null){ - // terminal.open(terminalObj.current ); - // // sock = new WebSocket("ws://192.168.0.40:8765"); - // sock = new WebSocket(Src); - // terminal.onData((data) => { - // sock?.send(data); - // }); - // terminal.onSelectionChange((a, b) => { - // if (terminal.hasSelection()){ - // navigator.clipboard.writeText(terminal.getSelection()); - // } - // }) - // setInterval(() => { - // sock?.send("heartbeat"); - // }, 1000); - // sock.addEventListener("message", function (event) { - // console.log(event.data); - // terminal.write(event.data); - // }); - // } - // }, [terminal]) - - function pasteContent(event) { - navigator.clipboard.readText().then((content) =>{ - sock?.send(content); - }) - event.preventDefault(); - } - - //删除函数 - const DEL=()=>{ - // - } //倒计时 // const { OperationId } = useParams(); @@ -203,7 +154,9 @@ function Operation2() { { isTrue&&TrainData&&

{TrainData['operateID'][3][0]}

-
+ +
+
} {/* 达梦数据库连接⬆ */} diff --git a/app-dm/src/router/index.jsx b/app-dm/src/router/index.jsx index f52c3f4..3381534 100644 --- a/app-dm/src/router/index.jsx +++ b/app-dm/src/router/index.jsx @@ -26,11 +26,7 @@ import Marking from '../TeacherPages/MarkingPages/Marking'; import SendTrain from '../TeacherPages/Trainmanage/SendTrain' import TrainManage from '../TeacherPages/Trainmanage/Trainmanage' import StudentLink from '../TeacherPages/MarkingPages/StudentLink'; -import Test from '../TeacherPages/TestManage/Test.tsx' - - -import SendTrain from '../TeacherPages/Trainmanage/SendTrain'; -import TrainManage from '../TeacherPages/Trainmanage/Trainmanage'; +import Test from '../TeacherPages/TestManage/Test'; // 定义一个组件来包裹除了特定页面(exam)外的所有页面使其有导航 const MainLayout = ({ headerNav:HeaderNav }) => { return ( diff --git a/app-dm/src/setupProxy.js b/app-dm/src/setupProxy.js index 4a40b4f..2dedd89 100644 --- a/app-dm/src/setupProxy.js +++ b/app-dm/src/setupProxy.js @@ -4,8 +4,8 @@ module.exports = function(app) { app.use( '/api', // 如果请求路径匹配'/api',则进行代理 createProxyMiddleware({ - target: 'http://127.0.0.1:5000', // 目标后端服务地址 + target: 'http://36.138.114.105:32087/', // 目标后端服务地址 changeOrigin: true, }) - ); + ); }; \ No newline at end of file diff --git a/python/app.py b/python/app.py index 15c08eb..a01e096 100644 --- a/python/app.py +++ b/python/app.py @@ -12,6 +12,8 @@ from flask import Flask, render_template, request, jsonify, send_from_directory, from flask_cors import CORS from flask_socketio import SocketIO, emit, disconnect import logging +import os +print(os.getcwd()) logging.basicConfig(level=logging.DEBUG) app = Flask(__name__, static_folder="public") CORS(app) @@ -257,11 +259,14 @@ def SendTrainTest(): TrainJudge=data['TrainJudge'] Hour=data['HourValue'] Min=data['MinValue'] - StopTime=data['StopTime'] + startTime=convert_iso_to_database_format(data['startDate']) + endTime=convert_iso_to_database_format(data['endDate']) Class=data['selectedItems'] Train=data['Train'] teacher_id=data['teacher_ID'] - SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min, StopTime,Class,Train,teacher_id) + SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min,Class,Train,teacher_id,startTime,endTime) + SendLink() + TeacherMark(Class, teacher_id) return '发布成功' @@ -272,20 +277,44 @@ def Find_details(): result=Find_details_Func(ID) print(result) return jsonify({'TestScore':result}) + +@app.route('/api/teacher/NotMarkTest',methods=["POST"]) +def NotMarkTest(): + testID=request.json['testID'] + result=NotMarkTestFunc(testID) + return jsonify({'result':result}) + +@app.route('/api/teacher/UpdateTest',methods=["POST"]) +def UpdateTest(): + testID=request.json['testID'] + score=request.json['score'] + submitScoreFunc(score,testID) + print('修改成功') + return '修改成功' + +@app.route('/api/teacher/getTrain',methods=["POST"]) +def GetTrain(): + teacherID=request.json['teacher_ID'] + data=getTrainFunc(teacherID) + return jsonify({'data':data}) + + + + @app.route("/api/teacher/list_pods") # 列出pod def teacher_list_pods(): - return list_pods() + return jsonify(list_pods()) @app.route("/api/teacher/list_services") # 列出服务 def teacher_list_services(): return list_services() -@app.route("/api/teacher/create_pod") # 创建服务 0为项目实训, 1为安装实训 +@app.route("/api/teacher/create_pod") # 创建服务 1为项目实训, 0为安装实训 def teacher_create_pod(): - return create_pod(1, "test") + create_pod(1, "test2") @app.route("/api/teacher/delete_pod") # 删除服务 def teacher_delete_pod(): - return delete_pod("test") + return delete_pod("test2") @app.route("/api/teacher/check_pod") # 检测数据库是否安装成功 若成功,返回OK 否则返回NO def teacher_check_pod(): diff --git a/python/assets/type0-pod.yaml b/python/assets/type0-pod.yaml index c8b9701..a500d68 100644 --- a/python/assets/type0-pod.yaml +++ b/python/assets/type0-pod.yaml @@ -17,8 +17,8 @@ spec: runAsGroup: 0 resources: limits: - cpu: '1' - memory: 1Gi + cpu: '0.2' + memory: 0.3Gi requests: - cpu: '0.25' - memory: 0.5Gi \ No newline at end of file + cpu: '0.1' + memory: 0.2Gi \ No newline at end of file diff --git a/python/assets/type1-pod.yaml b/python/assets/type1-pod.yaml index 6025574..dec4808 100644 --- a/python/assets/type1-pod.yaml +++ b/python/assets/type1-pod.yaml @@ -15,8 +15,8 @@ spec: runAsGroup: 0 resources: limits: - cpu: '1' - memory: 1Gi + cpu: '0.2' + memory: 0.3Gi requests: - cpu: '0.25' - memory: 0.5Gi \ No newline at end of file + cpu: '0.1' + memory: 0.2Gi \ No newline at end of file diff --git a/python/del.py b/python/del.py new file mode 100644 index 0000000..642c494 --- /dev/null +++ b/python/del.py @@ -0,0 +1,6 @@ +import k8s_func +studentList=['s20240103-44'] + +for i in studentList: + k8s_func.delete_pod(i) + print("delete") diff --git a/python/k8s_func.py b/python/k8s_func.py index b6f6bc1..06571b6 100644 --- a/python/k8s_func.py +++ b/python/k8s_func.py @@ -6,25 +6,29 @@ from kubernetes import client, config from flask import jsonify import dmPython # Load in-cluster config + config.load_incluster_config() v1 = client.CoreV1Api() namespace = open("/var/run/secrets/kubernetes.io/serviceaccount/namespace").read() IP = "36.138.114.105" + def list_pods(): ret = v1.list_namespaced_pod(namespace, watch=False) - return { + return ({ "list": [{ "name": item.metadata.name, "ip": item.status.pod_ip } for item in ret.items] - } + }) def list_services(): ret = v1.list_namespaced_service(namespace) return { - "list": [ - item.to_dict() - for item in ret.items] + "list": [{ + "ip": item.spec.cluster_ip, + "name": item.metadata.name, + "ports": [port.to_dict() for port in item.spec.ports] + } for item in ret.items] } def create_pod(type, name): @@ -38,7 +42,7 @@ def create_pod(type, name): body=pod_manifest, namespace=namespace ) - print(f"pod '{resp.metadata.name}' 创建成功") + # print(f"pod '{resp.metadata.name}' 创建成功") # 创建 Service with open(f"assets/type{type}-service.yaml") as f: service_pod = yaml.safe_load(f) @@ -49,20 +53,23 @@ def create_pod(type, name): body=service_pod, namespace=namespace ) - print(f"服务 '{resp.metadata.name}' 创建成功") + # print(f"服务 '{resp.metadata.name}' 创建成功") if type == 1: # 创建成功,再次查询,拿到端口 service = v1.read_namespaced_service(name=name + "-service", namespace=namespace) - print(service) - print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port)) + # print(service) + # print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port)) else: service = v1.read_namespaced_service(name=name + "-service", namespace=namespace) - print(service) - print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port)) - return f"{IP} {service.spec.ports[0].node_port}" + # print(service) + # print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port)) + return "cjcg" + +# create_pod(0,'20240101-zt-9-0') def delete_pod(name): v1.delete_namespaced_pod(name=name, namespace=namespace) + print('deleting pod ' + name) v1.delete_namespaced_service(name=name + "-service", namespace=namespace) return "删除成功" diff --git a/python/teacher_func.py b/python/teacher_func.py index 242b717..32a4e0a 100644 --- a/python/teacher_func.py +++ b/python/teacher_func.py @@ -4,10 +4,18 @@ from Crypto.Cipher import AES from Crypto.Random import get_random_bytes import base64 import datetime +import k8s_func db = dmPython.connect(user='SYSDBA', password='dameng!!', host="36.138.114.105", port="32522") +def convert_iso_to_database_format(iso_datetime_str): + # 解析 ISO 8601 格式的日期时间字符串为 datetime 对象 + iso_datetime = datetime.datetime.fromisoformat(iso_datetime_str.replace('Z', '+00:00')) + # 格式化为数据库需要的日期时间格式 + formatted_datetime_str = iso_datetime.strftime('%Y-%m-%d %H:%M:%S') + + return formatted_datetime_str #获取题目 def choice_question_func(ID): @@ -223,6 +231,7 @@ def train_question(): testID=None TrainName="" +studentList=[] # train_question() def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,Class,Train,teacher_id,startTime,endTime): TrainChoice = json.dumps(TrainChoice) @@ -232,7 +241,6 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,Class,Trai Train=json.dumps(Train) global TrainName TrainName=Train - cursor = db.cursor() cursor.execute(f'INSERT INTO TRAINTEST (CHOICE,COMPLE,JUDGE,HOUR,MIN,RELEASETIME,STOPTIME,CLASS,SUBJECT,TEACHER_ID,Train) VALUES' f'(?,?,?,?,?,?,?,?,?,?,?)',(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,startTime,endTime,Class,'Train',teacher_id,Train)) @@ -249,20 +257,11 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,Class,Trai end = 'false' # 将试卷分配到每一个学生 - zero='https://www.baidu.com/' - one='https://www.douyin.com/' + global studentList + studentList=student_list - for i in student_list: - if Train=='达梦数据库连接': - cursor.execute("INSERT INTO TrainScore (STUDENT_ID,CLASS,TEST_ID,TF,LINK) VALUES (?,?,?,?,?)", - (i, i[0:6], test_id, end,zero)) - else: - cursor.execute("INSERT INTO TrainScore (STUDENT_ID,CLASS,TEST_ID,TF,LINK) VALUES (?,?,?,?,?)", - (i, i[0:6], test_id, end,one)) - - # 发布实训的时候根据实训不同给予不同链接 - cursor.execute(f"SELECT ID FROM TRAINTEST WHERE RELEASETIME=? ", (now_time)) + cursor.execute(f"SELECT ID FROM TRAINTEST WHERE RELEASETIME=? ", (startTime)) test_id = cursor.fetchall()[0][0] global testID testID=test_id @@ -272,6 +271,50 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,Class,Trai return '发布成功' + +num=5 +def SendLink(): + global TrainName + global studentList + global testID + cursor = db.cursor() + print('进入到函数') + if TrainName.find(r'["\u524d\u7aef\u4e0e\u6570\u636e\u5e93\u7ed3\u5408"]') != -1: + print('s') + for i in studentList: + print(i) + name ='s'+str(i)+'-'+str(testID) + k8s_func.create_pod(1, 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']) + cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?)",( + i,i[0:6],testID,'false','NULL','NULL',Link,Link2,Link3 + )) + else: + pass + else: + for i in studentList: + name = 'n' + str(i) + '-' + str(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'] + cursor.execute(f"INSERT INTO TRAINSCORE VALUES (?,?,?,?,?,?,?,?,?)", ( + i, i[0:6], testID, 'false', 'NULL', 'NULL', Link, 'NULL', 'NULL' + )) + + print('加入链接成功') + db.commit() + cursor.close() + + + + def TeacherMark(CLASS,ID): global testID global TrainName @@ -280,20 +323,11 @@ def TeacherMark(CLASS,ID): if TrainName.find(r'["\u524d\u7aef\u4e0e\u6570\u636e\u5e93\u7ed3\u5408"]') != -1: for i in eval(strClass): cursor.execute(f'INSERT INTO TEACHERMARK VALUES(?,?,?,?) ', (ID,testID,'false', i)) + else: + print(TrainName) db.commit() cursor.close() -# def Find_dic(dic): -# # 获取字典的键,并按照从大到小的顺序排序 -# keys_sorted = sorted(dic.keys(), reverse=True) -# -# # 取最后三个键 -# last_three_keys = keys_sorted[:3] -# -# # 创建一个新的字典,仅包含排序后的最后三个键及其对应的值 -# dic_last_three = {key: dic[key] for key in last_three_keys} -# -# return dic_last_three # 返回一个新字典,该字典仅包含排序后的最后三个键及其对应的值 def Find_details_Func(ID): @@ -324,7 +358,7 @@ def MarkTrainFunc(ClassID,teacher_ID): # MarkTrainFunc('202401','111111') -def NotMarkTest(testID): +def NotMarkTestFunc(testID): cursor = db.cursor() dic={} cursor.execute(f'SELECT * FROM TRAINSCORE WHERE TEST_ID=?',(testID)) @@ -334,5 +368,23 @@ def NotMarkTest(testID): return dic -NotMarkTest('9') +# NotMarkTest('9') +def submitScoreFunc(score,testID): + cursor = db.cursor() + 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 TEACHERMARK SET TF=? WHERE TRAINID=?',('true',testID)) + db.commit() + return 'SELECT' + +# score= {'20240101':'123','20240102':'132','20240103':'321'} +# submitScoreFunc(score,'9') + + +def getTrainFunc(teacherID): + cursor = db.cursor() + cursor.execute(f'SELECT * FROM TRAINTEST WHERE TEACHER_ID=?',(teacherID)) + data = cursor.fetchall() + return data diff --git a/python/test.py b/python/test.py new file mode 100644 index 0000000..f6171ca --- /dev/null +++ b/python/test.py @@ -0,0 +1,30 @@ +import json +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) + + + +
{key}{TestLink[key][6]}{TestLink[key][6]}