Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app-dm/src/router/index.jsx
#	python/app.py
#	python/k8s_func.py
This commit is contained in:
wang 2024-07-02 13:02:19 +08:00
commit df8ece4dd8
14 changed files with 235 additions and 103 deletions

View File

@ -3,6 +3,8 @@ import { Link } from 'react-router-dom';
// import axios from 'axios';
import './Marking.css';
import Test from '../../pages/Home/img/test.jpg'
import React, { useEffect, useState } from 'react';
import axios from 'axios';
//
function Marking(){
@ -11,34 +13,81 @@ function Marking(){
alert('登录过期,请重新登录')
window.location.href='http://36.138.114.105:30294/'
}
const [istrue,setistrue]=useState(false)
//
const [ClassID,setClassID]=useState()
const [selectClass,SetClassData]=useState()
const SeleactClass= async()=>{
try {
const select_class_src = await axios.post('/api/teacher/select_class', {
teacher_ID
});
SetClassData(select_class_src.data['Class']);
setClassID(Object.keys(select_class_src.data['Class'])[0])
setistrue(true)
} catch (error) {
console.log(error);
}
}
useEffect(()=>{
SeleactClass()
},[])
//
const [MarkData,setMarkData]=useState()
const MarkTrainFunc=async()=>{
try{
const MarkTrainSrc=await axios.post('/api/teacher/marktrain',{
ClassID,
teacher_ID
})
setMarkData(MarkTrainSrc.data['MarkClass'])
}catch{
alert('MarkTrain出错')
}
}
useEffect(()=>{
if(istrue){
MarkTrainFunc()
}
},[ClassID])
const ClassChange=(event)=>{
setClassID(event.target.value)
}
const click=()=>{
console.log(ClassID);
console.log(MarkData);
}
return(
<div className='body-right-mark'>
<select className='mark-list'>
<option value="2024级一班">2024级一班</option>
<option value="2024级二班">2024级二班</option>
<option value="2024级三班">2024级三班</option>
</select>
<div className='test-mark'>
{selectClass&&<select className='mark-list' onChange={ClassChange}>
{Object.keys(selectClass).map((key)=>(
<option value={key} key={key} >{key}</option>
))}
</select>}
{MarkData&&<div className='test-mark'>
{/* 内容 */}
<ul>
{[{class:'课程1:达梦数据库的安装',time:"关闭时间:2024-4-16 11.46",ImgSrc:Test},
{class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Test},
{class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Test},
].map((item) =>
<Link style={{color:'#000',textDecoration:'none'}} to={'studentlink'}>
<li key={item.class}>
<img src={item.ImgSrc} alt="" width='35px' height='35px'/>
<p>
<p className='p-mark'>{item.class}</p>
<span>{item.time}</span>
</p>
</li>
</Link>
)}
{Object.keys(MarkData).map((key)=>(
<Link style={{color:'#000',textDecoration:'none'}} to={`studentlink/Mark/${key}`}>
<li key={key}>
<img src={Test} alt="" width='35px' height='35px'/>
<p>
<p className='p-mark'><span>实训ID:{MarkData[key][0][10]}</span>{eval(MarkData[key][0][11])}</p>
<span>{MarkData[key][0][6]}</span><span></span>
</p>
</li>
</Link>
))}
</ul>
</div>
<button onClick={click}>asda</button>
</div>}
</div>
)

View File

@ -1,8 +1,33 @@
import './StudentLink.css'
import { useParams } from 'react-router-dom';
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import axios from 'axios';
function StudentLink(){
const testID=useParams()['key']
const submit=()=>{
console.log(TestLink);
}
const [TestLink,setTestLink]=useState()
const NotMarkTestFunc=async ()=>{
try{
const NotMarkTestSrc=await axios.post('/api/teacher/NotMarkTest',{
testID
})
setTestLink(NotMarkTestSrc.data['result'])
}catch{
alert('出错')
}
}
useEffect(()=>{
NotMarkTestFunc()
},[])
return(
<div className='body-right-studentlink'>
<table>
@ -13,14 +38,17 @@ function StudentLink(){
<th>分数</th>
</tr>
</thead>
<tbody>
<tr>
<td>数据1</td>
<td>数据2</td>
<td>数据3</td>
{TestLink&&<tbody>
{Object.keys(TestLink).map((key)=>(
<tr key={key}>
<td>{key}</td>
<td><Link to={TestLink[key][6]}>{TestLink[key][6]}</Link></td>
<td><input type="text" name="" id="" /></td>
</tr>
</tbody>
))}
</tbody>}
</table>
<button onClick={submit}>提交</button>
</div>
)
}

View File

@ -123,14 +123,14 @@ function SendTest(){
<button>基础题</button>
<ul style={{all:'unset'}}>
<li>第一章</li>
<li>第二章</li>
<li>第二章</li>
</ul>
</li>
</ul>
</div>
<div className='SendTest_body_right'>
<p>题目选择</p>
{<table>
{question&&<table>
<span className='title'>选择题</span>
{Object.keys(question['choice']).map((key)=>(
<tr key={key}>
@ -207,11 +207,6 @@ function SendTest(){
</table>}
<button onClick={SendTrainBtn} id='SendTrainBtn'>发布按钮</button>
</div>
{/* 右边的内容 */}

View File

@ -202,9 +202,8 @@
.calendar-box span{
position: absolute;
/* top: 20px; */
top: 380px;
right: 160px;
top: 400px;
right: 185px;
}
.calendar1{
width: 100px;

View File

@ -3,7 +3,8 @@ import { Link } from 'react-router-dom';
import './SendTrain.css'
import axios from 'axios';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import "react-datepicker/dist/react-datepicker.css";
function SendTrain(){
const teacher_ID=localStorage.getItem('islogin')
@ -77,7 +78,9 @@ function SendTrain(){
StopTime,
selectedItems,
Train,
teacher_ID
teacher_ID,
startDate,
endDate
})
alert('发布成功')
window.location.href='/teacher/trainmanage'
@ -89,7 +92,7 @@ function SendTrain(){
const SendTrainBtn=()=>{
if(selectedItems.length>0 && (HourValue || MinValue)&&StopTime){
if(selectedItems.length>0 && (HourValue || MinValue)){
if(Train.length>0){
SendTrainTest()
}else{
@ -133,34 +136,19 @@ function SendTrain(){
}
//
const [StopTime,SetStopTime]=useState('')
const getstoptime=(event)=>{
SetStopTime(event.target.value)
}
//
//
const [startDate, setStartDate] = useState(new Date());
const [endDate, setEndDate] = useState(new Date());
//
const formatDate = (date) => {
return date.toLocaleDateString();
};
//
//
const handleStartDateChange = (date) => {
setStartDate(date);
};
//
const handleEndDateChange = (date) => {
setEndDate(date);
};
//
const calculateTotalDays = () => {
const differenceInTime = endDate - startDate;
const differenceInDays = Math.floor(differenceInTime / (1000 * 60 * 60 * 24));
return differenceInDays;
};
useEffect(() => {
console.log(calculateTotalDays());
}, [startDate, endDate]);
return(
<div className='SendTrain_body'>
@ -204,7 +192,7 @@ function SendTrain(){
<input type="checkbox" className='check_box' onClick={(event)=>{
if (event.target.checked) {
//ID
setTrainChoice(items=>([
setTrainChoice(items=>([
...items,
Trainquestion['choice'][key][7]
]))
@ -334,10 +322,10 @@ function SendTrain(){
<option value={num} key={num}>{num}</option>
))}
</select>小时
{/* <button onClick={()=>{
console.log(selectedItems);
console.log(Train);
}}>asd</button> */}
<button onClick={()=>{
console.log(startDate);
console.log(endDate);
}}>asd</button>
<select name="" id="" value={MinValue} onChange={getminvalue}>
{min_list.map((num)=>(
<option value={num} key={num}>{num}</option>
@ -346,30 +334,35 @@ function SendTrain(){
{/* 日历 */}
<p>请填写考试开始截止日期</p>
<div className='calendar-box'>
<DatePicker
selected={startDate}
onChange={handleStartDateChange}
dateFormat="yyyy/MM/dd"
placeholderText="选择开始日期"
popperPlacement="left-start"
className='calendar1'
/>
<span>-</span>
<DatePicker
selected={endDate}
onChange={handleEndDateChange}
dateFormat="yyyy/MM/dd"
placeholderText="选择结束日期"
minDate={startDate} //
withFullScreenPortal={false} //
popperPlacement="left-start"
className='calendar2'
/>
{/* 开始时间输入框 */}
<div className='start-date-input'>
{/* 日历组件 */}
<div className='calendar-picker'>
<DatePicker
selected={startDate}
onChange={handleStartDateChange}
dateFormat="yyyy-MM-dd HH:mm"
showTimeSelect
timeIntervals={10} //
timeCaption="time"
minDate={new Date()} //
/>
<DatePicker
selected={endDate}
onChange={handleEndDateChange}
dateFormat="yyyy-MM-dd HH:mm"
showTimeSelect
timeIntervals={10}
timeCaption="time"
minDate={startDate || new Date()} //
/>
</div>
</div>
</div>
<p className='data-num'>总天数{calculateTotalDays()}</p>
</div>
</div>
</div>
</div>
</div>
)
}

View File

@ -43,10 +43,6 @@ const WarningModal = ({ isOpen, onClose }) => {
return null;
};
const list4=[
{'train':'实训3待定',id:'3'},
{'train':'实训4待定',id:'4'}
]
//
function SubjectPage(){
@ -94,6 +90,7 @@ function SubjectPage(){
{Object.keys(title).map((key)=>(
<div className='test-box-training' key={key}>
<p>实训:{eval(title[key][0][11])}</p>
<span>实训ID:{(title[key][0][10])}</span>
<span>发布者:陈老师</span>
<div>发布时间:{title[key][0][5]}</div>
<div>截至时间:{title[key][0][6]}</div>

View File

@ -27,6 +27,10 @@ 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';
// (exam)使
const MainLayout = ({ headerNav:HeaderNav }) => {
return (
@ -61,7 +65,7 @@ function App() {
<Route path='mark' element={<Marking/>}/> {/* 批改 */}
<Route path='managetest' element={<ManageTest />}/> {/* 考试管理 */}
<Route path="classID/:key" element={<ClassID />} /> {/* 班级管理1 */}
<Route path='mark/studentlink' element={<StudentLink/>}/> {/* 批改1 */}
<Route path='mark/studentlink/Mark/:key' element={<StudentLink/>}/> {/* 批改1 */}
{/* 其他需要HeaderNavTeacher的页面 */}
</Route>

View File

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

View File

@ -197,6 +197,12 @@ def select_class(): # 查找每个老师管理的班级 以及在考试管理
# print(testID)
return jsonify({'Class': class_dic,'default': find_default_class_func(default_class, teacher_id)})
@app.route('/api/teacher/marktrain',methods=['POST'])
def mark(): # 批阅试卷
ClassID=request.json['ClassID']
teacher_ID=request.json['teacher_ID']
return jsonify({'MarkClass': MarkTrainFunc(ClassID,teacher_ID)})
@app.route('/api/teacher/change_class', methods=['POST'])
def change_class(): # 查找每个老师管理的班级 以及在考试管理查找默认班级
teacher_id = request.json['teacher_ID']
@ -343,5 +349,6 @@ def handle_disconnect():
if __name__ == '__main__':
socketio.run(app, host='0.0.0.0', port=5000, debug=True)
socketio.run(app, host='0.0.0.0', port=5000 ,allow_unsafe_werkzeug=True, debug=True)

View File

@ -252,12 +252,22 @@ def FetchTrainTitleFunc(ID):
titles.append(i[2])
for i in titles:
cursor.execute('SELECT * FROM TRAINTEST WHERE ID=? ',(i))
title.append(cursor.fetchall())
cursor.execute('SELECT * FROM TRAINTEST WHERE ID=? AND STOPTIME>? ',(i,Time))
result=cursor.fetchall()
title.append(result)
if result:
pass
else:
cursor.execute("UPDATE TRAINSCORE SET TF='true' , RESULT='0' , TRAINRESULT='0' WHERE TEST_ID=? AND STUDENT_ID=?",(i,ID))
title = [item for item in title if item]
print(title)
db.commit()
cursor.close()
return title
# FetchTrainTitleFunc("20240101")
def FetchTrainTestFunc(operateID):

View File

@ -7,6 +7,8 @@ import datetime
db = dmPython.connect(user='SYSDBA', password='dameng!!', host="36.138.114.105", port="32522")
#获取题目
def choice_question_func(ID):
question_cursor = db.cursor()
@ -218,24 +220,26 @@ def train_question():
# print(Train)
return Train
testID=None
TrainName=""
# train_question()
def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,Class,Train,teacher_id):
def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,Class,Train,teacher_id,startTime,endTime):
TrainChoice = json.dumps(TrainChoice)
TrainCompletion = json.dumps(TrainCompletion)
TrainJudge = json.dumps(TrainJudge)
Class=json.dumps(Class)
Train=json.dumps(Train)
# 获取当前时间
now_time = datetime.datetime.now().replace(microsecond=0)
end_time = now_time + datetime.timedelta(days=int(StopTime))
end_time = end_time.replace(microsecond=0)
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,now_time,end_time,Class,'Train',teacher_id,Train))
f'(?,?,?,?,?,?,?,?,?,?,?)',(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,startTime,endTime,Class,'Train',teacher_id,Train))
db.commit()
print('添加成功')
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]
# 查找学生
student_list = []
@ -258,13 +262,27 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,C
(i, i[0:6], test_id, end,one))
# 发布实训的时候根据实训不同给予不同链接
cursor.execute(f"SELECT ID FROM TRAINTEST WHERE RELEASETIME=? ", (now_time))
test_id = cursor.fetchall()[0][0]
global testID
testID=test_id
print('分配成功')
db.commit()
cursor.close()
return '发布成功'
def TeacherMark(CLASS,ID):
global testID
global TrainName
cursor = db.cursor()
strClass=str(CLASS)
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))
db.commit()
cursor.close()
# def Find_dic(dic):
# # 获取字典的键,并按照从大到小的顺序排序
# keys_sorted = sorted(dic.keys(), reverse=True)
@ -291,3 +309,30 @@ def Find_details_Func(ID):
return dic
# print(Find_details('20240101'))
#获取未批改的卷子
def MarkTrainFunc(ClassID,teacher_ID):
dic={}
cursor = db.cursor()
cursor.execute(f"SELECT * FROM TEACHERMARK WHERE CLASS=? AND TEACHERID=? AND TF='false'", (ClassID,teacher_ID))
for i in cursor.fetchall():
cursor.execute(f"SELECT * FROM TRAINTEST WHERE ID=? ", (i[1],))
dic[i[1]]=cursor.fetchall()
# print(dic)
return dic
# MarkTrainFunc('202401','111111')
def NotMarkTest(testID):
cursor = db.cursor()
dic={}
cursor.execute(f'SELECT * FROM TRAINSCORE WHERE TEST_ID=?',(testID))
for i in cursor.fetchall():
cursor.execute(f'SELECT NAME FROM STUDENT WHERE ID=?',(i[0]))
dic[cursor.fetchall()[0][0]]=i
return dic
NotMarkTest('9')

5
python/test.py Normal file
View File

@ -0,0 +1,5 @@
TrainName='["\u524d\u7aef\u4e0e\u6570\u636e\u5e93\u7ed3\u5408"]'
print(TrainName)
print(type(TrainName))
if TrainName == '["\u524d\u7aef\u4e0e\u6570\u636e\u5e93\u7ed3\u5408"]':
print('yes')