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

.

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