This commit is contained in:
parent
915992d8de
commit
2420365c72
|
@ -3,6 +3,8 @@ import { Link } from 'react-router-dom';
|
||||||
// import axios from 'axios';
|
// import axios from 'axios';
|
||||||
import './Marking.css';
|
import './Marking.css';
|
||||||
import Test from '../../pages/Home/img/test.jpg'
|
import Test from '../../pages/Home/img/test.jpg'
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
// 批改
|
// 批改
|
||||||
function Marking(){
|
function Marking(){
|
||||||
|
@ -12,33 +14,80 @@ function Marking(){
|
||||||
window.location.href='http://36.138.114.105:30294/'
|
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(
|
return(
|
||||||
<div className='body-right-mark'>
|
<div className='body-right-mark'>
|
||||||
<select className='mark-list'>
|
{selectClass&&<select className='mark-list' onChange={ClassChange}>
|
||||||
<option value="2024级一班">2024级一班</option>
|
{Object.keys(selectClass).map((key)=>(
|
||||||
<option value="2024级二班">2024级二班</option>
|
<option value={key} key={key} >{key}</option>
|
||||||
<option value="2024级三班">2024级三班</option>
|
))}
|
||||||
</select>
|
</select>}
|
||||||
<div className='test-mark'>
|
{MarkData&&<div className='test-mark'>
|
||||||
{/* 内容 */}
|
{/* 内容 */}
|
||||||
<ul>
|
<ul>
|
||||||
{[{class:'课程1:达梦数据库的安装',time:"关闭时间:2024-4-16 11.46",ImgSrc:Test},
|
{Object.keys(MarkData).map((key)=>(
|
||||||
{class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Test},
|
<Link style={{color:'#000',textDecoration:'none'}} to={`studentlink/Mark/${key}`}>
|
||||||
{class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Test},
|
<li key={key}>
|
||||||
].map((item) =>
|
<img src={Test} alt="" width='35px' height='35px'/>
|
||||||
<Link style={{color:'#000',textDecoration:'none'}} to={'studentlink'}>
|
<p>
|
||||||
<li key={item.class}>
|
<p className='p-mark'>{eval(MarkData[key][0][11])}</p>
|
||||||
<img src={item.ImgSrc} alt="" width='35px' height='35px'/>
|
<span>{}</span><span></span>
|
||||||
<p>
|
</p>
|
||||||
<p className='p-mark'>{item.class}</p>
|
</li>
|
||||||
<span>{item.time}</span>
|
</Link>
|
||||||
</p>
|
))}
|
||||||
</li>
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<button onClick={click}>asda</button>
|
||||||
</div>
|
</div>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ function SendTest(){
|
||||||
</div>
|
</div>
|
||||||
<div className='SendTest_body_right'>
|
<div className='SendTest_body_right'>
|
||||||
<p>题目选择</p>
|
<p>题目选择</p>
|
||||||
{<table>
|
{question&&<table>
|
||||||
<span className='title'>选择题</span>
|
<span className='title'>选择题</span>
|
||||||
{Object.keys(question['choice']).map((key)=>(
|
{Object.keys(question['choice']).map((key)=>(
|
||||||
<tr key={key}>
|
<tr key={key}>
|
||||||
|
@ -207,11 +207,6 @@ function SendTest(){
|
||||||
</table>}
|
</table>}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<button onClick={SendTrainBtn} id='SendTrainBtn'>发布按钮</button>
|
<button onClick={SendTrainBtn} id='SendTrainBtn'>发布按钮</button>
|
||||||
</div>
|
</div>
|
||||||
{/* 右边的内容 */}
|
{/* 右边的内容 */}
|
||||||
|
|
|
@ -133,11 +133,7 @@ function SendTrain(){
|
||||||
}
|
}
|
||||||
//获取截止时间
|
//获取截止时间
|
||||||
const [StopTime,SetStopTime]=useState('')
|
const [StopTime,SetStopTime]=useState('')
|
||||||
const getstoptime=(event)=>{
|
|
||||||
SetStopTime(event.target.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 日历
|
|
||||||
// 用于存储开始日期和结束日期的状态
|
// 用于存储开始日期和结束日期的状态
|
||||||
const [startDate, setStartDate] = useState(new Date());
|
const [startDate, setStartDate] = useState(new Date());
|
||||||
const [endDate, setEndDate] = useState(new Date());
|
const [endDate, setEndDate] = useState(new Date());
|
||||||
|
@ -155,10 +151,12 @@ function SendTrain(){
|
||||||
// 计算并显示总天数
|
// 计算并显示总天数
|
||||||
const calculateTotalDays = () => {
|
const calculateTotalDays = () => {
|
||||||
const differenceInTime = endDate - startDate;
|
const differenceInTime = endDate - startDate;
|
||||||
const differenceInDays = Math.floor(differenceInTime / (1000 * 60 * 60 * 24));
|
const differenceInDays = Math.floor(differenceInTime / (1000 * 60 * 60 * 24)+1);
|
||||||
return differenceInDays;
|
return differenceInDays;
|
||||||
};
|
};
|
||||||
|
// const [starTime,setstartTime]=useState()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
SetStopTime(calculateTotalDays())
|
||||||
console.log(calculateTotalDays());
|
console.log(calculateTotalDays());
|
||||||
}, [startDate, endDate]);
|
}, [startDate, endDate]);
|
||||||
|
|
||||||
|
@ -334,10 +332,10 @@ function SendTrain(){
|
||||||
<option value={num} key={num}>{num}</option>
|
<option value={num} key={num}>{num}</option>
|
||||||
))}
|
))}
|
||||||
</select>小时
|
</select>小时
|
||||||
{/* <button onClick={()=>{
|
<button onClick={()=>{
|
||||||
console.log(selectedItems);
|
console.log(startDate);
|
||||||
console.log(Train);
|
console.log(endDate);
|
||||||
}}>asd</button> */}
|
}}>asd</button>
|
||||||
<select name="" id="" value={MinValue} onChange={getminvalue}>
|
<select name="" id="" value={MinValue} onChange={getminvalue}>
|
||||||
{min_list.map((num)=>(
|
{min_list.map((num)=>(
|
||||||
<option value={num} key={num}>{num}</option>
|
<option value={num} key={num}>{num}</option>
|
||||||
|
|
|
@ -43,10 +43,6 @@ const WarningModal = ({ isOpen, onClose }) => {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const list4=[
|
|
||||||
{'train':'实训3:待定',id:'3'},
|
|
||||||
{'train':'实训4:待定',id:'4'}
|
|
||||||
]
|
|
||||||
// 首页 学习分析
|
// 首页 学习分析
|
||||||
function SubjectPage(){
|
function SubjectPage(){
|
||||||
|
|
||||||
|
@ -94,6 +90,7 @@ function SubjectPage(){
|
||||||
{Object.keys(title).map((key)=>(
|
{Object.keys(title).map((key)=>(
|
||||||
<div className='test-box-training' key={key}>
|
<div className='test-box-training' key={key}>
|
||||||
<p>实训:{eval(title[key][0][11])}</p>
|
<p>实训:{eval(title[key][0][11])}</p>
|
||||||
|
<span>实训ID:{(title[key][0][10])}</span>
|
||||||
<span>发布者:陈老师</span>
|
<span>发布者:陈老师</span>
|
||||||
<div>发布时间:{title[key][0][5]}</div>
|
<div>发布时间:{title[key][0][5]}</div>
|
||||||
<div>截至时间:{title[key][0][6]}</div>
|
<div>截至时间:{title[key][0][6]}</div>
|
||||||
|
|
|
@ -180,6 +180,12 @@ def select_class(): # 查找每个老师管理的班级 以及在考试管理
|
||||||
# print(testID)
|
# print(testID)
|
||||||
return jsonify({'Class': class_dic,'default': find_default_class_func(default_class, teacher_id)})
|
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'])
|
@app.route('/api/teacher/change_class', methods=['POST'])
|
||||||
def change_class(): # 查找每个老师管理的班级 以及在考试管理查找默认班级
|
def change_class(): # 查找每个老师管理的班级 以及在考试管理查找默认班级
|
||||||
teacher_id = request.json['teacher_ID']
|
teacher_id = request.json['teacher_ID']
|
||||||
|
@ -239,6 +245,7 @@ def SendTrainTest():
|
||||||
Train=data['Train']
|
Train=data['Train']
|
||||||
teacher_id=data['teacher_ID']
|
teacher_id=data['teacher_ID']
|
||||||
SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min, StopTime,Class,Train,teacher_id)
|
SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min, StopTime,Class,Train,teacher_id)
|
||||||
|
TeacherMark(Class,teacher_id)
|
||||||
return '发布成功'
|
return '发布成功'
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,7 +254,6 @@ def Find_details():
|
||||||
data=request.json
|
data=request.json
|
||||||
ID=data['ID']
|
ID=data['ID']
|
||||||
result=Find_details_Func(ID)
|
result=Find_details_Func(ID)
|
||||||
print(result)
|
|
||||||
return jsonify({'TestScore':result})
|
return jsonify({'TestScore':result})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -252,12 +252,22 @@ def FetchTrainTitleFunc(ID):
|
||||||
titles.append(i[2])
|
titles.append(i[2])
|
||||||
|
|
||||||
for i in titles:
|
for i in titles:
|
||||||
cursor.execute('SELECT * FROM TRAINTEST WHERE ID=? ',(i))
|
cursor.execute('SELECT * FROM TRAINTEST WHERE ID=? AND STOPTIME>? ',(i,Time))
|
||||||
title.append(cursor.fetchall())
|
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()
|
cursor.close()
|
||||||
return title
|
return title
|
||||||
|
|
||||||
|
# FetchTrainTitleFunc("20240101")
|
||||||
|
|
||||||
|
|
||||||
def FetchTrainTestFunc(operateID):
|
def FetchTrainTestFunc(operateID):
|
||||||
|
|
|
@ -7,6 +7,8 @@ import datetime
|
||||||
|
|
||||||
db = dmPython.connect(user='SYSDBA', password='dameng!!', host="36.138.114.105", port="32522")
|
db = dmPython.connect(user='SYSDBA', password='dameng!!', host="36.138.114.105", port="32522")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#获取题目
|
#获取题目
|
||||||
def choice_question_func(ID):
|
def choice_question_func(ID):
|
||||||
question_cursor = db.cursor()
|
question_cursor = db.cursor()
|
||||||
|
@ -218,6 +220,9 @@ def train_question():
|
||||||
# print(Train)
|
# print(Train)
|
||||||
return Train
|
return Train
|
||||||
|
|
||||||
|
|
||||||
|
testID=None
|
||||||
|
TrainName=""
|
||||||
# train_question()
|
# train_question()
|
||||||
def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,Class,Train,teacher_id):
|
def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,Class,Train,teacher_id):
|
||||||
TrainChoice = json.dumps(TrainChoice)
|
TrainChoice = json.dumps(TrainChoice)
|
||||||
|
@ -225,6 +230,8 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,C
|
||||||
TrainJudge = json.dumps(TrainJudge)
|
TrainJudge = json.dumps(TrainJudge)
|
||||||
Class=json.dumps(Class)
|
Class=json.dumps(Class)
|
||||||
Train=json.dumps(Train)
|
Train=json.dumps(Train)
|
||||||
|
global TrainName
|
||||||
|
TrainName=Train
|
||||||
# 获取当前时间
|
# 获取当前时间
|
||||||
now_time = datetime.datetime.now().replace(microsecond=0)
|
now_time = datetime.datetime.now().replace(microsecond=0)
|
||||||
end_time = now_time + datetime.timedelta(days=int(StopTime))
|
end_time = now_time + datetime.timedelta(days=int(StopTime))
|
||||||
|
@ -258,13 +265,27 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,C
|
||||||
(i, i[0:6], test_id, end,one))
|
(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('分配成功')
|
print('分配成功')
|
||||||
db.commit()
|
db.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
return '发布成功'
|
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):
|
# def Find_dic(dic):
|
||||||
# # 获取字典的键,并按照从大到小的顺序排序
|
# # 获取字典的键,并按照从大到小的顺序排序
|
||||||
# keys_sorted = sorted(dic.keys(), reverse=True)
|
# keys_sorted = sorted(dic.keys(), reverse=True)
|
||||||
|
@ -291,3 +312,17 @@ def Find_details_Func(ID):
|
||||||
return dic
|
return dic
|
||||||
|
|
||||||
# print(Find_details('20240101'))
|
# 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')
|
||||||
|
|
|
@ -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')
|
Loading…
Reference in New Issue