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
5b4f23dc
Commit
5b4f23dc
authored
Aug 10, 2020
by
baesangjune
Browse files
.
parent
c3ab49b5
Changes
2
Show whitespace changes
Inline
Side-by-side
src/End.js
View file @
5b4f23dc
...
@@ -5,6 +5,7 @@ import React from 'react'
...
@@ -5,6 +5,7 @@ import React from 'react'
// import { Link } from 'react-router-dom';
// import { Link } from 'react-router-dom';
function
End
()
{
function
End
()
{
let
result
=
''
let
scores
=
[]
let
scores
=
[]
let
score
=
0
let
score
=
0
const
answers
=
JSON
.
parse
(
localStorage
.
getItem
(
'
Answers
'
))
const
answers
=
JSON
.
parse
(
localStorage
.
getItem
(
'
Answers
'
))
...
@@ -16,11 +17,17 @@ function End() {
...
@@ -16,11 +17,17 @@ function End() {
scores
[
i
]
=
1
scores
[
i
]
=
1
}
}
else
if
(
answers
[
i
]
===
0
)
{
scores
[
i
]
=
-
1
}
else
{
else
{
scores
[
i
]
=
0
scores
[
i
]
=
0
}
}
score
+=
scores
[
i
]
score
+=
scores
[
i
]
if
(
score
<
0
){
score
=
0
}
}
}
return
(
return
(
...
@@ -37,7 +44,17 @@ function End() {
...
@@ -37,7 +44,17 @@ function End() {
<
tbody
>
<
tbody
>
{
scores
.
map
((
score
,
index
)
=>
{
{
scores
.
map
((
score
,
index
)
=>
{
return
(
score
===
1
)
?
<
tr
><
td
>
Quiz
{
index
+
1
}
<
/td> <td> O </
td
><
/tr> : <tr><td>Quiz {index + 1}</
td
>
<
td
>
X
<
/td></
tr
>
if
(
score
===
-
1
)
{
result
=
<
tr
><
td
>
Quiz
{
index
+
1
}
<
/td> <td> 정답이 입력되지 않았습니다. </
td
><
/tr
>
}
else
if
(
score
===
1
)
{
result
=
<
tr
><
td
>
Quiz
{
index
+
1
}
<
/td> <td> O </
td
><
/tr
>
}
else
{
result
=
<
tr
><
td
>
Quiz
{
index
+
1
}
<
/td> <td> X</
td
><
/tr
>
}
return
result
})}
})}
<
tr
>
<
tr
>
<
td
>
총점
<
/td
>
<
td
>
총점
<
/td
>
...
...
src/Quiz.js
View file @
5b4f23dc
...
@@ -6,9 +6,9 @@ import logo from './img_question.png'
...
@@ -6,9 +6,9 @@ import logo from './img_question.png'
const
QnA
=
[
const
QnA
=
[
{
Q
:
"
6 X 4 = ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
A
:
"
4
"
,
N
:
1
},
{
Q
:
"
6 X 4 = ?
"
,
Choose
:
[
6
,
12
,
18
,
24
],
N
:
1
},
{
Q
:
"
3 + 3 = ?
"
,
Choose
:
[
2
,
4
,
6
,
8
],
A
:
"
3
"
,
N
:
2
},
{
Q
:
"
3 + 3 = ?
"
,
Choose
:
[
2
,
4
,
6
,
8
],
N
:
2
},
{
Q
:
"
3 - 1 = ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
"
2
"
,
N
:
3
}
{
Q
:
"
3 - 1 = ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
N
:
3
}
]
]
let
Answers
=
[
0
,
0
,
0
]
let
Answers
=
[
0
,
0
,
0
]
...
...
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