From 9b85fcff63fffc8be2c7502c7055c841866c9ed6 Mon Sep 17 00:00:00 2001 From: 30404 <3040471803@qq.com> Date: Wed, 26 Jun 2024 11:24:33 +0800 Subject: [PATCH] http://localhost:3000/classID/202401 --- .../TeacherPages/classlistpages/classId.jsx | 284 ++++++++++-------- .../TeacherPages/classlistpages/classid.css | 2 - .../src/TeacherPages/list_pods/List_pods.jsx | 3 +- python/app.py | 9 +- python/teacher_func.py | 2 +- 5 files changed, 168 insertions(+), 132 deletions(-) diff --git a/app-dm/src/TeacherPages/classlistpages/classId.jsx b/app-dm/src/TeacherPages/classlistpages/classId.jsx index 33f7a0d..682c15d 100644 --- a/app-dm/src/TeacherPages/classlistpages/classId.jsx +++ b/app-dm/src/TeacherPages/classlistpages/classId.jsx @@ -1,135 +1,169 @@ -import { useParams } from 'react-router-dom'; -import { Link } from 'react-router-dom'; -import React, { useEffect, useState } from 'react'; -import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts'; -import axios from 'axios'; -import './classid.css' + import { useParams } from 'react-router-dom'; + import { Link } from 'react-router-dom'; + import React, { useEffect, useState } from 'react'; + import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts'; + import axios from 'axios'; + import './classid.css' -function TeacherPage() { - const click=()=>{ - console.log(TestScore); - } - const teacher_ID=localStorage.getItem('islogin') - if(teacher_ID==null){ - alert('登录过期,请重新登录') - window.location.href='http://36.138.114.105:30294/' - } - const { key } = useParams(); - const [isclick,setisclick]=useState(false) - //学生表格 - const [classdata,setClassData]=useState([]) - const class_succeed = async () => { - try{ - const class_scr=await axios.post('/api/teacher/find_student',{key}) - const class_data=class_scr.data - setClassData(class_data[1]) - setisclick(true) - }catch(error){ - alert(error) + function TeacherPage() { + const [selectedSubject, setSelectedSubject] = useState(); + const [ID,setID]=useState(null) + const[TestScore,setTestScore]=useState([]) + const { key } = useParams(); + const [isclick,setisclick]=useState(false) + const [classdata,setClassData]=useState([]) + const [studentScores, setStudentScores] = useState([]) + const [name,setname]=useState('') + + const click=()=>{ + console.log(studentScores); } - } - useState(()=>{ - class_succeed(); - },[]) - - //柱形图 - const [studentScores, setStudentScores] = useState([]); - - useEffect(() => { - class_succeed().then(() => { - const scores = classdata.map(student => ({ - name: 11.26, // 学生姓名 - score:10, // 学生分数 - })); - setStudentScores(scores); - }); - }, [isclick]); - - function formatDate(dateString) { - // 将日期字符串转换为 Date 对象 - const date = new Date(dateString); - // 获取年份、月份和日期 - const year = date.getFullYear(); - const monthIndex = date.getMonth(); - const day = date.getDate(); - - // 构建格式化后的日期字符串 - const formattedDate = `${year}-${(monthIndex + 1).toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`; - return formattedDate; - } - const[TestScore,setTestScore]=useState() - const Find_details=async (ID)=>{ - try{ - const Find_details_Src=await axios.post('api/Find_details',{ - ID - }) - setTestScore(Find_details_Src.data) - }catch{ - alert('Find_details出错') + const teacher_ID=localStorage.getItem('islogin') + if(teacher_ID==null){ + alert('登录过期,请重新登录') + window.location.href='http://36.138.114.105:30294/' } - } + + //学生表格 + + const class_succeed = async () => { + try{ + const class_scr=await axios.post('/api/teacher/find_student',{key}) + const class_data=class_scr.data + setClassData(class_data[1]) + setisclick(true) + }catch(error){ + alert(error) + } + } + useState(()=>{ + class_succeed(); + },[]) - return( -