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
ce569345
Commit
ce569345
authored
Jul 29, 2020
by
Jiwon Yoon
Browse files
Merge branch 'jiwon' into TeamJS
parents
7306d873
89cbc788
Changes
6
Hide whitespace changes
Inline
Side-by-side
package-lock.json
View file @
ce569345
...
@@ -3773,9 +3773,9 @@
...
@@ -3773,9 +3773,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
},
"@types/node": {
"@types/node": {
"version": "14.0.2
6
",
"version": "14.0.2
7
",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.2
6
.tgz",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.2
7
.tgz",
"integrity": "sha512-
W+fpe5s91FBGE0pEa0lnqGLL4USgpLgs4nokw16SrBBco/gQxuua7KnArSEOd5iaMqbbSHV10vUDkJYJJqpXKA
=="
"integrity": "sha512-
kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g
=="
},
},
"@types/parse-json": {
"@types/parse-json": {
"version": "4.0.0",
"version": "4.0.0",
...
...
src/App.js
View file @
ce569345
...
@@ -14,17 +14,17 @@ function App() {
...
@@ -14,17 +14,17 @@ function App() {
<
button
>
Calculus
<
/button
>
<
button
>
Calculus
<
/button
>
<
/Link
>
<
/Link
>
<
/header
>
<
/header
>
<
hr
/>
<
hr
/>
<
div
>
<
div
>
<
Switch
>
<
Switch
>
<
Route
exact
path
=
"
/
"
>
<
Route
exact
path
=
"
/
"
>
<
Home
/>
<
Home
/>
<
/Route
>
<
/Route
>
<
Route
path
=
"
/quiz
"
>
<
Route
path
=
"
/quiz
"
>
<
Quiz
/>
<
Quiz
/>
<
/Route
>
<
/Route
>
<
Route
path
=
"
/end
"
>
<
Route
path
=
"
/end
"
>
<
End
/>
<
End
/>
<
/Route
>
<
/Route
>
<
/Switch
>
<
/Switch
>
<
/div
>
<
/div
>
...
...
src/End.js
View file @
ce569345
...
@@ -3,12 +3,47 @@ import React from 'react'
...
@@ -3,12 +3,47 @@ import React from 'react'
function
End
()
{
function
End
()
{
let
k
=
[]
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
if
(
localStorage
.
getItem
(
i
+
'
번문제답
'
)
===
localStorage
.
getItem
(
i
+
'
번문제정답
'
))
{
alert
(
'
정답입니다.
'
)
k
[
i
]
=
[
'
O
'
,
1
]
}
else
{
alert
(
'
오답입니다.
'
)
k
[
i
]
=
[
'
X
'
,
0
]
}
}
return
(
return
(
<
div
className
=
"
Box
"
>
<>
<
h2
>
수고하셨습니다
!<
/h2
>
<
/div
>
<
div
className
=
"
card
"
>
<
div
className
=
'
card-header
'
>
-
채점표
-
<
/div
>
<
div
className
=
'
card-body
'
>
<
h3
className
=
'
card-title
'
>
이름
:
{
localStorage
.
getItem
(
'
name
'
)}
<
/h3
>
<
p
className
=
'
card-text
'
>
Quiz
1
:
{
k
[
0
][
0
]}
<
/p
>
<
p
className
=
'
card-text
'
>
Quiz
2
:
{
k
[
1
][
0
]}
<
/p
>
<
p
className
=
'
card-text
'
>
Quiz
3
:
{
k
[
2
][
0
]}
<
/p
>
<
p
className
=
'
card-text
'
>
Total
Score
:
{
k
[
0
][
1
]
+
k
[
1
][
1
]
+
k
[
2
][
1
]}
<
/p
>
<
/div
>
<
div
className
=
"
Box text-center
"
>
<
h1
>
수고하셨습니다
.
<
/h1
>
<
/div
>
<
/div
>
<
/
>
)
)
}
}
export
default
End
;
export
default
End
;
\ No newline at end of file
src/Home.js
View file @
ce569345
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
)
=>
sessionStorage
.
setItem
(
'
name
'
,
event
.
target
.
value
)}
/
>
<
input
onChange
=
{
handleChange
}
/
>
<
/div
>
<
div
>
<
button
className
=
"
QuizStart
"
onClick
=
{
checking
}
>
Quiz
Start
!<
/button
>
<
/div
>
<
/div
>
<
button
onClick
=
{(
event
)
=>
checking
(
event
)}
>
이름입력완료
<
/button
>
{
/* sessionStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
<
/div
>
<
div
className
=
'
Box2
'
>
<
Link
to
=
"
/quiz
"
>
<
button
className
=
"
QuizStart
"
>
Quiz
Start
!<
/button
>
<
/Link
>
<
/div
>
<
/div
>
<
/
>
<
/
>
)
)
}
}
function
checking
(
event
)
{
function
checking
(
event
)
{
...
@@ -33,4 +45,6 @@ function checking(event) {
...
@@ -33,4 +45,6 @@ function checking(event) {
}
}
}
}
export
default
Home
;
export
default
Home
;
\ No newline at end of file
src/Quiz.js
View file @
ce569345
...
@@ -3,9 +3,9 @@ import { Link } from 'react-router-dom';
...
@@ -3,9 +3,9 @@ import { Link } from 'react-router-dom';
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
const
question
=
[
const
question
=
[
{
Q
:
"
6 X 4 ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
""
,
N
:
1
},
{
Q
:
"
6 X 4 ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
"
24
"
,
N
:
1
},
{
Q
:
"
3 + 3 ?
"
,
Choose
:
[
2
,
4
,
6
,
8
],
A
:
""
,
N
:
2
},
{
Q
:
"
3 + 3 ?
"
,
Choose
:
[
2
,
4
,
6
,
8
],
A
:
"
6
"
,
N
:
2
},
{
Q
:
"
3 - 1 ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
""
,
N
:
3
}
{
Q
:
"
3 - 1 ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
"
2
"
,
N
:
3
}
]
]
class
Quiz
extends
React
.
Component
{
class
Quiz
extends
React
.
Component
{
...
@@ -13,6 +13,7 @@ class Quiz extends React.Component {
...
@@ -13,6 +13,7 @@ class Quiz extends React.Component {
super
(
props
)
super
(
props
)
this
.
setQuestion
=
this
.
setQuestion
.
bind
(
this
)
this
.
setQuestion
=
this
.
setQuestion
.
bind
(
this
)
this
.
answerbox
=
this
.
answerbox
.
bind
(
this
)
this
.
answerbox
=
this
.
answerbox
.
bind
(
this
)
this
.
timer
=
this
.
timer
.
bind
(
this
)
// this.enterkey = this.enterkey(this)
// this.enterkey = this.enterkey(this)
this
.
state
=
{
this
.
state
=
{
...
question
[
0
],
...
question
[
0
],
...
@@ -36,10 +37,32 @@ class Quiz extends React.Component {
...
@@ -36,10 +37,32 @@ 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
(
'
answer-
'
+
i
,
checked_value
)
localStorage
.
setItem
(
this
.
state
.
i
+
'
번문제답
'
,
checked_value
)
localStorage
.
setItem
(
this
.
state
.
i
+
'
번문제정답
'
,
question
[
i
-
1
].
A
)
}
}
}
}
}
}
timer
(){
return
(
<
Timer
initialTime
=
{
10010
}
direction
=
"
backward
"
checkpoints
=
{[
{
time
:
0
,
callback
:
this
.
setQuestion
// history.go(1)
}
]}
>
{()
=>
(
<>
<
Timer
.
Seconds
/>
seconds
<
/
>
)}
<
/Timer> /
*
npm
i
react
-
compound
-
timer
*
/
)
}
// enterkey() {
// enterkey() {
// if ( window.event === 13 ) {
// if ( window.event === 13 ) {
// alert("Enter Key 입력 감지 \n함수 실행.");
// alert("Enter Key 입력 감지 \n함수 실행.");
...
@@ -54,7 +77,7 @@ class Quiz extends React.Component {
...
@@ -54,7 +77,7 @@ class Quiz extends React.Component {
<
div
>
<
div
>
{
this
.
state
.
Choose
.
map
((
a
)
=>
{
this
.
state
.
Choose
.
map
((
a
)
=>
<
div
>
{
this
.
state
.
N
}
<
div
>
{
this
.
state
.
N
}
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
'
anwer
'
+
a
}
value
=
{
a
}
/*ref={this.textInput} input 네임을 문제단위로 바꾸어주어야 함. */
/
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
a
}
value
=
{
a
}
/*ref={this.textInput} input 네임을 문제단위로 바꾸어주어야 함. */
/
>
<
label
for
=
{
a
}
>
{
a
}
<
/label
>
<
label
for
=
{
a
}
>
{
a
}
<
/label
>
<
/div>
)
<
/div>
)
...
@@ -71,27 +94,11 @@ class Quiz extends React.Component {
...
@@ -71,27 +94,11 @@ class Quiz extends React.Component {
}
}
{
/* <input onKeyPress="this.enterkey()"/> */
}
{
/* <input onKeyPress="this.enterkey()"/> */
}
<
Timer
{
this
.
timer
()}
initialTime
=
{
5000
}
direction
=
"
backward
"
checkpoints
=
{[
{
time
:
0
,
callback
:
()
=>
console
.
log
(
'
콜백실행
'
)
// history.go(1)
}
]}
>
{()
=>
(
<>
<
Timer
.
Seconds
/>
seconds
<
/
>
)}
<
/Timer> {/
*
npm
i
react
-
compound
-
timer
*
/
}
<
/div
>
<
/div
>
)
)
}
}
}
}
export
default
Quiz
;
export
default
Quiz
;
\ No newline at end of file
src/history.js
0 → 100644
View file @
ce569345
import
{
createBrowserHistory
as
history
}
from
'
history
'
;
export
default
history
()
\ No newline at end of file
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