This commit is contained in:
30404 2024-06-26 19:33:02 +08:00
parent 17bd97c9dc
commit f98c0638bf
9 changed files with 244 additions and 282 deletions

View File

@ -1,89 +1,25 @@
#body_left{
flex: 20%;
}
#body_right{
border-left: 1px solid black;
height: 100%;
flex:80%
}
.check_box{ .check_box{
margin-left: 800px; margin-left: 800px;
} }
.single{ .SendTest_body_right tr{
margin-left: 100px; background-color: antiquewhite;
} }
.choice_answer{ .SendTest_body_right p{
display: flex; font-size: 32px;
width: 800px; border: 1px solid black;
background-color: aqua;
}
.choice_answer span{
flex: 1;
}
.line{
border-bottom: 1px solid black;
}
#body_top{
border-bottom: 1px solid black;
width: 100%;
}
#body_left input {
margin-top: 30px;
margin-left: 30px;
}
#next{
margin-left:1450px;
margin-top: 30px;
}
/* 选择班级界面 */
#background{
width: 400px;
height: 550px;
background-color: rgb(149, 224, 224);
position: absolute;
margin-left: 650px;
margin-top: 150px;
}
#class_ul{
width: 200px;
height: 300px;
margin-left: 80px;
background-color: rgb(198, 155, 238);
overflow: auto;
list-style-type: none;
}
.class_div {
/* 普通状态下的样式 */
width: 130px;
height: 30px;
border: 1px solid #ccc;
cursor: pointer;
background-color: bisque;
margin-top: 10px;
margin-left: 15px;
text-align: center; text-align: center;
margin-top: 0px;
margin-bottom: 0px;
} }
.SendTest_body_right table{
.selected { width: 100%;
/* 选中状态下的样式 */ border-left: 1px solid black;
background-color: lightblue; border-right: 1px solid black;
border-color: blue;
} }
#send_box{ .Testbox{
width: 400px; background-color: antiquewhite;
height: 550px; }
background-color: rgb(149, 224, 224); .judgetitletd{
position: absolute; font-size: 20px;
margin-left: 650px; background-color: antiquewhite;
margin-top: 150px;
} }

View File

