diff --git a/app-dm/src/pages/ListPages/Analyse/AnalysePages.css b/app-dm/src/pages/ListPages/Analyse/AnalysePages.css index 3a2ff6b..6f6f15f 100644 --- a/app-dm/src/pages/ListPages/Analyse/AnalysePages.css +++ b/app-dm/src/pages/ListPages/Analyse/AnalysePages.css @@ -11,7 +11,6 @@ .test-analyse{ width: 100%; - height: 400px; } .test-analyse li{ diff --git a/app-dm/src/pages/ListPages/Analyse/AnalysePages.jsx b/app-dm/src/pages/ListPages/Analyse/AnalysePages.jsx index 2ab1f01..5f1b566 100644 --- a/app-dm/src/pages/ListPages/Analyse/AnalysePages.jsx +++ b/app-dm/src/pages/ListPages/Analyse/AnalysePages.jsx @@ -1,17 +1,48 @@ import Computer from '../../Home/img/computer.jpg' -import React,{ useState } from 'react'; +import React,{ useState,useEffect } from 'react'; import '../Analyse/AnalysePages.css' import { Pie } from 'react-chartjs-2'; import 'chart.js/auto'; +import axios from 'axios'; // 首页 学习分析 function SubjectPage(){ + const student_ID=localStorage.getItem('islogin') //点击li弹出图像窗口 const [SubjectModal,setSubjectModal] = useState(false); + + //表视图数据 + const [PieData,setPieData]=useState({}) + const [PieOptions,setPieOptions]=useState({}) + //题目总分 + const [score,setscore]=useState() - const handleSubjectClick = () => { + const handleSubjectClick = (key) => { setSubjectModal(!SubjectModal) + + //计算总分 + setscore((JSON.parse(HistoryTrain[key][1][0]).length+JSON.parse(HistoryTrain[key][1][1]).length+JSON.parse(HistoryTrain[key][1][2]).length)*5+40) + + setPieData({labels: ['实训题','基础题'], + datasets: [ + { + label: '得分情况分布', + data: [HistoryTrain[key][0][4],HistoryTrain[key][0][5]], // 这里填写每个类型题目的数量 + backgroundColor: ['#FF6384','#36A2EB'], // 颜色 + hoverOffset: 2, + }, + ]}) + + setPieOptions({plugins: { + legend: { + position: 'top', + }, + title: { + display: true, + text: '得分情况分布', + }, + },}) } // 处理弹窗关闭的函数 const handleSubjectModalClose = () => { @@ -19,61 +50,52 @@ function SubjectPage(){ }; - // 饼图数据 - const pieData = { - labels: ['判断题', '填空题', '简答题','实训题'], - datasets: [ - { - label: '题目类型分布', - data: [30, 20, 10,40], // 这里填写每个类型题目的数量 - backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56','#a7f7b1'], // 颜色 - hoverOffset: 4, - }, - ], - }; + const click=()=>{ + console.log(score); + } + + //获取历史实训记录 + const [HistoryTrain,setHisToryTrain]=useState() - // 饼图配置项 - const pieOptions = { - plugins: { - legend: { - position: 'top', - }, - title: { - display: true, - text: '题目类型分布', - }, - }, - }; - - + const HistoryTrainFunc=async()=>{ + try{ + const HistoryTrainSrc=await axios.post('/api/student/HistoryTrain',{ + student_ID + }) + setHisToryTrain(HistoryTrainSrc.data['HistoryTrain']) + + }catch{ + alert('HistoryTrainFunc出错') + } + } + useEffect(()=>{ + HistoryTrainFunc() + },[]) return(
-
+ {HistoryTrain&&
{/* 内容 */}
    - {[{class:'课程1:达梦数据库的安装',time:"关闭时间:2024-4-16 11.46",ImgSrc:Computer}, - {class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Computer}, - {class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Computer}, - {class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Computer}, - {class:'课程2:web前端开发与数据库的结合',time:"关闭时间:2024-4-16 11.46",ImgSrc:Computer}, - ].map((item) => -
  • - -

    -

    {item.class}

    - {item.time} -

    -
  • - )} + {Object.keys(HistoryTrain).map((key)=>( +
  • handleSubjectClick(key)} key={key}> + +

    +

    {eval(HistoryTrain[key][1][11])}

    + {HistoryTrain[key][1][5]} +

    +
  • + ))}
-
+
} +

课程

