Commit c6d01df3 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

a

parent e67f66d7
...@@ -2,46 +2,71 @@ import React, { useState } from 'react'; ...@@ -2,46 +2,71 @@ import React, { useState } from 'react';
let list = [] let list = []
let QnAadmins = []
let QnAadmin = {}
function AdminQuiz() { function AdminQuiz() {
const [question, setQuestion] = useState('') const [question, setQuestion] = useState('')
const [choose, setChoose] = useState('') const [choose, setChoose] = useState('')
const [answer, setAnswer] = useState('') const [answer, setAnswer] = useState('')
const [selectOption, setselectOption] = useState(1) const [selectOption, setselectOption] = useState(1)
const handleChangeQuestion = (event) => { const handleChangeQuestion = (event) => {
QnAadmin['Q'] = event.target.value
setQuestion(event.target.value) setQuestion(event.target.value)
} }
const handleChangeChoose = (event) => { const handleChangeChoose = (event) => {
QnAadmin['Choose'] = event.target.value
setChoose(event.target.value) setChoose(event.target.value)
} }
const handleChangeanswer = (event) => { const handleChangeanswer = (event) => {
QnAadmin['A'] = event.target.value
setAnswer(event.target.value) setAnswer(event.target.value)
} }
function addSelectOption() { function addSelectOption() {
list.push( list.push(
<div className="input-group"> <div className="input-group">
<div className="input-group-prepend"> <div className="input-group-prepend">
<div className="input-group-text"> <div className="input-group-text">
<input type="radio" name="answer" /> <input type="radio" id={selectOption + 1} name="answer" />
</div> </div>
</div> </div>
<input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} /> <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
</div> </div>
) )
setselectOption(selectOption + 1) setselectOption(selectOption + 1)
} }
function handleClick() {
alert('입력이 완료되었습니다') function handleClick() {
// localStorage.setItem('Q', question) if (!question) {
// localStorage.setItem('Choose', choose) alert('문제가 입력되지 않았습니다.')
// localStorage.setItem('Answer', answer) }
// localStorage.setItem('P', password) else if (!choose) {
// localStorage.setItem('AP', adminpassword) alert('보기가 입력되지 않았습니다.')
// localStorage.setItem('T', time * 1000) }
else if (!answer) {
alert('정답이 입력되지 않았습니다.')
}
else {
console.log(QnAadmin)
QnAadmins.push(QnAadmin)
localStorage.setItem('QnA', JSON.stringify(QnAadmins))
console.log(QnAadmins)
alert('입력이 완료되었습니다.')
}
} }
......
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