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
68deb13a
Commit
68deb13a
authored
Jul 29, 2020
by
baesangjune
Browse files
.
parent
6bdefa5b
Changes
3
Show whitespace changes
Inline
Side-by-side
src/End.js
View file @
68deb13a
...
@@ -8,12 +8,12 @@ function End() {
...
@@ -8,12 +8,12 @@ function End() {
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
if
(
localStorage
.
getItem
(
i
+
'
번문제답
'
)
===
localStorage
.
getItem
(
i
+
'
번문제정답
'
))
{
if
(
localStorage
.
getItem
(
i
+
'
번문제답
'
)
===
localStorage
.
getItem
(
i
+
'
번문제정답
'
))
{
alert
(
'
정답입니다.
'
)
k
[
i
]
=
[
'
O
'
,
1
]
k
[
i
]
=
[
'
O
'
,
1
]
}
}
else
{
else
{
alert
(
'
오답입니다.
'
)
k
[
i
]
=
[
'
X
'
,
0
]
k
[
i
]
=
[
'
X
'
,
0
]
}
}
}
}
...
...
src/Home.js
View file @
68deb13a
import
React
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
Link
}
from
'
react-router-dom
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
// import { Link } from 'react-router-dom';
function
Home
()
{
function
Home
()
{
const
[
name
,
setName
]
=
useState
(
''
)
const
[
done
,
setDone
]
=
useState
(
false
)
const
handleChange
=
(
event
)
=>
{
setName
(
event
.
target
.
value
)
}
function
checking
(
event
)
{
if
(
!
name
)
{
alert
(
'
이름을 입력하세요
'
)
}
else
{
alert
(
'
입력하신 이름은
'
+
name
+
'
입니다.
'
)
localStorage
.
setItem
(
'
name
'
,
name
)
setDone
(
true
)
}
}
return
(
return
(
<>
<>
<
div
classXName
=
"
Box
"
>
{
done
?
<
Redirect
to
=
'
/quiz
'
/>
:
''
}
<
div
className
=
"
Name
"
>
<
div
className
=
"
Box
"
>
이름을
입력하세요
<
div
className
=
"
Name
"
>
이름을
입력하세요
<
input
onChange
=
{
(
event
)
=>
localStorage
.
setItem
(
'
name
'
,
event
.
target
.
value
)
}
/
>
<
input
onChange
=
{
handleChange
}
/
>
<
/div
>
<
/div
>
<
div
>
{
/* sessionStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
<
/div
>
<
div
className
=
'
Box2
'
>
<
Link
to
=
"
/quiz
"
>
<
button
className
=
"
QuizStart
"
onClick
=
{
checking
}
>
Quiz
Start
!<
/button
>
<
button
className
=
"
QuizStart
"
onClick
=
{
checking
}
>
Quiz
Start
!<
/button
>
<
/
Link
>
<
/
div
>
<
/div
>
<
/div
>
<
/
>
<
/
>
)
)
}
}
function
checking
(
event
)
{
if
(
localStorage
.
getItem
(
'
name
'
)
===
null
||
localStorage
.
getItem
(
'
name
'
).
length
===
0
)
{
alert
(
'
이름을 입력하세요
'
)
}
else
{
alert
(
'
입력하신 이름은
'
+
localStorage
.
getItem
(
'
name
'
)
+
'
입니다.
'
)
}
}
export
default
Home
;
export
default
Home
;
\ No newline at end of file
src/Quiz.js
View file @
68deb13a
...
@@ -37,8 +37,8 @@ class Quiz extends React.Component {
...
@@ -37,8 +37,8 @@ class Quiz extends React.Component {
if
(
answers
[
i
].
checked
)
{
if
(
answers
[
i
].
checked
)
{
// checked_index = i;
// checked_index = i;
checked_value
=
answers
[
i
].
value
;
checked_value
=
answers
[
i
].
value
;
localStorage
.
setItem
(
this
.
state
.
i
+
'
번문제답
'
,
checked_value
)
localStorage
.
setItem
(
this
.
state
.
i
+
1
+
'
번문제답
'
,
checked_value
)
localStorage
.
setItem
(
this
.
state
.
i
+
'
번문제정답
'
,
question
[
i
-
1
].
A
)
localStorage
.
setItem
(
this
.
state
.
i
+
1
+
'
번문제정답
'
,
question
[
i
-
1
].
A
)
}
}
}
}
}
}
...
@@ -94,7 +94,7 @@ class Quiz extends React.Component {
...
@@ -94,7 +94,7 @@ class Quiz extends React.Component {
}
}
{
/* <input onKeyPress="this.enterkey()"/> */
}
{
/* <input onKeyPress="this.enterkey()"/> */
}
{
this
.
timer
()}
{
/*
{this.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