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
d809327d
Commit
d809327d
authored
Aug 05, 2020
by
baesangjune
Browse files
end 수정
parent
b7609d2f
Changes
3
Show whitespace changes
Inline
Side-by-side
src/End.js
View file @
d809327d
...
...
@@ -5,44 +5,44 @@ import tr from './img_end.jpg';
// import { Link } from 'react-router-dom';
function
End
()
{
let
a
=
[]
let
Scores
=
[]
let
Score
=
0
JSON
.
parse
(
localStorage
.
getItem
(
'
Answers
'
))
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
if
(
localStorage
.
getItem
(
'
답
'
+
(
i
+
1
))
===
localStorage
.
getItem
(
'
정답
'
+
(
i
+
1
))
)
{
if
(
JSON
.
parse
(
localStorage
.
getItem
(
'
Answers
'
))[
i
]
===
JSON
.
parse
(
localStorage
.
getItem
(
'
Solutions
'
))[
i
]
)
{
a
[
i
]
=
1
localStorage
.
setItem
(
'
채점
'
+
(
i
+
1
),
'
O
'
)
Scores
[
i
]
=
1
}
else
{
a
[
i
]
=
0
localStorage
.
setItem
(
'
채점
'
+
(
i
+
1
),
'
X
'
)
Scores
[
i
]
=
0
}
Score
+=
Scores
[
i
]
}
return
(
<>
<
div
className
=
"
card
"
style
=
{{
fontSize
:
'
30px
'
,
textAlign
:
"
center
"
}}
>
<
div
className
=
"
card
"
style
=
{{
fontSize
:
'
30px
'
,
textAlign
:
"
center
"
}}
>
<
div
className
=
'
card-header
'
>
-
채점표
-
<
div
className
=
'
card-body
'
>
<
h3
className
=
'
card-title
'
>
이름
:
{
localStorage
.
getItem
(
'
name
'
)}
<
/h3
>
{
Scores
.
map
(
score
=>
{
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
if
(
score
===
1
)
{
return
<
p
className
=
'
card-text
'
>
Quiz
{(
i
+
1
)}
:
'
O
'
<
/p
>
}
else
{
return
<
p
className
=
'
card-text
'
>
Quiz
{(
i
+
1
)}
:
'
X
'
<
/p>
}
}
<
p
className
=
'
card-text
'
>
Quiz
1
:
{
localStorage
.
getItem
(
'
채점1
'
)}
<
/p
>
<
p
className
=
'
card-text
'
>
Quiz
2
:
{
localStorage
.
getItem
(
'
채점2
'
)}
<
/p
>
<
p
className
=
'
card-text
'
>
Quiz
3
:
{
localStorage
.
getItem
(
'
채점3
'
)}
<
/p
>
<
p
className
=
'
card-text
'
>
Total
Score
:
{
a
[
0
]
+
a
[
1
]
+
a
[
2
]}
<
/p
>
})}
<
p
className
=
'
card-text
'
>
Total
Score
:
{
Score
}
<
/p
>
<
/div
>
<
div
style
=
{{
marginTop
:
'
100px
'
}}
className
=
"
Box text-center
"
>
<
div
style
=
{{
marginTop
:
'
100px
'
}}
className
=
"
Box text-center
"
>
<
img
src
=
{
tr
}
alt
=
"
수고
"
/>
<
/div
>
...
...
src/Home.js
View file @
d809327d
...
...
@@ -11,7 +11,7 @@ function Home() {
setName
(
event
.
target
.
value
)
}
function
checking
(
event
)
{
function
checking
()
{
if
(
!
name
)
{
alert
(
'
이름을 입력하세요
'
)
}
...
...
@@ -24,6 +24,7 @@ function Home() {
return
(
<>
{
done
?
<
Redirect
to
=
'
/quiz
'
/>
:
''
}
<
div
style
=
{{
backgroundImage
:
'
url(
'
+
bg
+
'
)
'
,
backgroundColor
:
"
grey
"
,
backgroundSize
:
"
100%
"
,
width
:
"
100%
"
,
height
:
"
880px
"
,
backgroundRepeat
:
'
no-repeat
'
}}
>
{
/* <div className="Main"></div> */
}
...
...
@@ -39,8 +40,6 @@ function Home() {
{
/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
<
/div
>
<
div
>
계산수학
<
/div
>
<
/div
>
<
/
>
...
...
src/Quiz.js
View file @
d809327d
...
...
@@ -10,7 +10,9 @@ const QnA = [
{
Q
:
"
3 - 1 = ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
"
2
"
,
N
:
3
}
]
let
Answers
=
[]
let
Solutions
=
[
4
,
3
,
2
]
localStorage
.
setItem
(
'
Solutions
'
,
JSON
.
stringify
(
Solutions
))
function
Quiz
()
{
let
[
question
,
setQuestion
]
=
useState
({
...
...
@@ -28,11 +30,9 @@ function Quiz() {
ev
.
preventDefault
()
//새로고침 안되도록
setSelected
(
ev
.
target
.
value
)
//selected값 변경
let
checked_number
=
ev
.
target
.
id
;
localStorage
.
setItem
(
'
답
'
+
(
question
.
N
),
Number
(
checked_number
)
+
1
)
localStorage
.
setItem
(
'
정답
'
+
(
question
.
N
),
QnA
[
question
.
N
-
1
].
A
)
Answers
[
question
.
N
-
1
]
=
Number
(
ev
.
target
.
id
)
+
1
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
}
return
(
<>
...
...
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