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
d3d5613c
Commit
d3d5613c
authored
Aug 05, 2020
by
Jiwon Yoon
Browse files
a
parent
72b2be6f
Changes
3
Show whitespace changes
Inline
Side-by-side
src/Home.js
View file @
d3d5613c
...
@@ -25,8 +25,8 @@ function Home() {
...
@@ -25,8 +25,8 @@ function Home() {
<>
<>
{
done
?
<
Redirect
to
=
'
/quiz
'
/>
:
''
}
{
done
?
<
Redirect
to
=
'
/quiz
'
/>
:
''
}
<
div
className
=
"
container-fluid
"
>
<
div
className
=
"
container-fluid
"
>
<
div
className
=
"
text-center
"
>
<
div
className
=
"
h-100
text-center
"
>
<
div
>
<
div
className
=
"
mb-5
"
>
이름을
입력하세요
이름을
입력하세요
<
/div
>
<
/div
>
<
input
className
=
"
inputBox
"
onChange
=
{
handleChange
}
/
>
<
input
className
=
"
inputBox
"
onChange
=
{
handleChange
}
/
>
...
...
src/Quiz.css
View file @
d3d5613c
.Main
{
.container-fluid
{
background
:
gray
;
background
:
white
;
background-image
:
url('')
;
width
:
100%
;
display
:
inline-block
;
height
:
500px
;
border
:
3px
solid
black
;
/* background-image: url('./img/img_quiz.png');
width
:
750px
;
background-repeat: no-repeat;
height
:
180px
;
background-position: right;
text-align
:
center
;
background-size: 200px; */
margin-left
:
410px
;
margin-top
:
10px
;
font-size
:
120px
;
font-family
:
cursive
;
color
:
greenyellow
;
text-shadow
:
-3px
-3px
0
#000
,
/* 왼쪽 위 그림자 */
3px
-3px
0
#000
,
/* 오른쪽 위 그림자 */
-3px
3px
0
#000
,
/* 왼쪽 아래 그림자 */
3px
3px
0
#000
;
/* 오른쪽 아래 그림자 */
}
/* .Name {} */
.Box
{
text-align
:
center
;
margin
:
0
auto
;
margin-top
:
75px
;
}
.QuizStart
{
margin
:
30px
;
margin-left
:
650px
;
margin-top
:
150px
;
margin-bottom
:
200px
;
width
:
220px
;
height
:
50px
;
font-family
:
Impact
,
Haettenschweiler
,
'Arial Narrow Bold'
,
sans-serif
;
font-size
:
20px
;
letter-spacing
:
3px
;
}
.card
{
text-align
:
center
;
margin
:
100px
;
font-size
:
10px
;
}
}
src/Quiz.js
View file @
d3d5613c
...
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
...
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
logo
from
'
./img/img_question.png
'
import
logo
from
'
./img/img_question.png
'
import
fight
from
'
./img/img_quiz.png
'
import
fight
from
'
./img/img_quiz.png
'
import
'
./Quiz.css
'
const
QnA
=
[
const
QnA
=
[
...
@@ -12,68 +13,64 @@ const QnA = [
...
@@ -12,68 +13,64 @@ const QnA = [
]
]
function
Quiz
()
{
function
Quiz
()
{
le
t
[
question
,
setQuestion
]
=
useState
({
cons
t
[
question
,
setQuestion
]
=
useState
({
...
QnA
[
0
],
...
QnA
[
0
],
i
:
0
,
i
:
0
,
page
:
0
,
page
:
0
,
})
})
let
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것들
const
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것들
// const [checked, setChecked] = useState(false)
function
handleQuestion
()
{
function
handleQuestion
()
{
setQuestion
({
...
QnA
[
question
.
i
+
1
],
i
:
question
.
i
+
1
,
page
:
question
.
page
+
1
})
setQuestion
({
...
QnA
[
question
.
i
+
1
],
i
:
question
.
i
+
1
,
page
:
question
.
page
+
1
})
// setChecked(false)
}
}
let
handleChange
=
(
ev
)
=>
{
let
handleChange
=
(
ev
)
=>
{
ev
.
preventDefault
()
//새로고침 안되도록
//
ev.preventDefault() //새로고침 안되도록
setSelected
(
ev
.
target
.
value
)
//selected값 변경
setSelected
(
ev
.
target
.
value
)
//selected값 변경
let
checked_number
=
ev
.
target
.
id
;
let
checked_number
=
ev
.
target
.
id
;
localStorage
.
setItem
(
'
답
'
+
(
question
.
N
),
Number
(
checked_number
)
+
1
)
localStorage
.
setItem
(
'
답
'
+
(
question
.
N
),
Number
(
checked_number
)
+
1
)
localStorage
.
setItem
(
'
정답
'
+
(
question
.
N
),
QnA
[
question
.
N
-
1
].
A
)
localStorage
.
setItem
(
'
정답
'
+
(
question
.
N
),
QnA
[
question
.
N
-
1
].
A
)
}
}
return
(
return
(
<>
<
div
className
=
"
container-fluid position-absolute
"
>
<
div
style
=
{{
fontSize
:
'
80px
'
,
marginBottom
:
'
100px
'
,
textAlign
:
"
center
"
,
backgroundColor
:
'
yellow
'
}}
>
미적분학
퀴즈
<
/div
>
<
div
className
=
"
text-center h2 font-weight-bold bg-warning py-2
"
>
미적분학
퀴즈
<
/div
>
<
img
src
=
{
fight
}
style
=
{{
position
:
"
absolute
"
,
left
:
"
1050px
"
,
top
:
'
200px
'
}}
alt
=
"
lion
"
/>
{
/* <div >
<
div
className
=
"
Quiz
"
>
<img src={fight} className="float-right mr-5 h-50" alt="lion" />
<
h1
><
img
src
=
{
logo
}
style
=
{{
marginLeft
:
"
450px
"
}}
width
=
'
75
'
height
=
'
75
'
alt
=
'
question
'
/>
<
span
style
=
{{
fontSize
:
"
75px
"
,
marginLeft
:
"
30px
"
}}
>
{
question
.
Q
}
<
/span></
h1
>
</div> */
}
{
/* <div style={{ marginTop: "30px", marginBottom: "30px", marginLeft:'450px', fontSize:'40px' }}>정답을 선택하세요</div> */
}
<
div
className
=
"
row justify-content-md-center
"
>
<
div
className
=
"
col text-right
"
>
<
div
>
<
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
>
<
form
>
{
question
.
Choose
.
map
((
a
,
index
)
=>
{
question
.
Choose
.
map
((
a
,
index
)
=>
<
div
key
=
{
index
}
>
<
div
key
=
{
index
}
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onClick
=
{
handleChange
}
style
=
{{
marginLeft
:
"
475px
"
,
width
:
"
25px
"
,
height
:
"
25px
"
}}
/
>
<
input
type
=
"
radio
"
name
=
'
answer
'
id
=
{
index
}
value
=
{
a
}
onClick
=
{
handleChange
}
/
>
<
label
htmlFor
=
{
a
}
style
=
{{
fontSize
:
"
40px
"
,
marginLeft
:
"
22px
"
}
}
>
{
a
}
<
/label
>
<
label
className
=
"
font-weight-bold
"
htmlFor
=
{
a
}
>
{
a
}
<
/label
>
<
/div
>
<
/div
>
)}
)}
<
input
hidden
type
=
"
submit
"
value
=
"
확인
"
/>
{
/*버튼 숨김*/
}
<
input
hidden
type
=
"
submit
"
value
=
"
확인
"
/>
{
/*버튼 숨김*/
}
<
/form
>
<
/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
)
<
span
className
=
"
h5 font-weight-bold
"
>
Your
Answer
:
<
/span
>
?
<
Link
to
=
"
/end
"
>
제출
<
/Link
>
<
span
className
=
"
h2 font-weight-bold text-danger
"
>
{
selected
}
<
/span> {/
*
선택한
값
보여줌
*
/
}
:
<
button
type
=
"
button
"
onClick
=
{
handleQuestion
}
style
=
{{
width
:
"
85px
"
,
height
:
"
40px
"
}}
>
다음
<
/button
>
<
div
className
=
"
text-center my-3
"
>
{(
question
.
page
===
QnA
.
length
-
1
)
?
<
Link
to
=
"
/end
"
>
}
<
/span
>
<
button
className
=
"
btn btn-outline-success
"
>
제출
<
/button
>
<
/p
>
<
/Link
>
:
<
button
type
=
"
button
"
className
=
"
btn btn-outline-dark
"
onClick
=
{
handleQuestion
}
>
다음
<
/button
>
}
<
/div
>
<
/div
>
<
p
className
=
"
h3 text-center text-danger
"
>
{
/* 마지막 질문일 경우 /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
<
Timer
initialTime
=
{
3600000
}
initialTime
=
{
3600000
}
direction
=
"
backward
"
direction
=
"
backward
"
...
@@ -91,9 +88,16 @@ function Quiz() {
...
@@ -91,9 +88,16 @@ function Quiz() {
)}
)}
<
/Timer> {/
*
npm
i
react
-
compound
-
timer
*
/
}
<
/Timer> {/
*
npm
i
react
-
compound
-
timer
*
/
}
<
/p
>
<
/p
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
/div
>
<
/div
>
<
/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