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(){
const teacher_ID=localStorage.getItem('islogin')
if(teacher_ID==null){
alert('登录过期,请重新登录')
window.location.href='http://localhost:3000/signin'
}
return(
<div className='body-right-mark'>

View File

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

View File

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

View File

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

View File

@ -5,29 +5,12 @@ import axios from 'axios';
// import { useParams } from 'react-router-dom';
function TeacherPage() {
const [isChecked, setisChecked] = useState(false);
const [teacher_ID, setTeacher_ID] = useState(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({});
//
// 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)=>{
console.log(key);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -7,6 +7,10 @@ import { useEffect, useState } from 'react';
function Exam(){
const {examId} = useParams()
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=true

View File

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

View File

@ -128,4 +128,14 @@
margin-top: 5px;
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() {
const click=()=>{
console.log(TrainData);
console.log(answeredJudge);
}
const clear=()=>{
localStorage.clear('choice_answers');
@ -20,6 +20,12 @@ function Operation1() {
setcompletion_answer({})
localStorage.clear('judge_answer')
setjudge_answer({})
localStorage.clear('answeredChoice')
setAnsweredChoice([])
localStorage.clear('answeredComple')
setAnsweredComple([])
localStorage.clear('answeredJudge')
setAnsweredJudge([])
}
const { operateID } = useParams();
@ -33,28 +39,24 @@ function Operation1() {
})
const returnData=TrainDataSrc.data
setTrainData(returnData)
settime(parseInt(returnData['operateID'][4]))
setCountdown(60*parseInt(returnData['operateID'][4]))
}catch{
alert('TrainDataFunc出错')
}
}
useEffect(()=>{
TrainDataFunc()
},[])
//
const [countdown, setCountdown] = useState(0);
const [countdown, setCountdown] = useState();
const [time,settime]=useState()
//
useEffect(() => {
const examDuration = 60 * time; // 1
setCountdown(examDuration);
}, [time]);
//
useEffect(() => {
let interval = setInterval(() => {
if (countdown > 0) {
if (countdown != 0) {
setCountdown(countdown - 1);
} else {
clearInterval(interval);
@ -79,6 +81,11 @@ function Operation1() {
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) => {
@ -86,6 +93,10 @@ function Operation1() {
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) => {
@ -94,6 +105,10 @@ function Operation1() {
...completion_answer,
[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 updatedJudgeAnswer={ ...judge_answer,[key]:judgeoption}
setjudge_answer(updatedJudgeAnswer)
if (!answeredJudge.includes(key)) {
setAnsweredJudge([...answeredJudge, key]);
}
}
// localStorage
@ -109,6 +127,9 @@ function Operation1() {
localStorage.setItem('choice_answers', JSON.stringify(choice_answer));
localStorage.setItem('completion_answer', JSON.stringify(completion_answer));
localStorage.setItem('judge_answer',JSON.stringify(judge_answer))
localStorage.setItem('answeredChoice',answeredChoice)
localStorage.setItem('answeredComple',answeredComple)
localStorage.setItem('answeredJudge',answeredJudge)
};
// localStorage
@ -116,6 +137,9 @@ function Operation1() {
const storedChoiceAnswers = localStorage.getItem('choice_answers');
const storedCompleAnswers = localStorage.getItem('completion_answer');
const storedJudgeAnswers = localStorage.getItem('judge_answer')
const storedAnsweredChoice=localStorage.getItem('answeredChoice')
const storedAnsweredComple=localStorage.getItem('answeredComple')
const storedAnsweredJudge=localStorage.getItem('answeredJudge')
if (storedChoiceAnswers) {
const parsedAnswers = JSON.parse(storedChoiceAnswers);
setchoice_answer(parsedAnswers);
@ -128,6 +152,16 @@ function Operation1() {
const parsedAnswers = JSON.parse(storedJudgeAnswers);
setjudge_answer(parsedAnswers);
}
if(storedAnsweredChoice){
setAnsweredChoice(storedAnsweredChoice)
}
if(storedAnsweredComple){
setAnsweredComple(storedAnsweredComple)
}
if(storedAnsweredJudge){
setAnsweredJudge(storedAnsweredJudge)
}
}, []);
//
@ -158,6 +192,8 @@ function Operation1() {
}
return (
<div>
<div className='nav-operation1'>
@ -191,19 +227,19 @@ function Operation1() {
<tr>选择题:</tr>
<div>
{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>
<tr>填空题</tr>
<div>
{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>
<tr>判断题</tr>
<div>
{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>
</table>}

View File

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

View File

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