Commit 7791de51 authored by baesangjune's avatar baesangjune
Browse files

.

parent b5f735f8
......@@ -27,7 +27,7 @@ function Admin() {
setresult(<AdminQuiz quizNum={e.target.id} fn={handleClickSave} data={dbRef.current[e.target.id-1]} />) //설명 부탇드립니다.
}
else{
dbRef.current[e.target.id-1] = {'Q':'x', 'Choose':[0,0,0,0], 'A':'x'}
dbRef.current[e.target.id-1] = {'Q':'문제를 입력하세요', 'Choose':['0','0','0','0'], 'A':'정답을 입력하세요'}
setresult(<AdminQuiz quizNum={e.target.id} fn={handleClickSave} data={dbRef.current[e.target.id-1]} />)
}
}
......
......@@ -7,19 +7,28 @@ let savechoose = {}
function AdminQuiz(props) {
const [question, setQuestion] = useState(props.data.Q)
const [choose, setChoose] = useState(props.data.Choose)
// const [choose, setChoose] = useState(props.data.Choose)
const [choose, setChoose] = useState('')
const [answer, setAnswer] = useState(props.data.A)
const [selectOption, setselectOption] = useState(1)
// const [c, setC] = useState(props.data.Choose)
console.log(props.data.Choose)
console.log(choose)
// console.log
// props.quizNum가 바뀔때마다 즉, Admin.js에서 퀴즈버튼을 바꿔누를때마다 useEffect가 발생하여 값을 업데이트 시켜줍니다.
useEffect(() => {
setQuestion(props.data.Q)
setChoose(props.data.Choose)
// setC(props.data.Choose)
setAnswer(props.data.A)
console.log(props.data.Choose)
console.log(choose)
// document.getElementById('3').value = c[2]
// document.getElementById('4').value = c[3]
// setcn(props.data.Choose)
// eslint-disable-next-line
}, [props.quizNum])
const handleChangeQuestion = (event) => {
QnAadmin['Q'] = event.target.value
setQuestion(event.target.value)
......@@ -28,7 +37,7 @@ function AdminQuiz(props) {
const handleChangeChoose = (event) => {
savechoose[event.target.id] = event.target.value
setChoose(event.target.value)
console.log(event.target.value)
// console.log(event.target.value)
}
const handleChangeanswer = (event) => {
......@@ -44,7 +53,7 @@ function AdminQuiz(props) {
<input type="radio" checked={false} name="answer" />
</div>
</div>
<input type="text" class="form-control" id={String(selectOption + 1)} value={choose[selectOption]} placeholder={(selectOption + 1) + '번 보기를 입력하세요'} onChange={handleChangeChoose} />
<input type="text" class="form-control" id={String(selectOption + 1)} placeholder={(selectOption + 1) + '번 보기를 입력하세요'} onChange={handleChangeChoose} />
</div>
)
setselectOption(selectOption + 1)
......@@ -63,8 +72,6 @@ function AdminQuiz(props) {
}
else {
QnAadmin['Choose'] = Object.values(savechoose)
console.log(savechoose)
console.log(QnAadmin.Choose)
QnAadmin['N'] = String(props.quizNum)
props.fn(QnAadmin)
QnAadmin = {}
......@@ -90,9 +97,9 @@ function AdminQuiz(props) {
<input type="radio" checked={false} name="answer" />
</div>
</div>
<input type="text" className="form-control" id='1' value={choose[0]} placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
<input type="text" className="form-control" id='1' placeholder="1번 보기를 입력하세요" onChange={handleChangeChoose} />
</div>
{list.map((element) => element)}
{list.map((element, index) => element)}
<button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
</div>
</div>
......
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