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
2d157ec6
Commit
2d157ec6
authored
Jul 27, 2020
by
baesangjune
Browse files
ㅇ
parent
798393cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
debug.log
0 → 100644
View file @
2d157ec6
src/Quiz.js
View file @
2d157ec6
...
...
@@ -21,17 +21,18 @@ class Quiz extends React.Component {
i
:
0
,
page
:
0
,
}
this
.
textInput
=
React
.
createRef
()
//
this.textInput = React.createRef()
}
ShowQuiz
()
{
this
.
setState
({
page
:
1
})
}
setQuestion
()
{
//값이 입력되지 않은채로 넘겨졌을 때 문제 해결 해야 함-sj-
this
.
setState
({
...
question
[
this
.
state
.
i
+
1
],
i
:
this
.
state
.
i
+
1
})
}
//answerbox - answer박스의 값을 네임리스트로 받아와서 값을 localstorage에 저장
answerbox
()
{
let
answers
=
document
.
getElementsByName
(
'
answer
'
);
let
count
=
answers
.
length
...
...
@@ -42,7 +43,7 @@ class Quiz extends React.Component {
if
(
answers
[
i
].
checked
)
{
// checked_index = i;
checked_value
=
answers
[
i
].
value
;
localStorage
.
setItem
(
'
answer
'
+
i
,
checked_value
)
localStorage
.
setItem
(
'
answer
-
'
+
i
,
checked_value
)
}
}
// alert('선택된 항목 인덱스: ' + checked_index + '\n선택된 항목 값: ' + checked_value);
...
...
@@ -64,6 +65,7 @@ class Quiz extends React.Component {
// }
render
()
{
if
(
this
.
state
.
page
===
1
)
{
this
.
answerbox
()
if
(
this
.
state
.
i
===
question
.
length
)
{
return
(
<
div
>
...
...
@@ -77,9 +79,9 @@ class Quiz extends React.Component {
<
h2
>
Q
:{
this
.
state
.
Q
}
<
/h2
>
{
this
.
state
.
Choose
.
map
((
a
)
=>
<
div
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
a
}
value
=
{
a
}
ref
=
{
this
.
textInput
}
/
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
a
}
value
=
{
a
}
/*
ref={this.textInput}
*/
/>
<
label
for
=
{
a
}
>
{
a
}
<
/label
>
{
this
.
answerbox
()}
<
/div>
)
}
<
div
className
=
"
App
"
>
...
...
@@ -88,7 +90,7 @@ class Quiz extends React.Component {
{
/* <div>
<input type="text" value={this.state.v} name="A" onChange={this.setAnswer} />
</div> */
}
<
button
type
=
"
button
"
onClick
=
{
this
.
setQuestion
}
>
다음
<
/button
>
<
button
type
=
"
button
"
onClick
=
{
setTimeout
(
this
.
setQuestion
,
2000
)
}
>
다음
<
/button
>
<
/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