Merge branch 'master' of https://gitea.xn--7p0a.site/2312072104/dm
This commit is contained in:
commit
915992d8de
|
@ -11,11 +11,10 @@ import { max, min } from 'lodash';
|
||||||
|
|
||||||
// 首页
|
// 首页
|
||||||
function Home(){
|
function Home(){
|
||||||
const [isChecked,setisChecked]=useState(false)
|
|
||||||
const student_ID=localStorage.getItem('islogin')
|
const student_ID=localStorage.getItem('islogin')
|
||||||
if(student_ID==null){
|
if(student_ID==null){
|
||||||
|
window.location.href='http://localhost:3000/signin'
|
||||||
alert('未登录,请先前往登录')
|
alert('未登录,请先前往登录')
|
||||||
window.location.href='http://36.138.114.105:30294/'
|
|
||||||
}
|
}
|
||||||
//课表数据
|
//课表数据
|
||||||
const [lesson, setLesson] = useState([]);
|
const [lesson, setLesson] = useState([]);
|
||||||
|
|
|
@ -119,4 +119,13 @@
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.body-right1-exam{
|
||||||
|
width: 1414px;
|
||||||
|
height: 1540px;
|
||||||
|
position: absolute;
|
||||||
|
top: 64px;
|
||||||
|
left: 230px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: #f7f8fa;
|
||||||
}
|
}
|
|
@ -10,10 +10,66 @@ import top from '../img/top.jpg'
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
function Exam() {
|
function Exam() {
|
||||||
|
|
||||||
|
|
||||||
//倒计时
|
//倒计时
|
||||||
const [countdown, setCountdown] = useState(null);
|
const [countdown, setCountdown] = useState(null);
|
||||||
|
const {examId}=useParams()
|
||||||
|
const student_ID=localStorage.getItem('islogin')
|
||||||
|
const [score,setscore]=useState(0)
|
||||||
|
const [isEntry,setisEntry]=useState(false)
|
||||||
|
|
||||||
|
//获取题目
|
||||||
|
const [TestData,setTestData]=useState()
|
||||||
|
const TestFunc=async ()=>{
|
||||||
|
try{
|
||||||
|
const TestSrc=await axios.post('/api/student/TestData',{
|
||||||
|
examId
|
||||||
|
})
|
||||||
|
const data=TestSrc.data
|
||||||
|
setTestData(data)
|
||||||
|
}catch{
|
||||||
|
alert('TestSrc出错')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
TestFunc()
|
||||||
|
},[])
|
||||||
|
|
||||||
|
|
||||||
|
//添加成绩
|
||||||
|
const scoreEntry=async()=>{
|
||||||
|
try{
|
||||||
|
const scoreEntrySrc=await axios.post('/api/student/score_entry',{
|
||||||
|
student_ID,
|
||||||
|
examId,
|
||||||
|
score
|
||||||
|
})
|
||||||
|
}catch{
|
||||||
|
alert('scoreEntry出错')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
if(isEntry){
|
||||||
|
scoreEntry()
|
||||||
|
}
|
||||||
|
},[score])
|
||||||
|
|
||||||
|
function daojishi(){
|
||||||
|
if(localStorage.getItem('time')){
|
||||||
|
setCountdown(localStorage.getItem('time'))
|
||||||
|
}else{
|
||||||
|
if(TestData){
|
||||||
|
setCountdown(60 * parseInt(TestData['examID'][3]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
daojishi()
|
||||||
|
console.log('a');
|
||||||
|
},[TestData])
|
||||||
|
|
||||||
|
|
||||||
// 倒计时更新
|
// 倒计时更新
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -24,19 +80,22 @@ function Exam() {
|
||||||
} else {
|
} else {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
alert('考试时间到!');
|
alert('考试时间到!');
|
||||||
|
correct()
|
||||||
|
window.location.href='http://localhost:3000/subject'
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [countdown]);
|
}, [countdown]);
|
||||||
|
|
||||||
// useEffect(()=>{
|
useEffect(()=>{
|
||||||
// if(countdown<0){
|
if(countdown<0){
|
||||||
// console.log('c');
|
localStorage.removeItem('time')
|
||||||
// setCountdown(60 * parseInt(TrainData['operateID'][4]))
|
setCountdown(60 * parseInt(TestData['examID'][3]))
|
||||||
// localStorage.removeItem('time')
|
|
||||||
// }
|
|
||||||
// },[TrainData])
|
|
||||||
|
|
||||||
|
}
|
||||||
|
},[TestData])
|
||||||
|
|
||||||
|
|
||||||
// 转换秒数为时分秒格式
|
// 转换秒数为时分秒格式
|
||||||
const formatTime = (seconds) => {
|
const formatTime = (seconds) => {
|
||||||
const hours = Math.floor(seconds / 3600);
|
const hours = Math.floor(seconds / 3600);
|
||||||
|
@ -48,6 +107,109 @@ function Exam() {
|
||||||
// 下拉菜单
|
// 下拉菜单
|
||||||
const [isSubjectDropdownOpen, setIsSubjectDropdownOpen] = useState(false);
|
const [isSubjectDropdownOpen, setIsSubjectDropdownOpen] = useState(false);
|
||||||
|
|
||||||
|
//创建答案字典,将用户填入的答案添加到答案字典
|
||||||
|
const [choice_answer,setchoice_answer]=useState({})
|
||||||
|
const [completion_answer,setcompletion_answer]=useState({})
|
||||||
|
const [judge_answer,setjudge_answer]=useState({})
|
||||||
|
//选中反馈
|
||||||
|
const [answeredChoice, setAnsweredChoice] = useState([]);
|
||||||
|
const [answeredComple, setAnsweredComple] = useState([]);
|
||||||
|
const [answeredJudge, setAnsweredJudge] = useState([]);
|
||||||
|
|
||||||
|
//给选择题添加事件监听器
|
||||||
|
const handleOptionChange = (event) => {
|
||||||
|
const selectedValue = event.target.value;
|
||||||
|
const key = parseInt(event.target.name.replace('group', ''));
|
||||||
|
const updatedChoiceAnswer = { ...choice_answer, [key]: selectedValue };
|
||||||
|
setchoice_answer(updatedChoiceAnswer);
|
||||||
|
// 更新已做题目的状态
|
||||||
|
if (!answeredChoice.includes(key)) {
|
||||||
|
setAnsweredChoice([...answeredChoice, key]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//填空题
|
||||||
|
const handleInputChange = (event) => {
|
||||||
|
const { name, value } = event.target;
|
||||||
|
setcompletion_answer({
|
||||||
|
...completion_answer,
|
||||||
|
[name]: value
|
||||||
|
});
|
||||||
|
if (!answeredComple.includes(parseInt(name))) {
|
||||||
|
setAnsweredComple([...answeredComple, parseInt(name)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//判断题
|
||||||
|
const handleJudgeOption=(event)=>{
|
||||||
|
const judgeoption=event.target.value;
|
||||||
|
const key=parseInt(event.target.name.replace('judge',''))
|
||||||
|
const updatedJudgeAnswer={ ...judge_answer,[key]:judgeoption}
|
||||||
|
setjudge_answer(updatedJudgeAnswer)
|
||||||
|
if (!answeredJudge.includes(key)) {
|
||||||
|
setAnsweredJudge([...answeredJudge, key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//批改
|
||||||
|
const correct=()=>{
|
||||||
|
let CHO_sum=0;
|
||||||
|
let COM_sum=0;
|
||||||
|
let JUD_sum=0;
|
||||||
|
for(let item of TestData['examID'][0]){
|
||||||
|
if(item[0][6]===choice_answer[CHO_sum]){
|
||||||
|
setscore(prevscore=>prevscore+5)
|
||||||
|
}
|
||||||
|
CHO_sum++
|
||||||
|
}
|
||||||
|
for(let item of TestData['examID'][1]){
|
||||||
|
if (item[0][2]===completion_answer[COM_sum]) {
|
||||||
|
setscore(prevscore=>prevscore+5)
|
||||||
|
}
|
||||||
|
COM_sum++
|
||||||
|
}
|
||||||
|
for(let item of TestData['examID'][2]){
|
||||||
|
if (item[0][2]===judge_answer[JUD_sum]) {
|
||||||
|
setscore(prevscore=>prevscore+5)
|
||||||
|
}
|
||||||
|
JUD_sum++
|
||||||
|
}
|
||||||
|
setisEntry(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const submit=()=>{
|
||||||
|
correct()
|
||||||
|
setCountdown(0)
|
||||||
|
localStorage.removeItem('time')
|
||||||
|
alert('提交成功')
|
||||||
|
window.location.href='http://localhost:3000/subject'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 题目预览框
|
||||||
|
const [isFixed,setIsFixed]=useState(false)
|
||||||
|
// 创建一个函数来处理滚动逻辑
|
||||||
|
const handleScroll = () => {
|
||||||
|
const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
||||||
|
const fixedThreshold = 100; // 滚动到100px后固定
|
||||||
|
|
||||||
|
if (scrollTop > fixedThreshold) {
|
||||||
|
setIsFixed(true);
|
||||||
|
} else {
|
||||||
|
setIsFixed(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 在组件挂载后添加滚动事件监听器,并在卸载时移除
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('scroll', handleScroll);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('scroll', handleScroll);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className='nav-exam'>
|
<div className='nav-exam'>
|
||||||
|
@ -78,32 +240,99 @@ function Exam() {
|
||||||
</ul>
|
</ul>
|
||||||
{/* 题目预览框 */}
|
{/* 题目预览框 */}
|
||||||
{/* 根据isFixed状态来设置countBox的类 */}
|
{/* 根据isFixed状态来设置countBox的类 */}
|
||||||
{/* <div className={`countBox ${isFixed ? 'fixed-count-box' : ''}`}>
|
<div className={`countBox ${isFixed ? 'fixed-count-box' : ''}`}> {/* 根据isFixed状态来设置countBox的类 */}
|
||||||
{TrainData&&<table>
|
{TestData&&<table>
|
||||||
<tr>选择题:</tr>
|
<tr>选择题:</tr>
|
||||||
<div>
|
<div>
|
||||||
{Object.keys(TrainData['operateID'][0]).map((key,index)=>(
|
{Object.keys(TestData['examID'][0]).map((key,index)=>(
|
||||||
<td key={key} className={answeredChoice.includes(index) ? 'answered' : ''}>{index+1}</td>
|
<td key={key} className={answeredChoice.includes(index) ? 'answered' : ''}>{index+1}</td>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<tr>填空题:</tr>
|
<tr>填空题:</tr>
|
||||||
<div>
|
<div>
|
||||||
{Object.keys(TrainData['operateID'][1]).map((key,index)=>(
|
{Object.keys(TestData['examID'][1]).map((key,index)=>(
|
||||||
<td key={key} className={answeredComple.includes(index) ? 'answered' : ''}>{index+1}</td>
|
<td key={key} className={answeredComple.includes(index) ? 'answered' : ''}>{index+1}</td>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<tr>判断题:</tr>
|
<tr>判断题:</tr>
|
||||||
<div>
|
<div>
|
||||||
{Object.keys(TrainData['operateID'][2]).map((key,index)=>(
|
{Object.keys(TestData['examID'][2]).map((key,index)=>(
|
||||||
<td key={key} className={answeredJudge.includes(index) ? 'answered' : ''}>{index+1}</td>
|
<td key={key} className={answeredJudge.includes(index) ? 'answered' : ''}>{index+1}</td>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</table>}
|
</table>}
|
||||||
</div> */}
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className='body-right1'>
|
||||||
|
{TestData&&<table>
|
||||||
|
<p>选择题</p>
|
||||||
|
<tbody>
|
||||||
|
{Object.keys(TestData['examID'][0]).map((key,index) => (
|
||||||
|
<tr key={key}>
|
||||||
|
<tr className='test-title'>{index+1}.{TestData['examID'][0][key][0][1]}</tr>
|
||||||
|
<div className='optionBox'>
|
||||||
|
<label>
|
||||||
|
<input type="radio" value={TestData['examID'][0][key][0][2]} checked={choice_answer[key] === TestData['examID'][0][key][0][2]} onChange={handleOptionChange} name={`group${key}`}/>
|
||||||
|
<span>A.{TestData['examID'][0][key][0][2]}</span>
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<label>
|
||||||
|
<input type="radio" value={TestData['examID'][0][key][0][3]} checked={choice_answer[key] === TestData['examID'][0][key][0][3]} onChange={handleOptionChange} name={`group${key}`}/>
|
||||||
|
<span>B.{TestData['examID'][0][key][0][3]}</span>
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<label>
|
||||||
|
<input type="radio" value={TestData['examID'][0][key][0][4]} checked={choice_answer[key] === TestData['examID'][0][key][0][4]} onChange={handleOptionChange} name={`group${key}`}/>
|
||||||
|
<span>C.{TestData['examID'][0][key][0][4]}</span>
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<label>
|
||||||
|
<input type="radio" value={TestData['examID'][0][key][0][5]} checked={choice_answer[key] === TestData['examID'][0][key][0][5]} onChange={handleOptionChange} name={`group${key}`}/>
|
||||||
|
<span>D.{TestData['examID'][0][key][0][5]}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>}
|
||||||
|
|
||||||
|
{TestData&&(
|
||||||
|
<table className='body-right1-comple'>
|
||||||
|
<tbody>
|
||||||
|
<p>填空题</p>
|
||||||
|
{Object.keys(TestData['examID'][1]).map((key,index)=>(
|
||||||
|
<tr key={key}>
|
||||||
|
<tr className='test-title1'>{index+1}.{TestData['examID'][1][key][0][1]}</tr>
|
||||||
|
{/* <br /> */}
|
||||||
|
<div className='input-box'>
|
||||||
|
<span>请填入你的答案:</span>
|
||||||
|
<input type="text" onChange={handleInputChange} name={key} value={completion_answer[key]||''}/>
|
||||||
|
</div>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{TestData&&(
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<p>判断题</p>
|
||||||
|
{Object.keys(TestData['examID'][2]).map((key,index)=>(
|
||||||
|
<tr key={key} className='panduan-box'>
|
||||||
|
<tr>{index+1}.{TestData['examID'][2][key][0][1]}</tr>
|
||||||
|
<tr>
|
||||||
|
<label><input type="radio" name={`judge${key}`} checked={judge_answer[key] === 'true'} onChange={handleJudgeOption} value={true} />T</label>
|
||||||
|
<label><input type="radio" name={`judge${key}`} checked={judge_answer[key] === 'false'} onChange={handleJudgeOption} value={false} />F</label>
|
||||||
|
</tr>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
<button onClick={submit}>提交</button>
|
||||||
</div>
|
</div>
|
||||||
{/* <div className='body-right1-exam'>
|
|
||||||
|
|
||||||
</div> */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -57,19 +57,18 @@ function SubjectPage(){
|
||||||
))}
|
))}
|
||||||
</div>}
|
</div>}
|
||||||
<h3>已结束或完成的试卷与练习</h3>
|
<h3>已结束或完成的试卷与练习</h3>
|
||||||
{ testdata&& result&&<div className='test-subject'>
|
<div className='test-subject'>
|
||||||
{Object.keys(testdata).map((key)=>{
|
{ Object.keys(testdata).slice(-3).reverse().map((key) => (
|
||||||
return(
|
<div className='test-box' key={key}>
|
||||||
<div className='test-box' key={key}>
|
<p>试卷ID:{testdata[key][0][3]}</p>
|
||||||
<p>试卷ID:{testdata[key][0][3]}</p>
|
<span>发布者:{'小陈老师'}</span>
|
||||||
<span>发布者:{'小陈老师'}</span>
|
<div>发布时间:{testdata[key][1][0][5]}</div>
|
||||||
<div>发布时间:{testdata[key][1][0][5]}</div>
|
<div>截至时间:{testdata[key][1][0][6]}</div>
|
||||||
<div>截至时间:{testdata[key][1][0][6]}</div>
|
<div id='score'>{testdata[key][0][5]}</div>
|
||||||
<div id='score'>{testdata[key][0][5]}</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
))}
|
||||||
})}
|
</div>
|
||||||
</div>}
|
<button>更多历史</button>
|
||||||
{ NotFalse&& result&&<div className='test-subject'>
|
{ NotFalse&& result&&<div className='test-subject'>
|
||||||
{Object.keys(NotFalse).map((key)=>{
|
{Object.keys(NotFalse).map((key)=>{
|
||||||
return(
|
return(
|
||||||
|
|
|
@ -16,19 +16,9 @@ function Operation1() {
|
||||||
console.log(60 * parseInt(TrainData['operateID'][4]));
|
console.log(60 * parseInt(TrainData['operateID'][4]));
|
||||||
}
|
}
|
||||||
const clear=()=>{
|
const clear=()=>{
|
||||||
localStorage.removeItem('choice_answers');
|
['time', 'choice_answers', 'completion_answer', 'judge_answer',
|
||||||
setchoice_answer({})
|
'answeredChoice', 'answeredComple', 'answeredJudge', 'RemainingTime', 'TrainData']
|
||||||
localStorage.removeItem('completion_answer')
|
.forEach(item => localStorage.removeItem(item));
|
||||||
setcompletion_answer({})
|
|
||||||
localStorage.removeItem('judge_answer')
|
|
||||||
setjudge_answer({})
|
|
||||||
localStorage.removeItem('answeredChoice')
|
|
||||||
setAnsweredChoice([])
|
|
||||||
localStorage.removeItem('answeredComple')
|
|
||||||
setAnsweredComple([])
|
|
||||||
localStorage.removeItem('answeredJudge')
|
|
||||||
setAnsweredJudge([])
|
|
||||||
localStorage.removeItem('RemainingTime')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { operateID } = useParams();
|
const { operateID } = useParams();
|
||||||
|
@ -85,7 +75,6 @@ function Operation1() {
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(countdown<0){
|
if(countdown<0){
|
||||||
console.log('c');
|
|
||||||
setCountdown(60 * parseInt(TrainData['operateID'][4]))
|
setCountdown(60 * parseInt(TrainData['operateID'][4]))
|
||||||
localStorage.removeItem('time')
|
localStorage.removeItem('time')
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,8 +146,16 @@ function Operation2() {
|
||||||
const tijiao = ()=>{
|
const tijiao = ()=>{
|
||||||
setCountdown(0)
|
setCountdown(0)
|
||||||
localStorage.removeItem('time')
|
localStorage.removeItem('time')
|
||||||
|
localStorage.removeItem('choice_answers');
|
||||||
|
localStorage.removeItem('completion_answer')
|
||||||
|
localStorage.removeItem('judge_answer')
|
||||||
|
localStorage.removeItem('answeredChoice')
|
||||||
|
localStorage.removeItem('answeredComple')
|
||||||
|
localStorage.removeItem('answeredJudge')
|
||||||
|
localStorage.removeItem('RemainingTime')
|
||||||
alert('提交成功')
|
alert('提交成功')
|
||||||
window.location.href='http://localhost:3000/train'
|
window.location.href='http://localhost:3000/train'
|
||||||
|
localStorage.removeItem('TrainData')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -184,7 +192,7 @@ function Operation2() {
|
||||||
|
|
||||||
<button onClick={click}>测试按钮</button>
|
<button onClick={click}>测试按钮</button>
|
||||||
{/* 前端连接数据库⬇ */}
|
{/* 前端连接数据库⬇ */}
|
||||||
{ !isTrue&&<div>
|
{ !isTrue&&TrainData&&<div>
|
||||||
<Link to={Src}>{TrainData['operateID'][3][0]}</Link>
|
<Link to={Src}>{TrainData['operateID'][3][0]}</Link>
|
||||||
<br />
|
<br />
|
||||||
点击以上链接前往实训
|
点击以上链接前往实训
|
||||||
|
@ -192,7 +200,7 @@ function Operation2() {
|
||||||
{/* 前端连接数据库 ⬆*/}
|
{/* 前端连接数据库 ⬆*/}
|
||||||
|
|
||||||
{/* 达梦数据库连接 ⬇*/}
|
{/* 达梦数据库连接 ⬇*/}
|
||||||
{ isTrue&&
|
{ isTrue&&TrainData&&
|
||||||
<div>
|
<div>
|
||||||
<p>{TrainData['operateID'][3][0]}</p>
|
<p>{TrainData['operateID'][3][0]}</p>
|
||||||
<div style={{width: "1430px",position:'absolute',right:'0'}} ref={terminalObj} onContextMenu={pasteContent}></div>
|
<div style={{width: "1430px",position:'absolute',right:'0'}} ref={terminalObj} onContextMenu={pasteContent}></div>
|
||||||
|
|
|
@ -23,8 +23,8 @@ import ClassID from '../TeacherPages/classlistpages/classId';
|
||||||
import ManageTest from '../TeacherPages/TestManage/ManageTest';
|
import ManageTest from '../TeacherPages/TestManage/ManageTest';
|
||||||
import SendTest from '../TeacherPages/TestManage/SendTest';
|
import SendTest from '../TeacherPages/TestManage/SendTest';
|
||||||
import Marking from '../TeacherPages/MarkingPages/Marking';
|
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';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -103,10 +103,11 @@ def get_test(): # 获取试卷以及历史试卷
|
||||||
result2=falseTest_func(ID)
|
result2=falseTest_func(ID)
|
||||||
return jsonify({"True":result1,'FalseTest':result2})
|
return jsonify({"True":result1,'FalseTest':result2})
|
||||||
|
|
||||||
@app.route('/api/student/get_testID',methods=['POST'])
|
@app.route('/api/student/TestData',methods=['POST'])
|
||||||
def get_testID(): # 获取试卷ID
|
def TestData(): # 获取试卷ID
|
||||||
ID=request.json['student_ID']
|
examID=request.json['examId']
|
||||||
return jsonify({'data': 'a'})
|
result=TestDataFunc(examID)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/student/fetch_result', methods=['POST']) # 查找成绩
|
@app.route('/api/student/fetch_result', methods=['POST']) # 查找成绩
|
||||||
|
@ -115,11 +116,7 @@ def fetch_result():
|
||||||
ID = data['student_ID']
|
ID = data['student_ID']
|
||||||
return jsonify({'result': fetch_result_func(ID)})
|
return jsonify({'result': fetch_result_func(ID)})
|
||||||
|
|
||||||
@app.route('/api/student/get_end_student', methods=['POST'])
|
|
||||||
def get_end_student():
|
|
||||||
data = request.json
|
|
||||||
ID = data['student_ID']
|
|
||||||
return jsonify({'result': find_end_test(ID)})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/student/score_entry', methods=['POST'])
|
@app.route('/api/student/score_entry', methods=['POST'])
|
||||||
|
|
|
@ -120,7 +120,6 @@ def student_succeed_func(ID):
|
||||||
cursor.execute(f'SELECT * FROM STUDENT WHERE ID={ID}')
|
cursor.execute(f'SELECT * FROM STUDENT WHERE ID={ID}')
|
||||||
student_succeed = cursor.fetchall()[0]
|
student_succeed = cursor.fetchall()[0]
|
||||||
student_succeeds = student_succeed[0], student_succeed[1], student_succeed[3], student_succeed[4]
|
student_succeeds = student_succeed[0], student_succeed[1], student_succeed[3], student_succeed[4]
|
||||||
print(student_succeeds)
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
return student_succeeds
|
return student_succeeds
|
||||||
|
|
||||||
|
@ -128,17 +127,27 @@ def student_succeed_func(ID):
|
||||||
# fetch_testID('20240101')
|
# fetch_testID('20240101')
|
||||||
def fetch_test_func(ID):#获取试卷
|
def fetch_test_func(ID):#获取试卷
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
correct=[]
|
||||||
TrueTestDic={}
|
TrueTestDic={}
|
||||||
TruetestID=[]
|
TruetestID=[]
|
||||||
cursor.execute(f"SELECT * FROM STUDENT_TEST WHERE STUDENT_ID=? AND TF='true'",(ID))
|
cursor.execute(f"SELECT * FROM STUDENT_TEST WHERE STUDENT_ID=? AND TF='true'",(ID))
|
||||||
for i in cursor.fetchall():
|
for i in cursor.fetchall():
|
||||||
|
correct.append(i)
|
||||||
|
|
||||||
|
correct=correct[::-1][:3]
|
||||||
|
|
||||||
|
for i in correct:
|
||||||
TruetestID.append(i[3])
|
TruetestID.append(i[3])
|
||||||
TrueTestDic[i[3]]=i
|
TrueTestDic[i[3]]=i
|
||||||
|
|
||||||
|
TruetestID=TruetestID[::-1][:3]
|
||||||
|
|
||||||
for index in TruetestID:
|
for index in TruetestID:
|
||||||
cursor.execute(f"SELECT * FROM TEST_BANK WHERE ID=?",(index))
|
cursor.execute(f"SELECT * FROM TEST_BANK WHERE ID=?",(index))
|
||||||
TrueTestDic[index]=TrueTestDic[index],cursor.fetchall()
|
TrueTestDic[index]=TrueTestDic[index],cursor.fetchall()
|
||||||
|
|
||||||
# print(TrueTestDic)
|
# print(TrueTestDic)
|
||||||
|
|
||||||
return TrueTestDic
|
return TrueTestDic
|
||||||
# fetch_test_func('20240101')
|
# fetch_test_func('20240101')
|
||||||
|
|
||||||
|
@ -166,6 +175,53 @@ def falseTest_func(ID):
|
||||||
|
|
||||||
# falseTest_func('20240101')
|
# falseTest_func('20240101')
|
||||||
|
|
||||||
|
|
||||||
|
def TestDataFunc(examID):
|
||||||
|
cursor = db.cursor()
|
||||||
|
cursor.execute(f"SELECT * FROM TEST_BANK WHERE ID=?",(examID,))
|
||||||
|
TestID=cursor.fetchall()[0]
|
||||||
|
ChoiceList=json.loads(TestID[0])
|
||||||
|
CompleList=json.loads(TestID[1])
|
||||||
|
JudgeList=json.loads(TestID[2])
|
||||||
|
|
||||||
|
Choice=[]
|
||||||
|
Comple=[]
|
||||||
|
Judge=[]
|
||||||
|
|
||||||
|
CHOICE=[str(x) for x in ChoiceList]
|
||||||
|
COMPLE=[str(x) for x in CompleList]
|
||||||
|
JUDGE=[str(x) for x in JudgeList]
|
||||||
|
|
||||||
|
for i in CHOICE:
|
||||||
|
cursor.execute(f"SELECT * FROM CHOICE_QUESTION_BANK WHERE ID=?",(i))
|
||||||
|
Choice.append(cursor.fetchall())
|
||||||
|
|
||||||
|
for i in COMPLE:
|
||||||
|
cursor.execute(f"SELECT * FROM COMPLETION_QUESTION_BANK WHERE ID=?",(i))
|
||||||
|
Comple.append(cursor.fetchall())
|
||||||
|
|
||||||
|
for i in JUDGE:
|
||||||
|
cursor.execute(f"SELECT * FROM T_OR_F_QUESTION_BANK WHERE ID=?",(i))
|
||||||
|
Judge.append(cursor.fetchall())
|
||||||
|
|
||||||
|
|
||||||
|
HOUR=TestID[3]
|
||||||
|
MIN=TestID[4]
|
||||||
|
if int(HOUR)==0:
|
||||||
|
time=int(MIN)
|
||||||
|
elif int(MIN)==0:
|
||||||
|
time=int(HOUR)*60
|
||||||
|
else:
|
||||||
|
time=int(HOUR)*60+int(MIN)
|
||||||
|
|
||||||
|
dic={'examID':[Choice,Comple,Judge,time]}
|
||||||
|
|
||||||
|
# print(dic)
|
||||||
|
|
||||||
|
return dic
|
||||||
|
|
||||||
|
# TestDataFunc('35')
|
||||||
|
|
||||||
# 查找学生已经完成的记录
|
# 查找学生已经完成的记录
|
||||||
def find_end_test(ID):
|
def find_end_test(ID):
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
|
Loading…
Reference in New Issue