This commit is contained in:
parent
915992d8de
commit
2420365c72
|
@ -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'>{eval(MarkData[key][0][11])}</p>
|
||||
<span>{}</span><span></span>
|
||||
</p>
|
||||
</li>
|
||||
</Link>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<button onClick={click}>asda</button>
|
||||
</div>}
|
||||
</div>
|
||||
)
|
||||
|
||||
|
|
|
@ -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>
|
||||
{/* 右边的内容 */}
|
||||
|
|
|
@ -133,11 +133,7 @@ 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());
|
||||
|
@ -155,10 +151,12 @@ function SendTrain(){
|
|||
// 计算并显示总天数
|
||||
const calculateTotalDays = () => {
|
||||
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;
|
||||
};
|
||||
// const [starTime,setstartTime]=useState()
|
||||
useEffect(() => {
|
||||
SetStopTime(calculateTotalDays())
|
||||
console.log(calculateTotalDays());
|
||||
}, [startDate, endDate]);
|
||||
|
||||
|
@ -334,10 +332,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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -180,6 +180,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']
|
||||
|
@ -239,6 +245,7 @@ def SendTrainTest():
|
|||
Train=data['Train']
|
||||
teacher_id=data['teacher_ID']
|
||||
SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min, StopTime,Class,Train,teacher_id)
|
||||
TeacherMark(Class,teacher_id)
|
||||
return '发布成功'
|
||||
|
||||
|
||||
|
@ -247,7 +254,6 @@ def Find_details():
|
|||
data=request.json
|
||||
ID=data['ID']
|
||||
result=Find_details_Func(ID)
|
||||
print(result)
|
||||
return jsonify({'TestScore':result})
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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,6 +220,9 @@ def train_question():
|
|||
# print(Train)
|
||||
return Train
|
||||
|
||||
|
||||
testID=None
|
||||
TrainName=""
|
||||
# train_question()
|
||||
def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,Class,Train,teacher_id):
|
||||
TrainChoice = json.dumps(TrainChoice)
|
||||
|
@ -225,6 +230,8 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,C
|
|||
TrainJudge = json.dumps(TrainJudge)
|
||||
Class=json.dumps(Class)
|
||||
Train=json.dumps(Train)
|
||||
global TrainName
|
||||
TrainName=Train
|
||||
# 获取当前时间
|
||||
now_time = datetime.datetime.now().replace(microsecond=0)
|
||||
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))
|
||||
|
||||
# 发布实训的时候根据实训不同给予不同链接
|
||||
|
||||
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 +312,17 @@ 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')
|
||||
|
|
|
@ -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