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
1be55b6e
Commit
1be55b6e
authored
Aug 10, 2020
by
JeongYeonwoo
Browse files
Home_edit
parent
a7a24e03
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/End.js
View file @
1be55b6e
import
React
from
'
react
'
import
tr
from
'
./img_end.jpg
'
;
import
'
./End.css
'
import
tr
from
'
./img/img_end.jpg
'
;
// import { Link } from 'react-router-dom';
...
...
@@ -9,7 +10,7 @@ function End() {
let
score
=
0
const
answers
=
JSON
.
parse
(
localStorage
.
getItem
(
'
Answers
'
))
const
solutions
=
JSON
.
parse
(
localStorage
.
getItem
(
'
Solutions
'
))
for
(
let
i
=
0
;
i
<
answers
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
answers
.
length
;
i
++
)
{
if
(
answers
[
i
]
===
solutions
[
i
])
{
...
...
@@ -22,39 +23,37 @@ function End() {
}
score
+=
scores
[
i
]
}
return
(
<>
<
div
className
=
"
card
"
style
=
{{
fontSize
:
'
30px
'
,
textAlign
:
"
center
"
}}
>
<
div
className
=
'
card-header
'
>
-
채점표
-
<
div
className
=
'
card-body
'
>
<
h3
className
=
'
card-title
'
>
이름
:
{
localStorage
.
getItem
(
'
name
'
)}
<
/h3
>
<
div
className
=
"
container
"
>
<
h2
>
채점표
<
/h2
>
<
table
className
=
"
table table-bordered
"
>
<
thead
>
<
tr
>
<
th
>
응시자
<
/th
>
<
th
>
{
localStorage
.
getItem
(
'
name
'
)}
<
/th
>
<
/tr
>
<
/thead
>
<
tbody
>
{
scores
.
map
((
score
,
index
)
=>
{
return
(
score
===
1
)
?
<
p
className
=
'
card-text
'
>
Quiz
{
index
+
1
}
:
'
O
'
<
/p> : <p className='card-text'>Quiz {index+1} : 'X' </
p
>
// if (score === 1) {
// return <p className='card-text'>Quiz {index+1} : 'O' </p>
// }
// else { return <p className='card-text'>Quiz {index+1} : 'X' </p> }
return
(
score
===
1
)
?
<
tr
><
td
>
Quiz
{
index
+
1
}
<
/td> <td> O </
td
><
/tr> : <tr><td>Quiz {index + 1}</
td
>
<
td
>
X
<
/td></
tr
>
})}
<
p
className
=
'
card-text
'
>
Total
Score
:
{
score
}
<
/p
>
<
/div
>
<
div
style
=
{{
marginTop
:
'
100px
'
}}
className
=
"
Box text-center
"
>
<
img
src
=
{
tr
}
alt
=
"
수고
"
/>
<
/div
>
<
/div
>
<
tr
>
<
td
>
총점
<
/td
>
<
td
>
{
score
}
점
<
/td
>
<
/tr
>
<
/tbody
>
<
/table
>
<
/div
>
<
/
>
)
}
export
default
End
;
src/Home.css
View file @
1be55b6e
.container-fluid
{
/* background-image: url("./img/img_study.jpg"); */
background-color
:
white
;
background-size
:
100%
;
width
:
100%
;
height
:
600px
;
background-repeat
:
no-repeat
;
}
/* .writename{
class : text-center
} */
/* .Name {
font-size: 30px;
position: absolute;
top: 330px;
left: 38%
} */
/* .inputBox {
margin-left: 30px;
inline-size: 200px;
block-size: 40px;
font-size: 40px;
} */
/* .QuizStart {
margin-top: 35%;
block-size: 100px;
inline-size: 200px;
font-size: 35px;
} */
\ No newline at end of file
src/Home.js
View file @
1be55b6e
// import bg from './img_study.jpg'
// import korea from './img_korea.jpg'
import
React
,
{
useState
}
from
'
react
'
import
{
Redirect
}
from
'
react-router-dom
'
;
import
'
./Home.css
'
function
Home
()
{
const
[
name
,
setName
]
=
useState
(
''
)
const
[
password
,
SetPassword
]
=
useState
(
''
)
const
[
done
,
setDone
]
=
useState
(
false
)
const
handleChange
=
(
event
)
=>
{
const
handleChange
name
=
(
event
)
=>
{
setName
(
event
.
target
.
value
)
}
const
handleChangepassword
=
(
event
)
=>
{
SetPassword
(
event
.
target
.
value
)
}
function
checking
(
event
)
{
function
handleClick
(
)
{
if
(
!
name
)
{
alert
(
'
이름을 입력하세요
'
)
}
else
if
(
!
password
)
{
alert
(
'
비밀번호를 입력하세요
'
)
}
else
if
(
password
!==
'
0000
'
)
{
alert
(
'
유효한 비밀번호를 입력하세요
'
)
}
else
{
alert
(
'
입력하신 이름은
'
+
name
+
'
입니다.
'
)
alert
(
'
입력하신 이름은
'
+
name
+
'
입니다.
'
)
localStorage
.
setItem
(
'
name
'
,
name
)
localStorage
.
setItem
(
'
password
'
,
password
)
setDone
(
true
)
}
}
return
(
<>
{
done
?
<
Redirect
to
=
'
/quiz
'
/>
:
''
}
<
div
className
=
"
d-flex justify-content-center
"
>
<
table
className
=
"
table table-borderless
"
style
=
{{
width
:
"
500px
"
}}
>
<
thead
className
=
"
text-center
"
>
<
tr
style
=
{{
height
:
"
180px
"
}}
><
/tr
>
<
/thead
>
<
tbody
className
=
"
text-center
"
>
<
tr
>
<
td
>
이름
입력
<
input
className
=
"
ml-2 inputBox
"
onChange
=
{
handleChange
}
/></
td
>
<
/tr
>
<
tr
>
<
td
>
비밀번호
<
input
className
=
"
ml-2 inputBox
"
onChange
=
{
handleChange
}
/></
td
>
<
/tr
>
<
tr
>
<
td
><
button
className
=
"
mt-4 btn btn-dark
"
onClick
=
{
checking
}
>
Quiz
Start
!<
/button></
td
>
<
/tr
>
<
/tbody
>
<
/table
>
{
/* <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
<div className="Main"></div> */
}
{
/*
<div style={{ fontSize: '70px', marginBottom: '100px', textAlign: 'center', backgroundColor: '#AE0E36' }}> */
}
{
/* <img alt='korea' src={korea} width='10%'/> */
}
{
/* KOREA UNIVERSITY
</div> */
}
<
h1
className
=
"
h-3 mb-5 mx-3 text-center bg-danger py-2
"
>
KOREA
UNIVERSITY
<
/h1
>
<
form
className
=
"
d-flex justify-content-center
"
>
<
div
className
=
"
table table-bordered
"
style
=
{{
width
:
"
400px
"
}}
>
<
label
for
=
"
inputId
"
className
=
"
d-flex justify-content-center
"
>
정보
입력
<
/label
>
<
div
className
=
"
form-group text-center
"
>
<
label
for
=
"
inputName
"
>
이름입력
<
input
className
=
"
ml-3 inputBox
"
onChange
=
{
handleChangename
}
placeholder
=
"
Name
"
/>
<
/label
>
<
label
for
=
"
inputPassword
"
>
비밀번호
<
input
type
=
'
password
'
className
=
"
ml-3 inputBox
"
onChange
=
{
handleChangepassword
}
placeholder
=
"
Password
"
/>
<
/label
>
<
div
className
=
"
form-group for login
"
>
<
label
for
=
"
inputLogin
"
className
=
"
d-flex justify-content-center
"
>
<
button
className
=
"
mt-4 btn btn-dark
"
onClick
=
{
handleClick
}
>
Login
<
/button
>
<
/label
>
<
/div
>
<
/div
>
<
/div
>
<
/form
>
{
/*
<div className="container">
<div className="row justify-content-center mb-5 mt-5">
<div className="col-md-4"></div>
<div className="col-md-4"> </div>
<div className="col-md-4"></div>
</div>
<div className="row text-center p-3">
<div className="col-md-4"></div>
<div className="col-md-4">이름입력<input className="ml-2 inputBox" onChange={handleChangename} /></div>
<div className="col-md-4"></div>
</div>
<div className="row text-center">
<div className="col-md-4"></div>
<div className="col-md-4">비밀번호<input type='password' className="ml-2 inputBox" onChange={handleChangepassword} /></div>
<div className="col-md-4"></div>
</div>
<div className="row text-center">
<div className="col-md-4"></div>
<div className="col-md-4"><button className="mt-4 btn btn-dark" onClick={handleClick}>Login</button></div>
<div className="col-md-4"></div>
</div>
</div>
*/
}
{
/*
<div className="container-fluid">
<div className="text-center">
<div>
이름을 입력하세요
</div>
<input className="inputBox" onChange={handleChange} />
<div className='Box2'>
<button className="btn btn-dark" onClick={checking}>Quiz Start !</button>
</div>
</div>
</div> */
}
<div className="d-flex justify-content-center ">
<
div
>
계산수학
<
/div
>
<table className="table table-bordered dark-table" style={{ width: "400px" }}>
<thead className="text-center">
<tr style={{ height: "0 px" }}>정보 입력</tr>
</thead>
<tbody className="text-center">
<tr>
<td>이름 입력<input className="ml-2 inputBox" onChange={handleChangename} /></td>
</tr>
<tr>
<td>비밀번호<input type='password' className="ml-2 inputBox" onChange={handleChangepassword} /></td>
</tr>
<tr>
<td><button className="mt-4 btn btn-dark" onClick={handleClick}>Login</button></td>
</tr>
</tbody>
</table>
</div>
*/
}
{
/* <div className="Box" style={{ border: 'solid', position: 'absolute', top: "300px", left: "68%"}} > */
}
{
/* <div className="Name" style={{boxShadow: '5px 5px 5px 5px gray', border: 'solid', fontSize: '30px', position: "absolute", top: "300px", left: "68%" }}>
이름(Name)
<input style={{ padding: '5px', border: 'solid', borderRight: 'none', borderBottom: 'none', borderTop: 'none', marginLeft: '105px', inlineSize: '160px', blockSize: '40px', fontSize: '40px' }} onChange={handleChangename} />
</div>
<div className="Name" style={{ boxShadow: '5px 5px 5px 5px gray',border: 'solid', fontSize: '30px', position: "absolute", top: "360px", left: "68%" }}>
비밀번호(Password)
<input type='password' style={{ padding: '5px', border: 'solid', borderRight: 'none', borderBottom: 'none', borderTop: 'none', marginLeft: '0px', inlineSize: '160px', blockSize: '40px', fontSize: '40px' }} onChange={handleChangepassword} />
</div>
<div className='Box2'>
<button style={{boxShadow: '5px 5px 5px 5px gray', marginLeft: '82%', marginTop: '10%', blockSize: '50px', inlineSize: '175px', fontSize: '35px' }} className="QuizStart" onClick={checking}>Start !</button>
</div> */
}
{
/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
{
/* </div> */
}
{
/* </div> */
}
<
/
>
)
}
export
default
Home
;
src/Quiz.js
View file @
1be55b6e
...
...
@@ -2,7 +2,6 @@ import React, { useState } from 'react'
import
{
Link
}
from
'
react-router-dom
'
;
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
logo
from
'
./img/img_question.png
'
import
fight
from
'
./img/img_quiz.png
'
const
QnA
=
[
{
Q
:
"
6 X 4 = ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
"
4
"
,
N
:
1
},
...
...
@@ -12,83 +11,90 @@ const QnA = [
let
Answers
=
[]
let
Solutions
=
[
4
,
3
,
2
]
localStorage
.
setItem
(
'
Solutions
'
,
JSON
.
stringify
(
Solutions
))
function
Quiz
()
{
let
[
question
,
setQuestion
]
=
useState
({
const
[
question
,
setQuestion
]
=
useState
({
...
QnA
[
0
],
i
:
0
,
page
:
0
,
})
le
t
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것
들
cons
t
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것
function
handleQuestion
()
{
setQuestion
({
...
QnA
[
question
.
i
+
1
],
i
:
question
.
i
+
1
,
page
:
question
.
page
+
1
})
setSelected
(
""
)
//페이지 넘어가면 Your Answer 초기화
}
let
handleChange
=
(
ev
)
=>
{
ev
.
preventDefault
()
//새로고침 안되도록
//
ev.preventDefault() //새로고침 안되도록
setSelected
(
ev
.
target
.
value
)
//selected값 변경
Answers
[
question
.
N
-
1
]
=
Number
(
ev
.
target
.
id
)
+
1
Answers
[
question
.
N
-
1
]
=
Number
(
ev
.
target
.
id
)
+
1
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
console
.
log
(
Answers
)
}
return
(
<>
<
div
style
=
{{
fontSize
:
'
80px
'
,
marginBottom
:
'
100px
'
,
textAlign
:
"
center
"
,
backgroundColor
:
'
yellow
'
}}
>
미적분학
퀴즈
<
/div
>
<
img
src
=
{
fight
}
style
=
{{
position
:
"
absolute
"
,
left
:
"
1050px
"
,
top
:
'
200px
'
}}
alt
=
"
lion
"
/>
<
div
className
=
"
Quiz
"
>
<
h1
><
img
src
=
{
logo
}
style
=
{{
marginLeft
:
"
450px
"
}}
width
=
'
75
'
height
=
'
75
'
alt
=
'
question
'
/>
<
span
style
=
{{
fontSize
:
"
75px
"
,
marginLeft
:
"
30px
"
}}
>
{
question
.
Q
}
<
/span></
h1
>
{
/* <div style={{ marginTop: "30px", marginBottom: "30px", marginLeft:'450px', fontSize:'40px' }}>정답을 선택하세요</div> */
}
<
div
>
<
form
>
{
question
.
Choose
.
map
((
a
,
index
)
=>
<
div
key
=
{
index
}
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onClick
=
{
handleChange
}
style
=
{{
marginLeft
:
"
475px
"
,
width
:
"
25px
"
,
height
:
"
25px
"
}}
/
>
<
label
htmlFor
=
{
a
}
style
=
{{
fontSize
:
"
40px
"
,
marginLeft
:
"
22px
"
}}
>
{
a
}
<
/label
>
<
/div
>
)}
<
input
hidden
type
=
"
submit
"
value
=
"
확인
"
/>
{
/*버튼 숨김*/
}
<
/form
>
<
p
style
=
{{
fontSize
:
"
40px
"
,
marginLeft
:
"
480px
"
}}
>
Answer
:
<
span
style
=
{{
color
:
"
green
"
,
fontWeight
:
"
bold
"
,
fontSize
:
"
90px
"
,
marginLeft
:
"
30px
"
}}
>
{
selected
}
<
/span> {/
*
선택한
값
보여줌
*
/}<span style={{ marginLeft: "50px" }}> {
(
question.page === QnA.length - 1
)
?
<
Link
to
=
"
/end
"
>
제출
<
/Link
>
:
<
button
type
=
"
button
"
onClick
=
{
handleQuestion
}
style
=
{{
width
:
"
85px
"
,
height
:
"
40px
"
}}
>
다음
<
/button
>
}
<
/span
>
<
/p
>
return
(
<
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
"
>
<
h1
>
<
img
src
=
{
logo
}
width
=
'
50
'
height
=
'
50
'
alt
=
'
question
'
/>
<
/h1
>
<
/div
>
<
div
className
=
"
col-md-auto
"
>
<
div
className
=
"
h2 mt-2
"
>
{
question
.
Q
}
<
/div
>
<
div
className
=
"
mt-2
"
>
<
form
>
{
question
.
Choose
.
map
((
a
,
index
)
=>
<
div
key
=
{
index
}
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onChange
=
{
handleChange
}
checked
=
{
parseInt
(
selected
)
===
a
}
/
>
<
label
className
=
"
font-weight-bold
"
htmlFor
=
{
a
}
>
{
a
}
<
/label
>
<
/div
>
)}
{
/* <input hidden type="submit" value="확인" /> */
}
{
/*버튼 숨김*/
}
<
/form
>
<
span
className
=
"
h5 font-weight-bold
"
>
Your
Answer
:
<
/span
>
<
span
className
=
"
h2 font-weight-bold text-danger
"
>
{
selected
}
<
/span> {/
*
선택한
값
보여줌
*
/
}
<
div
className
=
"
text-center my-3
"
>
{(
question
.
page
===
QnA
.
length
-
1
)
?
<
Link
to
=
"
/end
"
>
<
button
className
=
"
btn btn-outline-success
"
onClick
=
{
localStorage
.
setItem
(
'
Solutions
'
,
JSON
.
stringify
(
Solutions
))}
>
제출
<
/button
>
<
/Link
>
:
<
button
type
=
"
button
"
className
=
"
btn btn-outline-dark
"
onClick
=
{
handleQuestion
}
>
다음
<
/button
>
}
<
/div
>
<
p
className
=
"
h3 text-center text-danger
"
>
<
Timer
initialTime
=
{
3600000
}
direction
=
"
backward
"
checkpoints
=
{[
{
time
:
0
,
callback
:
<
Link
to
=
"
/end
"
>
제출
<
/Link
>
// history.go(1)
}
]}
>
{()
=>
(
<>
<
Timer
.
Minutes
/>
:
<
Timer
.
Seconds
><
/Timer.Seconds> /
60
:
00
<
/
>
)}
<
/Timer> {/
*
npm
i
react
-
compound
-
timer
*
/
}
<
/p
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
/div
>
<
/div
>
<
/div
>
)
{
/* 마지막 질문일 경우 /end페이지로 이동, 그렇지 않을경우는 this.handleQuestion발생 */
}
{
/* {(question.page === QnA.length - 1)
? <Link to="/end">제출</Link>
: <button type="button" onClick={handleQuestion} >다음</button>
} */
}
{
/* <input onKeyPress="this.enterkey()"/> */
}
<
p
style
=
{{
textAlign
:
"
center
"
,
fontSize
:
"
30px
"
,
color
:
"
crimson
"
}}
>
<
Timer
initialTime
=
{
3600000
}
direction
=
"
backward
"
checkpoints
=
{[
{
time
:
0
,
callback
:
<
Link
to
=
"
/end
"
>
제출
<
/Link
>
// history.go(1)
}
]}
>
{()
=>
(
<>
<
Timer
.
Minutes
/>
:
<
Timer
.
Seconds
><
/Timer.Seconds> /
60
:
00
<
/
>
)}
<
/Timer> {/
*
npm
i
react
-
compound
-
timer
*
/
}
<
/p
>
<
/div
>
<
/
>
)
}
...
...
src/img_korea.jpg
0 → 100644
View file @
1be55b6e
18.4 KB
src/index.js
View file @
1be55b6e
...
...
@@ -4,6 +4,7 @@ import './index.css';
import
App
from
'
./App
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
;
import
*
as
serviceWorker
from
'
./serviceWorker
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
ReactDOM
.
render
(
<
React
.
StrictMode
>
...
...
src/preQuiz.js
View file @
1be55b6e
import
React
from
'
react
'
;
// import logo from './logo.svg';
import
'
./Quiz.css
'
;
import
React
,
{
useState
}
from
'
react
'
import
{
Link
}
from
'
react-router-dom
'
;
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
logo
from
'
./img/img_question.png
'
import
'
./Quiz.css
'
const
question
=
[
{
Q
:
"
6 X 4 ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
"
"
},
{
Q
:
"
3 + 3 ?
"
,
Choose
:
[
2
,
4
,
6
,
8
],
A
:
"
"
},
{
Q
:
"
3 - 1 ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
"
"
}
const
QnA
=
[
{
Q
:
"
6 X 4
=
?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
"
4
"
,
N
:
1
},
{
Q
:
"
3 + 3
=
?
"
,
Choose
:
[
2
,
4
,
6
,
8
],
A
:
"
3
"
,
N
:
2
},
{
Q
:
"
3 - 1
=
?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
"
2
"
,
N
:
3
}
]
class
Quiz
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
)
// this.setAnswer = this.setAnswer.bind(this)
this
.
setQuestion
=
this
.
setQuestion
.
bind
(
this
)
this
.
ShowQuiz
=
this
.
ShowQuiz
.
bind
(
this
)
this
.
answerbox
=
this
.
answerbox
.
bind
(
this
)
this
.
state
=
{
...
question
[
0
],
i
:
0
,
page
:
0
,
}
// this.textInput = React.createRef()
}
ShowQuiz
()
{
this
.
setState
({
page
:
1
})
}
setQuestion
()
{
//값이 입력되지 않은채로 넘겨졌을 때 문제 해결 해야 함-sj-
this
.
setState
({
...
question
[
this
.
state
.
i
+
1
],
i
:
this
.
state
.
i
+
1
})
let
Answers
=
[]
let
Solutions
=
[
4
,
3
,
2
]
localStorage
.
setItem
(
'
Solutions
'
,
JSON
.
stringify
(
Solutions
))
}
//answerbox - answer박스의 값을 네임리스트로 받아와서 값을 localstorage에 저장
answerbox
()
{
let
answers
=
document
.
getElementsByName
(
'
answer
'
);
let
count
=
answers
.
length
// var checked_index = -1;
var
checked_value
=
''
;
function
Quiz
()
{
const
[
question
,
setQuestion
]
=
useState
({
...
QnA
[
0
],
i
:
0
,
page
:
0
,
})
const
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것들
// const [checked, setChecked] = useState(false)
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
if
(
answers
[
i
].
checked
)
{
// checked_index = i;
checked_value
=
answers
[
i
].
value
;
localStorage
.
setItem
(
'
answer-
'
+
i
,
checked_value
)
}
function
handleQuestion
()
{
setQuestion
({
...
QnA
[
question
.
i
+
1
],
i
:
question
.
i
+
1
,
page
:
question
.
page
+
1
})
// setChecked(false)
}
// alert('선택된 항목 인덱스: ' + checked_index + '\n선택된 항목 값: ' + checked_value);
// if (document.getElementsByName("answer")[i].checked === true) {
// alert(document.getElementsByName("answer")[i].value);
// }
}
// setAnswer(e) {
// question[this.state.i]["A"] = e.target.value
// this.setState({ v: e.target.value })
// console.log(this.state)
// console.log(question)
// }
render
()
{
if
(
this
.
state
.
page
===
1
)
{
this
.
answerbox
()
if
(
this
.
state
.
i
===
question
.
length
)
{
return
(
<
div
>
<
h2
>
수고하셨습니다
!<
/h2
>
<
/div
>
)
}
else
{
return
(
<
div
className
=
"
Quiz
"
>
<
h2
>
Q
:{
this
.
state
.
Q
}
<
/h2
>
{
this
.
state
.
Choose
.
map
((
a
)
=>
<
div
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
a
}
value
=
{
a
}
/*ref={this.textInput}*/
/>
<
label
for
=
{
a
}
>
{
a
}
<
/label
>
let
handleChange
=
(
ev
)
=>
{
// ev.preventDefault() //새로고침 안되도록
setSelected
(
ev
.
target
.
value
)
//selected값 변경
Answers
[
question
.
N
-
1
]
=
Number
(
ev
.
target
.
id
)
+
1
<
/div>
)
}
<
div
className
=
"
App
"
>
정답을
입력하세요
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
}
return
(
<
div
className
=
"
container-fluid position-absolute
"
>
<
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
"
>
<
h1
>
<
img
src
=
{
logo
}
width
=
'
50
'
height
=
'
50
'
alt
=
'
question
'
/>
<
/h1
>
<
/div
>
<
div
className
=
"
col-md-auto
"
>
<
div
className
=
"
h2 mt-2
"
>
{
question
.
Q
}
<
/div
>
<
div
className
=
"
mt-2
"
>
<
form
>
{
question
.
Choose
.
map
((
a
,
index
)
=>
<
div
key
=
{
index
}
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onClick
=
{
handleChange
}
/
>
<
label
className
=
"
font-weight-bold
"
htmlFor
=
{
a
}
>
{
a
}
<
/label
>
<
/div
>
)}
<
input
hidden
type
=
"
submit
"
value
=
"
확인
"
/>
{
/*버튼 숨김*/
}
<
/form
>
<
span
className
=
"
h5 font-weight-bold
"
>
Your
Answer
:
<
/span
>
<
span
className
=
"
h2 font-weight-bold text-danger
"
>
{
selected
}
<
/span> {/
*
선택한
값
보여줌
*
/
}
<
div
className
=
"
text-center my-3
"
>
{(
question
.
page
===
QnA
.
length
-
1
)
?
<
Link
to
=
"
/end
"
>
<
button
className
=
"
btn btn-outline-success
"
>
제출
<
/button
>
<
/Link
>
:
<
button
type
=
"
button
"
className
=
"
btn btn-outline-dark
"
onClick
=
{
handleQuestion
}
>
다음
<
/button
>
}
<
/div
>
<
p
className
=
"
h3 text-center text-danger
"
>
<
Timer
initialTime
=
{
3600000
}
direction
=
"
backward
"
checkpoints
=
{[
{
time
:
0
,
callback
:
<
Link
to
=
"
/end
"
>
제출
<
/Link
>
// history.go(1)
}
]}
>
{()
=>
(
<>
<
Timer
.
Minutes
/>
:
<
Timer
.
Seconds
><
/Timer.Seconds> /
60
:
00
<
/
>
)}
<
/Timer> {/
*
npm
i
react
-
compound
-
timer
*
/
}
<
/p
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
/div
>
<
/div
>
{
/* <div>
<input type="text" value={this.state.v} name="A" onChange={this.setAnswer} />
</div> */
}
<
button
type
=
"
button
"
onClick
=
{
setTimeout
(
this
.
setQuestion
,
2000
)}
>
다음
<
/button
>
<
/div
>
)
}
}
else
{
return
(
<
div
className
=
"
Box
"
>
<
div
className
=
"
Main
"
>
<
h1
>
Calculus
<
/h1
>
<
/div
>
<
div
className
=
"
Name
"
>
이름을
입력하세요
<
input
onChange
=
{(
event
)
=>
{
console
.
log
(
event
.
target
.
value
)
}}
/
>
<
/div
>
<
button
className
=
"
QuizStart
"
onClick
=
{
this
.
ShowQuiz
}
>
Quiz
Start
!<
/button
>
<
/div
>
)
)
}
}
}
export
default
Quiz
;
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