This commit is contained in:
30404 2024-06-20 14:54:17 +08:00
parent 02ba73619e
commit 882e8b4087
8 changed files with 91 additions and 59 deletions

View File

@ -5,18 +5,12 @@ import React,{ useEffect,useState } from 'react';
import axios from 'axios';
//
import { Line } from 'react-chartjs-2';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Tooltip, Legend } from 'chart.js';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Tooltip, Legend, Ticks } from 'chart.js';
import { max, min } from 'lodash';
//
function Home(){
const outlog=()=>{
localStorage.removeItem('islogin')
// setisChecked(false)
alert('注销成功')
window.location.href='http://localhost:3000/signin'
};
const [isChecked,setisChecked]=useState(false)
//
// useEffect(()=>{
@ -52,7 +46,7 @@ function Home(){
const student_succeed=student_succeed_src.data
const lesson_data=(student_succeed['student_lesson'])
setLesson(lesson_data)
}catch(error){
}catch(error){
if(student_ID.length===6){
window.location.href='http://localhost:3000/teacher'
return
@ -63,9 +57,10 @@ function Home(){
}
}
}
// useEffect(()=>{
// student_succeed_func()
// },[])
useEffect(()=>{
student_succeed_func()
},[])
useEffect(()=>{
if(lesson.length>0){
@ -83,10 +78,6 @@ function Home(){
}
},[lesson])
const click=()=>{
console.log();
}
//线
//
const [chartData, setChartData] = useState({
@ -109,8 +100,7 @@ function Home(){
datasets: [
{
label: '总体成绩分析',
// data: [10, 20, 30, 40, 50,60,70,80,90,100],
data:data,
data: [62, 79, 71, 49, 70],
fill: false,
backgroundColor:'#fff',
borderColor: 'rgb(75, 192, 192)',
@ -125,6 +115,11 @@ function Home(){
scales: {
y: {
beginAtZero: true,
min:0,
max:100,
ticks:{
stepSize:10
}
}
},
plugins: {

View File

@ -46,10 +46,6 @@ function SubjectPage(){
//
const [outtest,setouttest]=useState({})
//
const click = () => {
console.log(testdata);
};
//
useEffect(()=>{
let test_list= []
@ -97,8 +93,6 @@ function SubjectPage(){
</div>
))}
</div>}
<button onClick={click}>测试按钮</button>
<h3>已结束或完成的试卷与练习</h3>
{ outtest&& result&&<div className='test-subject'>
{Object.keys(outtest).map((key)=>{

View File

@ -48,16 +48,16 @@
}
.exam-btn-training{
position: relative;
margin-top: 50px;
margin-left: 250px;
position: absolute;
margin-left: 260px;
border-radius: 15px;
margin-top: -10px;
font-size: 17px;
border: none;
display: inline-block;
padding: 3px 32px;
padding: 3px 26px;
background-color: rgba(175, 235, 230, 0.929);
color: #000;
color: #000;
text-decoration: none;
box-shadow: 3px 3px 5px rgba(127, 170, 166, 0.929);
}
@ -69,6 +69,13 @@
.exam-btn-training:active{
color:rgba(86, 117, 114, 0.929);
}
.bottomP{
color: red;
font-size: 20px;
margin-top: 350px;
margin-left: 50px;
letter-spacing: 20px;
}

View File

@ -1,44 +1,53 @@
import React,{ useState } from 'react';
import React,{ useState , useEffect} from 'react';
import { Link } from 'react-router-dom';
import '../Training/TrainingPage.css'
import axios from 'axios';
const list3=[
{'train':'实训一:数据库的安装',id:'1'},
{'train':'实训二web前端开发和数据库的结合',id:'2'}
]
const list4=[
{'train':'实训3待定',id:'3'},
{'train':'实训4待定',id:'4'}
]
//
function SubjectPage(){
const student_ID=localStorage.getItem('islogin')
const [title,setTitle]=useState()
//
const FetchTrainFunc=async()=>{
try{
const FetchTrainSrc=await axios.post('http://127.0.0.1:5000/student/FetchTrainTitle',{
student_ID
})
setTitle(FetchTrainSrc.data['title'])
}catch{
alert('FetchTrainFunc出错')
}
}
useEffect(()=>{
FetchTrainFunc()
},[])
return(
<div className="body-right-training">
<h3>未完成练习</h3>
<div className='test-training'>
{list3.map((item) =>(
<div className='test-box-training'key={item.id}>
<p>{item.train}</p>
<span>发布者陈老师</span>
<div dangerouslySetInnerHTML={{ __html: item.title }} />
<Link to={`/operation1/${item.train}`} className="exam-btn-training">
<h3>未完成实训项目</h3>
{title&&<div className='test-training'>
{Object.keys(title).map((key)=>(
<div className='test-box-training' key={key}>
<p>实训:{eval(title[key][0][11])}</p>
<span>发布者:陈老师</span>
<div>发布时间:{title[key][0][5]}</div>
<div>截至时间:{title[key][0][6]}</div>
<Link to={`/operation1/${title[key][0][10]}`} className="exam-btn-training">
开始实训
</Link>
</div>))}
</div>
<h3>已完成练习</h3>
<div className='test-training'>
{list4.map((item) => (
<div className='test-box-training'key={item.id}>
<p>{item.train}</p>
<div>
{item.title}
</div>
</div>))}
</div>
</div>
))}
</div>}
<button onClick={()=>{
console.log(title[0][0][11]);
}}></button>
<p className='bottomP'>提醒:请及时完成实训内容</p>
</div>
)};

View File

@ -21,6 +21,7 @@ import ClassID from '../TeacherPages/classlistpages/classId';
import ManageTest from '../TeacherPages/teachermanagetest/ManageTest';
import SendTest from '../TeacherPages/SendTest/SendTest';
import Marking from '../TeacherPages/MarkingPages/Marking';
import SendTrain from '../TeacherPages/SendTrain/SendTrain';
// (exam)使
const MainLayout = ({ headerNav:HeaderNav }) => {
@ -53,9 +54,10 @@ function App() {
<Route path="/teacher" element={<MainLayout headerNav={HeaderNavTeacher} />}>
<Route index element={<TeacherPage/>} />
<Route path='managetest' element={<ManageTest />}/>
<Route path='managetest/:ClassID' element={<ManageTest />}/>
{/* <Route path='managetest/:ClassID' element={<ManageTest />}/> */}
<Route path="classID/:key" element={<ClassID />} />
<Route path='mark' element={<Marking/>}/>
{/* 其他需要HeaderNavTeacher的页面 */}
</Route>
@ -68,8 +70,7 @@ function App() {
<Route path='/teacher/sendtest' element={<SendTest />}/>
<Route path='operation1/:operateID' element={<Operation1/>}/>
<Route path='operation2/:operateID' element={<Operation2/>}/>
<Route path='teacher/SendTrain' element={<SendTrain/>}/>
{/* 独立的顶级路由如登录页面也不包含HeaderNav */}
{/* 登录页面 */}
<Route path="signin" element={<SignInPage />} />

View File

@ -128,6 +128,15 @@ def score_entry():
return jsonify({'result': '成功'})
@app.route('/student/FetchTrainTitle',methods=['POST'])
def FetchTrainTitle():
data = request.json
ID = data['student_ID']
title=FetchTrainTitleFunc(ID)
return jsonify({'title': title})
# 以下为教师功能—————————————————————————————————————————————————————————————————————
@app.route('/teacher/return_question', methods=['POST'])
def return_question():

View File

@ -203,6 +203,24 @@ def score_entry_func(score,testID,ID):
return '修改成功'
def FetchTrainTitleFunc(ID):
cursor = db.cursor()
cursor.execute('SELECT * FROM TRAINSCORE WHERE STUDENT_ID=?',(ID))
train_title = cursor.fetchall()
titles = []
title = []
for i in train_title:
titles.append(i[2])
print(titles)
for i in titles:
cursor.execute('select * from TRAINTEST WHERE ID=?',(i))
title.append(cursor.fetchall())
cursor.close()
return title

View File

@ -5,7 +5,6 @@ from Crypto.Random import get_random_bytes
import base64
import datetime
db = dmPython.connect(user='SYSDBA', password='dameng!!', host="36.138.114.105", port="32522")
#获取题目