@ -5,73 +5,43 @@ import React, { useEffect, useState } from 'react';
import axios from 'axios'; import axios from 'axios';
function SendTest(){ function SendTest(){
// const { key } = useParams();
const teacher_ID=localStorage.getItem('islogin') const teacher_ID=localStorage.getItem('islogin')
// //
const [ChoiceQuestion,SetChoiceQuestion]=useState() const [question,Setquestion]=useState()
const [Completion,SetCompletion]=useState() //
const [Judge,SetJudge]=useState() const [Choice,setChoice]=useState([])
const [Completion,setCompletion]=useState([])
const subject = async ()=>{ const [Judge,setJudge]=useState([])
try{ //
const subject_src=await axios.post('/api/teacher/return_question',{
teacher_ID})
SetChoiceQuestion(subject_src.data['选择'])
SetCompletion(subject_src.data['填空'])
SetJudge(subject_src.data['判断'])
}catch(error){
console.log(error);
}
}
useEffect(()=>{
subject()
},[])
//ID
const [ChoiceQuestionSet,SetChoiceQuestionSet]=useState([])
const [CompletionQuestionSet,SetCompletionQuestionSet]=useState([])
const [JudgeQuestionSet,SetJudgeQuestionSet]=useState([])
//
const body=document.getElementById('body')
const background=document.getElementById('background')
const send_box=document.getElementById('send_box')
const [ClassData,SetClassData]=useState([]) const [ClassData,SetClassData]=useState([])
const click_1= async()=>{ const question_func=async()=>{
try{
const Train_question_src=await axios.post('/api/teacher/return_question',{
teacher_ID
})
Setquestion(Train_question_src.data)
}catch{
alert('question_func出错')
}
}
const SeleactClass= async()=>{
try { try {
const select_class_src = await axios.post('/api/teacher/select_class', { const select_class_src = await axios.post('/api/teacher/select_class', {
teacher_ID teacher_ID
}); });
background.style.display='block' SetClassData(select_class_src.data['Class']);
body.style.display='none'
send_box.display='none'
SetClassData(select_class_src.data);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
} }
//
const click_2=()=>{
background.style.display='none'
body.style.display='none'
send_box.style.display='block'
}
// useEffect(()=>{
const last_1=()=>{ question_func()
background.style.display='none' SeleactClass()
body.style.display='block' },[])
send_box.display='none'
}
//
const last_2=()=>{
background.style.display='block'
body.style.display='none'
send_box.style.display='none'
}
// //
const [selectedItems, setSelectedItems] = useState([]); const [selectedItems, setSelectedItems] = useState([]);
@ -85,12 +55,39 @@ function SendTest(){
}; };
const getClassNames = (key) => { const getClassNames = (key) => {
if (selectedItems.includes(key)) { if (selectedItems.includes(key)) {
return 'class_div selected'; return 'Train_class_div Trainselected';
} else { } else {
return 'class_div'; return 'Train_class_div';
} }
}; };
//
const SendTrainTest=async ()=>{
try{
const SendTrainSrc=await axios.post('/api/teacher/accept_test',{
Choice,
Completion,
Judge,
HourValue,
MinValue,
StopTime,
selectedItems,
teacher_ID
})
alert('发布成功')
}catch{
alert('SendTrainTest出错')
}
}
const SendTrainBtn=()=>{
if(selectedItems.length>0 && (HourValue || MinValue)&&StopTime){
SendTrainTest()
}else{
alert('发布信息未完全')
}
}
//00~59 //00~59
const min_list=[] const min_list=[]
for (let i=0;i<=59;i++){ for (let i=0;i<=59;i++){
@ -116,33 +113,113 @@ function SendTest(){
const getstoptime=(event)=>{ const getstoptime=(event)=>{
SetStopTime(event.target.value) SetStopTime(event.target.value)
} }
//
const release= async()=>{
try{
const release_src=await axios.post('/api/teacher/accept_test',{
teacher_ID,
ChoiceQuestionSet,//
CompletionQuestionSet,//
JudgeQuestionSet,//
selectedItems,//
HourValue,//
MinValue,//
StopTime,//
}
)
alert('发布成功')
window.location.href='http://36.138.114.105:30294/teacher/managetest'
}catch{
alert('发布失败')
}
}
return( return(
<div id='big_body'> <div className='SendTrain_body'>
<div id='background' style={{display:'none'}}> <div className='SendTrain_body_left'>
<p style={{marginLeft:'30px'}}>请选择发布班级</p> <ul className='SendTrain_body_left_ul'>
{ ClassData &&<ul style={{marginTop:'70px'}} id='class_ul'> <li><div className='SendTrain_body_left_ul_div'>题目集</div></li>
<li>
<button>基础题</button>
<ul style={{all:'unset'}}>
<li>第一章</li>
<li>第二章</li>
</ul>
</li>
</ul>
</div>
<div className='SendTest_body_right'>
<p>题目选择</p>
{<table>
<span className='title'>选择题</span>
{Object.keys(question['choice']).map((key)=>(
<tr key={key}>
<div>{question['choice'][key][8]}</div>
<tr>
<td className='questiontitle'>.{question['choice'][key][1]}</td>
</tr>
<div className='Train_answer_box'>
<tr>A:{question['choice'][key][2]}</tr>
<tr>B:{question['choice'][key][3]}</tr>
<tr>C:{question['choice'][key][4]}</tr>
<tr>D:{question['choice'][key][5]}</tr>
</div>
<input type="checkbox" className='check_box' onClick={(event)=>{
if (event.target.checked) {
//ID
setChoice(items=>([
...items,
question['choice'][key][7]
]))
}else{
setChoice((items)=>
items.filter((item)=>item!==question['choice'][key][7])
)
}
}} /><span>是否选择</span>
</tr>
))}
<span className='title'>填空题</span>
{Object.keys(question['completion']).map((key)=>(
<tr key={key}>
<td className='Testbox'>
{question['completion'][key][4]}
<td className='questiontitle'>
.{question['completion'][key][1]}
</td>
<input type="checkbox" className='check_box' onClick={(event)=>{
if (event.target.checked) {
//ID
setCompletion(items=>([
...items,
question['completion'][key][3]
]))
}else{
setCompletion((items)=>
items.filter((item)=>item!==question['completion'][key][3])
)
}
}} /><span>是否选择</span>
</td>
</tr>
))}
<span className='title'>判断题</span>
{Object.keys(question['judge']).map((key)=>(
<tr key={key}>
<td className='Testbox'>
{question['judge'][key][4]}
<td className='judgetitletd'>:{question['judge'][key][1]}</td>
<input type="checkbox" className='check_box' onClick={(event)=>{
if (event.target.checked) {
setJudge(items=>([
...items,
question['judge'][key][3]
]))
}else{
setJudge((items)=>
items.filter((item)=>item!==question['judge'][key][3])
)
}
}} /><span>是否选择</span>
</td>
</tr>
))}
</table>}
<button onClick={SendTrainBtn} id='SendTrainBtn'>发布按钮</button>
</div>
{/* 右边的内容 */}
<div className='right_right'>
<div className='OptionBox'>
<div className='TrainSelectClass'>
<p className='TrainSelectClassP'>请选择发布班级</p>
{ ClassData &&<ul id='Train_class_ul'>
{Object.keys(ClassData).map((key)=>( {Object.keys(ClassData).map((key)=>(
<li key={key}> <li key={key}>
<div className={getClassNames(key)} onClick={() => click_div(key)}> <div className={getClassNames(key)} onClick={() => click_div(key)}>
@ -151,17 +228,17 @@ function SendTest(){
</li> </li>
))} ))}
</ul>} </ul>}
<button style={{marginLeft:'110px'}} onClick={last_1}>上一步</button>
<button style={{marginLeft:'80px'}} onClick={click_2}>下一步</button>
</div> </div>
<div id='send_box' style={{display:'none'}}> <div className='TrainSelectTime'>
<button onClick={()=>{
console.log(Choice);
}}></button>
<p>请填写考试时间</p> <p>请填写考试时间</p>
<select name="" id="" alue={HourValue} onChange={gethourvalue}> <select name="" id="" alue={HourValue} onChange={gethourvalue}>
{Object.keys(hour_list).map((num)=>( {Object.keys(hour_list).map((num)=>(
<option value={num} key={num}>{num}</option> <option value={num} key={num}>{num}</option>
))} ))}
</select>小时 </select>小时
<select name="" id="" alue={MinValue} onChange={getminvalue}> <select name="" id="" alue={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>
@ -169,111 +246,10 @@ function SendTest(){
</select>分钟 </select>分钟
<p>请填写截至时间</p> <p>请填写截至时间</p>
<input type="text" maxLength={10} style={{width:'30px'}} value={StopTime} onChange={getstoptime} />天后 <input type="text" maxLength={10} style={{width:'30px'}} value={StopTime} onChange={getstoptime} />天后
<button onClick={last_2}>上一步</button>
<button onClick={release}>发布</button>
</div> </div>
<div id='body' >
<div id='body_top' style={{display:'flex'}}>
<div id='body_left'>
<input type="checkbox" id='choice'/><span>选择题</span><br />
<input type="checkbox" id='fill'/><span>填空</span><br />
<input type="checkbox" id='judge'/><span>判断</span><br />
</div>
<div id='body_right'>
<div id='choice_box'>
<span style={{color:'red'}}>选择题</span>
{ChoiceQuestion && <table>
<thead>
{Object.keys(ChoiceQuestion).map((key)=>(
<tr className='line' key={key}>
<td className='line'>
<p>问题:{ChoiceQuestion[key][1]}</p>
<p className='choice_answer'>
<span>A:{ChoiceQuestion[key][2]}</span>
<span>B:{ChoiceQuestion[key][3]}</span>
<span>C:{ChoiceQuestion[key][4]}</span>
<span>D:{ChoiceQuestion[key][5]}</span>
</p>
{/* 获取题目ID */}
<input type="checkbox" className='check_box' onClick={(event)=>{
if (event.target.checked) {
//ID
SetChoiceQuestionSet(items=>([
...items,
ChoiceQuestion[key][7]
]))
}else{
SetChoiceQuestionSet((items)=>
items.filter((item)=>item!==ChoiceQuestion[key][7])
)
}
}} /><span>是否选择</span>
</td>
</tr>
))}
</thead>
</table>}
</div>
<div id='fill_box'>
<span style={{color:'red'}}>填空题</span>
{ Completion &&<table>
<thead>
{Object.keys(Completion).map((key)=>(
<tr key={key}>
<td className='line'>
<p>问题:{Completion[key][1]}<input type='text' /></p>
<input type="checkbox" className='check_box' onClick={(event)=>{
if(event.target.checked){
SetCompletionQuestionSet(items=>([
...items,
Completion[key][3]
]))
}else{
SetCompletionQuestionSet((items)=>
items.filter((item)=>item!==Completion[key][3]))
}
}}/><span>是否选择</span>
</td>
</tr>
))}
</thead>
</table>}
</div>
<div id='judge_box'>
<span style={{color:'red'}}>判断题</span>
{ Judge &&<table>
<thead>
{Object.keys(Judge).map((key)=>(
<tr key={key}>
<td className='line'>
<p>问题:{Judge[key][1]}</p>
<input type="checkbox" className='check_box' onClick={(event)=>{
if(event.target.checked){
SetJudgeQuestionSet(items=>([
...items,
Judge[key][3]
]))
}else{
SetJudgeQuestionSet((items)=>
items.filter((item)=>item!==Judge[key][3]))
}
}}/><span>是否选择</span>
</td>
</tr>
))}
</thead>
</table>}
</div>
</div>
</div>
<div id='body_btm'>
<button id='next' onClick={click_1}>下一步</button>
</div> </div>
</div> </div>
</div> </div>
) )
} }
export default SendTest export default SendTest

View File

@ -7,7 +7,7 @@ import { Link } from 'react-router-dom';
function TrainManage(){ function TrainManage(){
return( return(
<div className='body-trainmanage'> <div className='body-trainmanage'>
<p>已批改试卷</p> <p>已批改试卷</p>
<div className='line'></div> <div className='line'></div>
<div className='train-list-trainmanage'> <div className='train-list-trainmanage'>
<ul className='ul1-trainmanage'> <ul className='ul1-trainmanage'>

View File

@ -0,0 +1,9 @@
.pods table{
width: 500px;
text-align: center;
border: 1px solid black;
}
.pods p{
line-height: 0px;
margin: 0px;
}

View File

@ -1,6 +1,36 @@
import './list_pods.css'
function List_pods(){ function List_pods(){
return( return(
<div></div> <div className="pods">
<table>
<tr>
<td>Name</td>
<td>TestID</td>
<td>Train</td>
<td>Start</td>
<td>End</td>
</tr>
<tr>
<td colSpan="5"><hr /></td>
</tr>
<tr>
<td>zhoutao</td>
<td>33</td>
<td>0</td>
<td>2024-7-1</td>
<td>2024-7-2</td>
</tr>
<tr>
<td>zhoutao</td>
<td>33</td>
<td>0</td>
<td>2024-7-1</td>
<td>2024-7-2</td>
</tr>
</table>
</div>
) )
} }
export default List_pods export default List_pods

View File

@ -24,6 +24,7 @@ import Marking from '../TeacherPages/MarkingPages/Marking';
import SendTrain from '../TeacherPages/Trainmanage/SendTrain'; import SendTrain from '../TeacherPages/Trainmanage/SendTrain';
import TrainManage from '../TeacherPages/Trainmanage/Trainmanage'; import TrainManage from '../TeacherPages/Trainmanage/Trainmanage';
import StudentLink from '../TeacherPages/MarkingPages/StudentLink'; import StudentLink from '../TeacherPages/MarkingPages/StudentLink';
import List_pods from '../TeacherPages/list_pods/list_pods'
// (exam)使 // (exam)使
const MainLayout = ({ headerNav:HeaderNav }) => { const MainLayout = ({ headerNav:HeaderNav }) => {
@ -73,6 +74,7 @@ function App() {
<Route path='/teacher/SendTrain' element={<SendTrain/>}/> {/*实训管理-发布实训*/} <Route path='/teacher/SendTrain' element={<SendTrain/>}/> {/*实训管理-发布实训*/}
<Route path='operation1/:operateID' element={<Operation1/>}/> {/* 实训页面1 */} <Route path='operation1/:operateID' element={<Operation1/>}/> {/* 实训页面1 */}
<Route path='operation2/:operateID' element={<Operation2/>}/> {/* 实训页面2 */} <Route path='operation2/:operateID' element={<Operation2/>}/> {/* 实训页面2 */}
<Route path='teacher/list_pods' element={<List_pods/>}/>
{/* 独立的顶级路由如登录页面也不包含HeaderNav */} {/* 独立的顶级路由如登录页面也不包含HeaderNav */}
{/* 登录页面 */} {/* 登录页面 */}
<Route path="signin" element={<SignInPage />} /> <Route path="signin" element={<SignInPage />} />

View File

@ -157,7 +157,7 @@ def return_question():
choice_question = choice_question_func(ID) # 调取相应老师科目的题库 choice_question = choice_question_func(ID) # 调取相应老师科目的题库
completion_question = completion_question_func(ID) completion_question = completion_question_func(ID)
t_or_f_question = t_or_f_question_func(ID) t_or_f_question = t_or_f_question_func(ID)
return jsonify({'选择': choice_question, '填空': completion_question, '判断': t_or_f_question}) return jsonify({'choice': choice_question, 'completion': completion_question, 'judge': t_or_f_question})
@app.route('/api/teacher/select_class', methods=['POST']) @app.route('/api/teacher/select_class', methods=['POST'])
@ -199,9 +199,9 @@ def find_student(): # 获取班级学生的具体信息
@app.route('/api/teacher/accept_test', methods=['POST']) # 在前端发布成功之后要存入数据库 @app.route('/api/teacher/accept_test', methods=['POST']) # 在前端发布成功之后要存入数据库
def accept_test(): def accept_test():
data = request.json data = request.json
choice_list = data['ChoiceQuestionSet'] choice_list = data['Choice']
completion_list = data['CompletionQuestionSet'] completion_list = data['Completion']
judge_list = data['JudgeQuestionSet'] judge_list = data['Judge']
hour = data['HourValue'] hour = data['HourValue']
min = data['MinValue'] min = data['MinValue']
stop_time = data['StopTime'] stop_time = data['StopTime']

View File

@ -245,11 +245,20 @@ def SendTrainTestFunc(TrainChoice,TrainCompletion,TrainJudge,Hour,Min,StopTime,C
end = 'false' end = 'false'
# 将试卷分配到每一个学生 # 将试卷分配到每一个学生
for i in student_list: zero='https://www.baidu.com/'
cursor.execute("INSERT INTO TrainScore (STUDENT_ID,CLASS,TEST_ID,TF) VALUES (?,?,?,?)", one='https://www.douyin.com/'
(i, i[0:6], test_id, end))
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))
# 发布实训的时候根据实训不同给予不同链接
print('分配成功') print('分配成功')
db.commit() db.commit()
cursor.close() cursor.close()