@@ -83,16 +105,16 @@ function SubjectPage(){ {/* 饼图组件 */}
- -
-
+ +
+ {HistoryTrain&&
{/* 图表或者文字分析 */} -
+
} )} diff --git a/app-dm/src/pages/ListPages/Training/Operation1.css b/app-dm/src/pages/ListPages/Training/Operation1.css index 5d1ebbe..216ab7e 100644 --- a/app-dm/src/pages/ListPages/Training/Operation1.css +++ b/app-dm/src/pages/ListPages/Training/Operation1.css @@ -20,7 +20,7 @@ /* 第二页(实训题)的左边导航 */ .nav-left-operation1{ width: 215px; - height: 840px; + height: 100%; position: absolute; box-shadow: 2px 2px 6px #d4d4d4; } @@ -30,7 +30,6 @@ } .nav-left-ul1{ width: 175px; - height: 240px; /* border-top: 1px solid #7f7f7f; */ position: relative; border-top: 2px solid rgb(212, 212, 212); @@ -111,4 +110,22 @@ .body-right1-comple tr{ background-color: rgb(110, 130, 130); } +.countBox{ + margin-top: 10px; +} +.countBox div{ + display: flex; + flex-wrap:wrap; + width: 200px; +} +.countBox td{ + width: 40px; + height: 30px; + /* background-color: rgb(136, 243, 209); */ + border: 1px solid black; + text-align: center; + margin-left: 5px; + margin-top: 5px; + cursor: pointer; +} diff --git a/app-dm/src/pages/ListPages/Training/Operation1.jsx b/app-dm/src/pages/ListPages/Training/Operation1.jsx index 15413c8..3052e07 100644 --- a/app-dm/src/pages/ListPages/Training/Operation1.jsx +++ b/app-dm/src/pages/ListPages/Training/Operation1.jsx @@ -11,13 +11,15 @@ import axios from 'axios'; function Operation1() { const click=()=>{ - console.log(score); + console.log(TrainData); } const clear=()=>{ localStorage.clear('choice_answers'); setchoice_answer({}) localStorage.clear('completion_answer') setcompletion_answer({}) + localStorage.clear('judge_answer') + setjudge_answer({}) } const { operateID } = useParams(); @@ -31,6 +33,7 @@ function Operation1() { }) const returnData=TrainDataSrc.data setTrainData(returnData) + settime(parseInt(returnData['operateID'][4])) }catch{ alert('TrainDataFunc出错') } @@ -40,14 +43,13 @@ function Operation1() { TrainDataFunc() },[]) //倒计时 - const [test_data, setTestData] = useState(''); const [countdown, setCountdown] = useState(0); - + const [time,settime]=useState() // 倒计时初始化 useEffect(() => { - const examDuration = 60 * 90; // 假设考试时长为1小时 + const examDuration = 60 * time; // 假设考试时长为1小时 setCountdown(examDuration); - }, []); + }, [time]); // 倒计时更新 useEffect(() => { @@ -155,6 +157,7 @@ function Operation1() { } } + return (
@@ -183,15 +186,37 @@ function Operation1() {
  • 实训题
  • +
    + {TrainData&& + 选择题: +
    + {Object.keys(TrainData['operateID'][0]).map((key,index)=>( +
    + ))} + + 填空题: +
    + {Object.keys(TrainData['operateID'][1]).map((key,index)=>( +
    + ))} + + 判断题: +
    + {Object.keys(TrainData['operateID'][2]).map((key,index)=>( +
    + ))} + +
    {index+1}
    {index+1}
    {index+1}
    } +
    {TrainData && (

    选择题:

    - {Object.keys(TrainData['operateID'][0]).map((key) => ( + {Object.keys(TrainData['operateID'][0]).map((key,index) => ( - {TrainData['operateID'][0][key][0][1]} + ({index+1}.){TrainData['operateID'][0][key][0][1]}

    diff --git a/python/app.py b/python/app.py index fcff020..8be6d84 100644 --- a/python/app.py +++ b/python/app.py @@ -136,10 +136,17 @@ def FetchTrainTitle(): @app.route('/api/student/TrainData',methods=['POST']) def TrainData(): - examID=request.json['operateID'] + data=request.json + examID=data['operateID'] result=FetchTrainTestFunc(examID) return result +@app.route('/api/student/HistoryTrain',methods=['POST']) +def HistoryTrain(): + ID = request.json['student_ID'] + result=HistoryTrainFunc(ID) + return jsonify({'HistoryTrain': result}) + # 以下为教师功能————————————————————————————————————————————————————————————————————— diff --git a/python/student_func.py b/python/student_func.py index ffd1cb9..aaaf9bb 100644 --- a/python/student_func.py +++ b/python/student_func.py @@ -263,10 +263,27 @@ def FetchTrainTestFunc(operateID): dic={'operateID':[CHOICELIST,COMPLELIST,JUDGELIST,Train,time]} + return dic +# FetchTrainTestFunc('6') + +def HistoryTrainFunc(ID): + dic={} + cursor=db.cursor() + cursor.execute("SELECT * FROM TRAINSCORE WHERE STUDENT_ID=? AND TF='true'",(ID)) + historytrain=cursor.fetchall() + + for i in historytrain: + cursor.execute("SELECT * FROM TRAINTEST WHERE ID=?", (i[2])) + dic[i[2]]=i,cursor.fetchall()[0] + + + return dic + +# HistoryTrainFunc('20240101') + -# FetchTrainTestFunc('3')