Commit dc027bff authored by JeongYeonwoo's avatar JeongYeonwoo
Browse files

quiz

parent 346060e8
...@@ -15,29 +15,28 @@ function Quiz() { ...@@ -15,29 +15,28 @@ function Quiz() {
i: 0, i: 0,
page: 0, page: 0,
}) })
let [selected,setSelected] = useState("") //선택한 답을 보여줄 것들 let [selected, setSelected] = useState("") //선택한 답을 보여줄 것들
function setQuestion() { function setQuestion() {
setQuestionss({ ...QnA[question.i + 1], i: question.i + 1, page: question.page + 1 }) setQuestionss({ ...QnA[question.i + 1], i: question.i + 1, page: question.page + 1 })
} }
let handleChange = (ev) => { let handleChange = (ev) => {
ev.preventDefault() //새로고침 안되도록 ev.preventDefault() //새로고침 안되도록
setSelected(ev.target.value) //selected값 변경 setSelected(ev.target.value) //selected값 변경
let slt=ev.target.value //slt에 선택한값 받아옴 let slt = ev.target.value //slt에 선택한값 받아옴
let count = question.Choose.length //이거 정확히 뭘로할지 모르겠어요 ㅜㅜ let count = question.Choose.length //이거 정확히 뭘로할지 모르겠어요 ㅜㅜ
// let checked_index = -1; // let checked_index = -1;
let checked_value = ''; let checked_value = '';
checked_value = slt; checked_value = slt;
//localStorage.setItem('번문제 답' + checked_value, checked_value) //localStorage.setItem('번문제 답' + checked_value, checked_value)
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
if (ev.target.checked) { //이거 맞는지도 잘.. if (ev.target.checked) { //이거 맞는지도 잘..
// checked_index = i; // checked_index = i;
checked_value = slt; checked_value = slt;
localStorage.setItem(question.i+1 + '번문제 답', checked_value) localStorage.setItem(question.i + 1 + '번문제 답', checked_value)
} }
} }
} }
...@@ -46,15 +45,16 @@ function Quiz() { ...@@ -46,15 +45,16 @@ function Quiz() {
<h2>Q:{question.Q}</h2> <h2>Q:{question.Q}</h2>
<div> <div>
<form onSubmit={handleChange}> <form onSubmit={handleChange}>
{question.Choose.map( (a,index) => {question.Choose.map((a, index) =>
<div key={index}> <div key={index}>
<input type="radio" name='answer' id={'anwer' + a} value={a} onClick={handleChange} /> <input type="radio" name='answer' id={'anwer' + a} value={a} onClick={handleChange} />
<label htmlFor={a}> {a}</label> <label htmlFor={a}> {a}</label>
</div> </div>
)} )}
<input hidden type="submit" value="확인" /> {/*버튼 숨김*/} <input hidden type="submit" value="확인" /> {/*버튼 숨김*/}
</form> </form>
<h3>선택한 : {selected}</h3> {/* 선택한 보여줌 */} <p>선택한 :<span style={{color : "green", fontWeight : "bold", fontSize: "30px"}}> {selected}</span> {/* 선택한 보여줌 */}
</p>
</div> </div>
...@@ -71,7 +71,7 @@ function Quiz() { ...@@ -71,7 +71,7 @@ function Quiz() {
{/* <input onKeyPress="this.enterkey()"/> */} {/* <input onKeyPress="this.enterkey()"/> */}
<Timer <Timer
initialTime={3050} initialTime={3050}
direction="backward" direction="backward"
...@@ -88,8 +88,7 @@ function Quiz() { ...@@ -88,8 +88,7 @@ function Quiz() {
<Timer.Seconds /> seconds <Timer.Seconds /> seconds
</> </>
)} )}
</Timer> </Timer> {/* npm i react-compound-timer */}
{/* npm i react-compound-timer */}
</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