Commit dc027bff authored by JeongYeonwoo's avatar JeongYeonwoo
Browse files

quiz

parent 346060e8
...@@ -15,16 +15,15 @@ function Quiz() { ...@@ -15,16 +15,15 @@ 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 //이거 정확히 뭘로할지 모르겠어요 ㅜㅜ
...@@ -37,7 +36,7 @@ function Quiz() { ...@@ -37,7 +36,7 @@ function Quiz() {
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,7 +45,7 @@ function Quiz() { ...@@ -46,7 +45,7 @@ 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>
...@@ -54,7 +53,8 @@ function Quiz() { ...@@ -54,7 +53,8 @@ function Quiz() {
)} )}
<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>
...@@ -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