This commit is contained in:
30404 2024-06-25 12:51:35 +08:00
parent f18f5dc80e
commit 9d08bddb45
17 changed files with 1271 additions and 53 deletions

View File

@ -6,6 +6,11 @@ import Test from '../../pages/Home/img/test.jpg'
// //
function Marking(){ function Marking(){
const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
return( return(
<div className='body-right-mark'> <div className='body-right-mark'>

View File

@ -7,6 +7,10 @@ import axios from 'axios';
function SendTest(){ function SendTest(){
// const { key } = useParams(); // const { key } = useParams();
const teacher_ID=localStorage.getItem('islogin') const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
// //
const [ChoiceQuestion,SetChoiceQuestion]=useState() const [ChoiceQuestion,SetChoiceQuestion]=useState()
const [Completion,SetCompletion]=useState() const [Completion,SetCompletion]=useState()

View File

@ -5,6 +5,11 @@ import { Link } from 'react-router-dom';
function TrainManage(){ function TrainManage(){
const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
return( return(
<div className='body-trainmanage'> <div className='body-trainmanage'>
<p>已批改试卷</p> <p>已批改试卷</p>

View File

@ -5,6 +5,10 @@ import axios from 'axios';
function SendTrain(){ function SendTrain(){
const teacher_ID=localStorage.getItem('islogin') const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
// //
const [Trainquestion,SetTrainquestion]=useState() const [Trainquestion,SetTrainquestion]=useState()
// //

View File

@ -5,29 +5,12 @@ import axios from 'axios';
// import { useParams } from 'react-router-dom'; // import { useParams } from 'react-router-dom';
function TeacherPage() { function TeacherPage() {
const [isChecked, setisChecked] = useState(false); const teacher_ID = localStorage.getItem('islogin')
const [teacher_ID, setTeacher_ID] = useState(localStorage.getItem('islogin')); if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
const [classData, setClassData] = useState({}); const [classData, setClassData] = useState({});
//
// useEffect(() => {
// if (!isChecked) {
// const is_login = localStorage.getItem('islogin');
// if (!is_login) {
// alert('');
// window.location.href = 'http://36.138.114.105:30294/signin';
// } else {
// if(teacher_ID.length===8){
// window.location.href='http://36.138.114.105:30294'
// return
// }else{
// console.log(teacher_ID);
// }
// }
// }
// }, []);
//
const log=(key)=>{ const log=(key)=>{
console.log(key); console.log(key);
} }

View File

@ -8,6 +8,11 @@ import './classid.css'
function TeacherPage() { function TeacherPage() {
const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
const { key } = useParams(); const { key } = useParams();
const [isclick,setisclick]=useState(false) const [isclick,setisclick]=useState(false)
// //

View File

@ -6,7 +6,11 @@ import './ManageTest.css'
function TeacherPage() { function TeacherPage() {
const teacher_ID = localStorage.getItem('islogin') const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
const [classData, setClassData] = useState({}); const [classData, setClassData] = useState({});
const [classtest,setClassTest]=useState() const [classtest,setClassTest]=useState()
const [defaultclass,setDefaultClass]=useState() const [defaultclass,setDefaultClass]=useState()

View File

@ -12,22 +12,11 @@ import { max, min } from 'lodash';
// //
function Home(){ function Home(){
const [isChecked,setisChecked]=useState(false) const [isChecked,setisChecked]=useState(false)
// const student_ID=localStorage.getItem('islogin')
// useEffect(()=>{ if(student_ID==null){
// if (!isChecked){ alert('未登录,请先前往登录')
// const is_login=localStorage.getItem('islogin') window.location.href='http://localhost:3000/signin'
// if(!is_login){ }
// alert('')
// window.location.href='http://localhost:3000/signin'
// }else{
// console.log(is_login);
// console.log('');
// setisChecked(true)
// }
// //login
// }
// },[]);//
// //
const [lesson, setLesson] = useState([]); const [lesson, setLesson] = useState([]);
const [firstlesson, setfirstlesson] = useState([]); const [firstlesson, setfirstlesson] = useState([]);

View File

@ -9,6 +9,10 @@ import axios from 'axios';
// //
function SubjectPage(){ function SubjectPage(){
const student_ID=localStorage.getItem('islogin') const student_ID=localStorage.getItem('islogin')
if(student_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
//li //li
const [SubjectModal,setSubjectModal] = useState(false); const [SubjectModal,setSubjectModal] = useState(false);

View File

@ -6,7 +6,11 @@ import { useEffect, useState } from 'react';
// //
function Exam(){ function Exam(){
const {examId} = useParams() const {examId} = useParams()
const student_ID =localStorage.getItem('islogin') const student_ID=localStorage.getItem('islogin')
if(student_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
// //
const [countdown, setCountdown] = useState(0); const [countdown, setCountdown] = useState(0);
const Countdown=true const Countdown=true

View File

@ -10,6 +10,10 @@ import moment from 'moment';
// //
function SubjectPage(){ function SubjectPage(){
const student_ID=localStorage.getItem('islogin') const student_ID=localStorage.getItem('islogin')
if(student_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
const [testdata,settestdata]=useState('') const [testdata,settestdata]=useState('')
const [time,settime]=useState(moment().format('YYYY-MM-DD HH:mm:ss')) const [time,settime]=useState(moment().format('YYYY-MM-DD HH:mm:ss'))
const [result,setresult]=useState({}) const [result,setresult]=useState({})

View File

@ -128,4 +128,14 @@
margin-top: 5px; margin-top: 5px;
cursor: pointer; cursor: pointer;
} }
.answered {
/* 例如,改变题目的背景色 */
width: 40px;
height: 30px;
background-color: rgb(136, 243, 209);
text-align: center;
margin-left: 5px;
margin-top: 5px;
cursor: pointer;
}

View File

@ -11,7 +11,7 @@ import axios from 'axios';
function Operation1() { function Operation1() {
const click=()=>{ const click=()=>{
console.log(TrainData); console.log(answeredJudge);
} }
const clear=()=>{ const clear=()=>{
localStorage.clear('choice_answers'); localStorage.clear('choice_answers');
@ -20,6 +20,12 @@ function Operation1() {
setcompletion_answer({}) setcompletion_answer({})
localStorage.clear('judge_answer') localStorage.clear('judge_answer')
setjudge_answer({}) setjudge_answer({})
localStorage.clear('answeredChoice')
setAnsweredChoice([])
localStorage.clear('answeredComple')
setAnsweredComple([])
localStorage.clear('answeredJudge')
setAnsweredJudge([])
} }
const { operateID } = useParams(); const { operateID } = useParams();
@ -33,28 +39,24 @@ function Operation1() {
}) })
const returnData=TrainDataSrc.data const returnData=TrainDataSrc.data
setTrainData(returnData) setTrainData(returnData)
settime(parseInt(returnData['operateID'][4])) setCountdown(60*parseInt(returnData['operateID'][4]))
}catch{ }catch{
alert('TrainDataFunc出错') alert('TrainDataFunc出错')
} }
} }
useEffect(()=>{ useEffect(()=>{
TrainDataFunc() TrainDataFunc()
},[]) },[])
// //
const [countdown, setCountdown] = useState(0); const [countdown, setCountdown] = useState();
const [time,settime]=useState() const [time,settime]=useState()
// //
useEffect(() => {
const examDuration = 60 * time; // 1
setCountdown(examDuration);
}, [time]);
// //
useEffect(() => { useEffect(() => {
let interval = setInterval(() => { let interval = setInterval(() => {
if (countdown > 0) { if (countdown != 0) {
setCountdown(countdown - 1); setCountdown(countdown - 1);
} else { } else {
clearInterval(interval); clearInterval(interval);
@ -79,6 +81,11 @@ function Operation1() {
const [choice_answer,setchoice_answer]=useState({}) const [choice_answer,setchoice_answer]=useState({})
const [completion_answer,setcompletion_answer]=useState({}) const [completion_answer,setcompletion_answer]=useState({})
const [judge_answer,setjudge_answer]=useState({}) const [judge_answer,setjudge_answer]=useState({})
//
const [answeredChoice, setAnsweredChoice] = useState([]);
const [answeredComple, setAnsweredComple] = useState([]);
const [answeredJudge, setAnsweredJudge] = useState([]);
// //
const handleOptionChange = (event) => { const handleOptionChange = (event) => {
@ -86,6 +93,10 @@ function Operation1() {
const key = parseInt(event.target.name.replace('group', '')); const key = parseInt(event.target.name.replace('group', ''));
const updatedChoiceAnswer = { ...choice_answer, [key]: selectedValue }; const updatedChoiceAnswer = { ...choice_answer, [key]: selectedValue };
setchoice_answer(updatedChoiceAnswer); setchoice_answer(updatedChoiceAnswer);
//
if (!answeredChoice.includes(key)) {
setAnsweredChoice([...answeredChoice, key]);
}
}; };
// //
const handleInputChange = (event) => { const handleInputChange = (event) => {
@ -94,6 +105,10 @@ function Operation1() {
...completion_answer, ...completion_answer,
[name]: value [name]: value
}); });
if (!answeredComple.includes(parseInt(name))) {
setAnsweredComple([...answeredComple, parseInt(name)]);
}
}; };
// //
@ -102,6 +117,9 @@ function Operation1() {
const key=parseInt(event.target.name.replace('judge','')) const key=parseInt(event.target.name.replace('judge',''))
const updatedJudgeAnswer={ ...judge_answer,[key]:judgeoption} const updatedJudgeAnswer={ ...judge_answer,[key]:judgeoption}
setjudge_answer(updatedJudgeAnswer) setjudge_answer(updatedJudgeAnswer)
if (!answeredJudge.includes(key)) {
setAnsweredJudge([...answeredJudge, key]);
}
} }
// localStorage // localStorage
@ -109,6 +127,9 @@ function Operation1() {
localStorage.setItem('choice_answers', JSON.stringify(choice_answer)); localStorage.setItem('choice_answers', JSON.stringify(choice_answer));
localStorage.setItem('completion_answer', JSON.stringify(completion_answer)); localStorage.setItem('completion_answer', JSON.stringify(completion_answer));
localStorage.setItem('judge_answer',JSON.stringify(judge_answer)) localStorage.setItem('judge_answer',JSON.stringify(judge_answer))
localStorage.setItem('answeredChoice',answeredChoice)
localStorage.setItem('answeredComple',answeredComple)
localStorage.setItem('answeredJudge',answeredJudge)
}; };
// localStorage // localStorage
@ -116,6 +137,9 @@ function Operation1() {
const storedChoiceAnswers = localStorage.getItem('choice_answers'); const storedChoiceAnswers = localStorage.getItem('choice_answers');
const storedCompleAnswers = localStorage.getItem('completion_answer'); const storedCompleAnswers = localStorage.getItem('completion_answer');
const storedJudgeAnswers = localStorage.getItem('judge_answer') const storedJudgeAnswers = localStorage.getItem('judge_answer')
const storedAnsweredChoice=localStorage.getItem('answeredChoice')
const storedAnsweredComple=localStorage.getItem('answeredComple')
const storedAnsweredJudge=localStorage.getItem('answeredJudge')
if (storedChoiceAnswers) { if (storedChoiceAnswers) {
const parsedAnswers = JSON.parse(storedChoiceAnswers); const parsedAnswers = JSON.parse(storedChoiceAnswers);
setchoice_answer(parsedAnswers); setchoice_answer(parsedAnswers);
@ -128,6 +152,16 @@ function Operation1() {
const parsedAnswers = JSON.parse(storedJudgeAnswers); const parsedAnswers = JSON.parse(storedJudgeAnswers);
setjudge_answer(parsedAnswers); setjudge_answer(parsedAnswers);
} }
if(storedAnsweredChoice){
setAnsweredChoice(storedAnsweredChoice)
}
if(storedAnsweredComple){
setAnsweredComple(storedAnsweredComple)
}
if(storedAnsweredJudge){
setAnsweredJudge(storedAnsweredJudge)
}
}, []); }, []);
// //
@ -158,6 +192,8 @@ function Operation1() {
} }
return ( return (
<div> <div>
<div className='nav-operation1'> <div className='nav-operation1'>
@ -191,19 +227,19 @@ function Operation1() {
<tr>选择题:</tr> <tr>选择题:</tr>
<div> <div>
{Object.keys(TrainData['operateID'][0]).map((key,index)=>( {Object.keys(TrainData['operateID'][0]).map((key,index)=>(
<td key={key}>{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(TrainData['operateID'][1]).map((key,index)=>(
<td key={key}>{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(TrainData['operateID'][2]).map((key,index)=>(
<td key={key}>{index+1}</td> <td key={key} className={answeredJudge.includes(index) ? 'answered' : ''}>{index+1}</td>
))} ))}
</div> </div>
</table>} </table>}

View File

@ -11,6 +11,10 @@ const list4=[
// //
function SubjectPage(){ function SubjectPage(){
const student_ID=localStorage.getItem('islogin') const student_ID=localStorage.getItem('islogin')
if(student_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
const [title,setTitle]=useState() const [title,setTitle]=useState()
// //
const FetchTrainFunc=async()=>{ const FetchTrainFunc=async()=>{

View File

@ -2,6 +2,7 @@ from teacher_func import *
from student_func import * from student_func import *
from flask import Flask, render_template, request, jsonify, send_from_directory, session from flask import Flask, render_template, request, jsonify, send_from_directory, session
from flask_cors import CORS from flask_cors import CORS
import python.k8s as k8s
app = Flask(__name__, static_folder="public") app = Flask(__name__, static_folder="public")
CORS(app, resources={r"/*": {"origins": "*"}}) CORS(app, resources={r"/*": {"origins": "*"}})
@ -230,6 +231,13 @@ def SendTrainTest():
SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min, StopTime,Class,Train,teacher_id) SendTrainTestFunc(TrainChoice, TrainCompletion, TrainJudge, Hour, Min, StopTime,Class,Train,teacher_id)
return '发布成功' return '发布成功'
@app.route('/api/student-test',methods=["POST"])
def student_test():
return k8s.list_pods()
@app.route('/') @app.route('/')
@app.route('/<path:path>') @app.route('/<path:path>')
def catch_all(path = "index.html"): def catch_all(path = "index.html"):

3
python/k8s.py Normal file
View File

@ -0,0 +1,3 @@
import json
def list_pods():
return json.load('test.txt')

1146
python/test.txt Normal file

File diff suppressed because it is too large Load Diff