From f98c0638bf8d3a7fe9ca2f407a0ca60ac59cda07 Mon Sep 17 00:00:00 2001 From: 30404 <3040471803@qq.com> Date: Wed, 26 Jun 2024 19:33:02 +0800 Subject: [PATCH] 2321 --- .../src/TeacherPages/TestManage/SendTest.css | 98 +---- .../src/TeacherPages/TestManage/SendTest.jsx | 358 ++++++++---------- .../TeacherPages/Trainmanage/Trainmanage.jsx | 2 +- .../TeacherPages/classlistpages/classId.jsx | 2 +- .../src/TeacherPages/list_pods/List_pods.css | 9 + .../src/TeacherPages/list_pods/List_pods.jsx | 32 +- app-dm/src/router/index.jsx | 2 + python/app.py | 8 +- python/teacher_func.py | 15 +- 9 files changed, 244 insertions(+), 282 deletions(-) diff --git a/app-dm/src/TeacherPages/TestManage/SendTest.css b/app-dm/src/TeacherPages/TestManage/SendTest.css index ad79a71..102e1e6 100644 --- a/app-dm/src/TeacherPages/TestManage/SendTest.css +++ b/app-dm/src/TeacherPages/TestManage/SendTest.css @@ -1,89 +1,25 @@ -#body_left{ - flex: 20%; -} - - - -#body_right{ - border-left: 1px solid black; - height: 100%; - flex:80% -} .check_box{ margin-left: 800px; } -.single{ - margin-left: 100px; +.SendTest_body_right tr{ + background-color: antiquewhite; } -.choice_answer{ - display: flex; - width: 800px; - 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; +.SendTest_body_right p{ + font-size: 32px; + border: 1px solid black; text-align: center; + margin-top: 0px; + margin-bottom: 0px; } - -.selected { - /* 选中状态下的样式 */ - background-color: lightblue; - border-color: blue; +.SendTest_body_right table{ + width: 100%; + border-left: 1px solid black; + border-right: 1px solid black; } -#send_box{ - width: 400px; - height: 550px; - background-color: rgb(149, 224, 224); - position: absolute; - margin-left: 650px; - margin-top: 150px; +.Testbox{ + background-color: antiquewhite; } +.judgetitletd{ + font-size: 20px; + background-color: antiquewhite; +} \ No newline at end of file diff --git a/app-dm/src/TeacherPages/TestManage/SendTest.jsx b/app-dm/src/TeacherPages/TestManage/SendTest.jsx index 955d440..4ae2686 100644 --- a/app-dm/src/TeacherPages/TestManage/SendTest.jsx +++ b/app-dm/src/TeacherPages/TestManage/SendTest.jsx @@ -5,74 +5,44 @@ import React, { useEffect, useState } from 'react'; import axios from 'axios'; function SendTest(){ - // const { key } = useParams(); const teacher_ID=localStorage.getItem('islogin') - //获取题目 - const [ChoiceQuestion,SetChoiceQuestion]=useState() - const [Completion,SetCompletion]=useState() - const [Judge,SetJudge]=useState() + //获取所有基础题的所有题目 + const [question,Setquestion]=useState() + //得到题目 + const [Choice,setChoice]=useState([]) + const [Completion,setCompletion]=useState([]) + const [Judge,setJudge]=useState([]) + //得到班级 + const [ClassData,SetClassData]=useState([]) - const subject = async ()=>{ + const question_func=async()=>{ 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); + const Train_question_src=await axios.post('/api/teacher/return_question',{ + teacher_ID + }) + Setquestion(Train_question_src.data) + }catch{ + alert('question_func出错') } } - 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 click_1= async()=>{ + const SeleactClass= async()=>{ try { const select_class_src = await axios.post('/api/teacher/select_class', { teacher_ID }); - background.style.display='block' - body.style.display='none' - send_box.display='none' - SetClassData(select_class_src.data); + SetClassData(select_class_src.data['Class']); } catch (error) { console.log(error); } } - //下下一步操作 - const click_2=()=>{ - background.style.display='none' - body.style.display='none' - send_box.style.display='block' - } - //上一步的操作 - const last_1=()=>{ - background.style.display='none' - body.style.display='block' - send_box.display='none' - } - //上上一步操作 - const last_2=()=>{ - background.style.display='block' - body.style.display='none' - send_box.style.display='none' - } - + useEffect(()=>{ + question_func() + SeleactClass() + },[]) + //选中班级的状态变化 const [selectedItems, setSelectedItems] = useState([]); @@ -85,12 +55,39 @@ function SendTest(){ }; const getClassNames = (key) => { if (selectedItems.includes(key)) { - return 'class_div selected'; + return 'Train_class_div Trainselected'; } 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 const min_list=[] for (let i=0;i<=59;i++){ @@ -116,34 +113,114 @@ function SendTest(){ const getstoptime=(event)=>{ 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( -
-
-

请选择发布班级

- { ClassData &&