Commit 41b1059e authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

ASD

parent 217e0071
...@@ -17,7 +17,8 @@ function Admin() { ...@@ -17,7 +17,8 @@ function Admin() {
function handleClickQuiz(e) { function handleClickQuiz(e) {
setn(e.target.id) setn(e.target.id)
setresult(<AdminQuiz quizNum={e.target.id} fn={handleClickSave} data={QnAadmins} />) console.log(QnAadmins)
setresult(<AdminQuiz quizNum={e.target.id} fn={handleClickSave} data={QnAadmins[e.target.id]} />)
} }
function handleClickAddQuiz() { function handleClickAddQuiz() {
...@@ -27,7 +28,6 @@ function Admin() { ...@@ -27,7 +28,6 @@ function Admin() {
setQuizBtnCount(QuizBtnCount + 1) setQuizBtnCount(QuizBtnCount + 1)
} }
function handleClickSave(QnAadmin){ function handleClickSave(QnAadmin){
QnAadmins.splice(n, 0, QnAadmin) QnAadmins.splice(n, 0, QnAadmin)
localStorage.setItem('QnA', JSON.stringify(QnAadmins)) localStorage.setItem('QnA', JSON.stringify(QnAadmins))
......
...@@ -14,22 +14,21 @@ function AdminQuiz(props) { ...@@ -14,22 +14,21 @@ function AdminQuiz(props) {
const [c, setc] = useState([]) const [c, setc] = useState([])
const [a, seta] = useState('') const [a, seta] = useState('')
// useEffect(()=>{ useEffect(()=>{
// setQuestion('') setQuestion('')
// if(JSON.parse(localStorage.getItem('QnA'))[props.QuizNum]){ setChoose('')
// setq(props.data[props.QuizNum-1].Q) if(props.data){
// setc(props.data[props.QuizNum-1].Choose) setq(props.data.Q)
// seta(props.data[props.QuizNum-1].A) setc(props.data.Choose)
seta(props.data.A)
// } }
// else { else {
// setq('보기를 입력하세요') setq('보기를 입력하세요')
// setc(['보기를 입력하세요','보기를 입력하세요','보기를 입력하세요','보기를 입력하세요']) setc(['보기를 입력하세요','보기를 입력하세요','보기를 입력하세요','보기를 입력하세요'])
// seta('보기를 입력하세요') seta('보기를 입력하세요')
// } }
// },[props.QuizNum]) },[props.quizNum])
const handleChangeQuestion = (event) => { const handleChangeQuestion = (event) => {
QnAadmin['Q'] = event.target.value QnAadmin['Q'] = event.target.value
......
// import bg from './img_study.jpg'
// import korea from './img_korea.jpg'
import React, { useState } from 'react' import React, { useState } from 'react'
import { Redirect } from 'react-router-dom'; import { Redirect } from 'react-router-dom';
function Home() { function Home() {
let info=[]
if(JSON.parse(localStorage.getItem("Set")) === null){
info=[{password:"0319", AdminPassword:"0001",Time : "30010"}] //수정.추가
}
else{
info = JSON.parse(localStorage.getItem("Set"))
} //수정. 추가
const [name, setName] = useState('') const [name, setName] = useState('')
const [password, SetPassword] = useState('') const [password, SetPassword] = useState('')
const [done, setDone] = useState(false) const [done, setDone] = useState(false)
...@@ -24,14 +31,14 @@ function Home() { ...@@ -24,14 +31,14 @@ function Home() {
else if (!password) { else if (!password) {
alert('비밀번호를 입력하세요') alert('비밀번호를 입력하세요')
} }
else if (name === 'admin' && password === '0001') { else if (name === 'admin' && password === info[0].AdminPassword) {
console.log('done') console.log('done')
return (setAdmin(true) return (setAdmin(true)
) )
} }
else if (password !== '0319') { else if (password !== info[0].password) {
alert('유효한 비밀번호를 입력하세요') alert('유효한 비밀번호를 입력하세요')
} }
else { else {
...@@ -83,4 +90,3 @@ function Home() { ...@@ -83,4 +90,3 @@ function Home() {
} }
export default Home; export default Home;
...@@ -6,11 +6,16 @@ import logo from './img/img_question.png' ...@@ -6,11 +6,16 @@ import logo from './img/img_question.png'
let localQnA = JSON.parse(localStorage.getItem('QnA')) let localQnA = JSON.parse(localStorage.getItem('QnA'))
let Answers = [] let Answers = []
function Quiz() { function Quiz() {
let Time = 0
if (JSON.parse(localStorage.getItem("Set")) === null) {
Time = 30010
}
else {
Time = Number(JSON.parse(localStorage.getItem("Set"))[0].Time)
} //수정. 추가. 새로 설정한 시간으로 설정
const [question, setQuestion] = useState({ const [question, setQuestion] = useState({
...localQnA[0] ...localQnA[0]
}) })
...@@ -20,10 +25,10 @@ function Quiz() { ...@@ -20,10 +25,10 @@ function Quiz() {
//for each 사용하기 //for each 사용하기
let Solutions = [] //빈 배열 let Solutions = [] //빈 배열
console.log(localQnA) console.log(localQnA)
localQnA.map((x) => { //A만 꺼내서 q에 추가
// Answers.push(0) localQnA.forEach((element) => {
return Solutions.push(x.A) Solutions.push(Number(element.A))
}) });
useEffect(() => { useEffect(() => {
for (let i = 1; i <= Solutions.length; i++) { for (let i = 1; i <= Solutions.length; i++) {
Answers.push(0) Answers.push(0)
...@@ -57,7 +62,7 @@ function Quiz() { ...@@ -57,7 +62,7 @@ function Quiz() {
</div> </div>
<div className="col-md-auto"> <div className="col-md-auto">
<div className="h2 mt-2"> <div className="h2 mt-2">
{localQnA[0].Q} {question.Q}
</div> </div>
<div className="mt-2"> <div className="mt-2">
<form> <form>
...@@ -79,7 +84,8 @@ function Quiz() { ...@@ -79,7 +84,8 @@ function Quiz() {
</div> </div>
<p className="h3 text-center text-danger "> <p className="h3 text-center text-danger ">
<Timer <Timer
initialTime={3000} initialTime={Time} // 수정. 추가. 새로설정한 시간으로 설정. 하지만 새로고침해야 적용됨
// initialTime={Number(JSON.parse(localStorage.getItem("Set"))[0].Time)}
direction="backward" direction="backward"
checkpoints={[ checkpoints={[
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment