Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
online-quiz-react
Commits
dc027bff
Commit
dc027bff
authored
Aug 01, 2020
by
JeongYeonwoo
Browse files
quiz
parent
346060e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Quiz.js
View file @
dc027bff
...
@@ -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
>
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment