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
aebc0b83
Commit
aebc0b83
authored
Aug 09, 2020
by
Jiwon Yoon
Browse files
radio button reset
parent
3fbe99fd
Changes
2
Show whitespace changes
Inline
Side-by-side
src/Home.js
View file @
aebc0b83
...
...
@@ -23,7 +23,7 @@ function Home() {
else
if
(
!
password
)
{
alert
(
'
비밀번호를 입력하세요
'
)
}
else
if
(
password
!==
'
0
319
'
)
{
else
if
(
password
!==
'
0
000
'
)
{
alert
(
'
유효한 비밀번호를 입력하세요
'
)
}
else
{
...
...
src/Quiz.js
View file @
aebc0b83
import
React
,
{
useState
}
from
'
react
'
import
{
Link
}
from
'
react-router-dom
'
;
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
logo
from
'
./img_question.png
'
import
logo
from
'
./img/img_question.png
'
const
QnA
=
[
{
Q
:
"
6 X 4 = ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
"
4
"
,
N
:
1
},
...
...
@@ -22,22 +20,21 @@ function Quiz() {
page
:
0
,
})
const
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것들
// const [checked, setChecked] = useState(false)
function
handleQuestion
()
{
setQuestion
({
...
QnA
[
question
.
i
+
1
],
i
:
question
.
i
+
1
,
page
:
question
.
page
+
1
})
// setCh
ec
k
ed(
false
)
setSel
ec
t
ed
(
""
)
}
let
handleChange
=
(
ev
)
=>
{
// ev.preventDefault() //새로고침 안되도록
setSelected
(
ev
.
target
.
value
)
//selected값 변경
Answers
[
question
.
N
-
1
]
=
Number
(
ev
.
target
.
id
)
+
1
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
}
return
(
<
div
className
=
"
container-fluid
position-absolute
"
>
<
div
className
=
"
container-fluid
"
>
<
div
className
=
"
text-center h2 font-weight-bold bg-warning py-2
"
>
미적분학
퀴즈
<
/div
>
<
div
className
=
"
row justify-content-md-center
"
>
<
div
className
=
"
col text-right
"
>
...
...
@@ -53,7 +50,7 @@ function Quiz() {
<
form
>
{
question
.
Choose
.
map
((
a
,
index
)
=>
<
div
key
=
{
index
}
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onC
lick
=
{
handleChange
}
/
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onC
hange
=
{
handleChange
}
checked
=
{
parseInt
(
selected
)
===
a
}
/
>
<
label
className
=
"
font-weight-bold
"
htmlFor
=
{
a
}
>
{
a
}
<
/label
>
<
/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