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
dd0704fc
Commit
dd0704fc
authored
Aug 17, 2020
by
baesangjune
Browse files
.
parent
16184ff8
Changes
4
Show whitespace changes
Inline
Side-by-side
src/Admin.js
View file @
dd0704fc
...
@@ -14,10 +14,7 @@ function Admin() {
...
@@ -14,10 +14,7 @@ function Admin() {
}
}
function
handleClickQuiz
(
e
)
{
function
handleClickQuiz
(
e
)
{
(
JSON
.
parse
(
localStorage
.
getItem
(
'
QnA
'
))
===
null
)
?
setresult
(
<
AdminQuiz
QuizNum
=
{
e
.
target
.
id
}
data
=
{{
Q
:
'
x
'
,
Choose
:
'
x
'
,
A
:
'
x
'
}}
/>
)
: setresult
(
<AdminQuiz QuizNum={e.target.id} data={JSON.parse
(
localStorage.getItem
(
'QnA'
))
} /
>
)
(
JSON
.
parse
(
localStorage
.
getItem
(
'
QnA
'
))
===
null
)
?
setresult
(
<
AdminQuiz
QuizNum
=
{
e
.
target
.
id
}
data
=
{[{
Q
:
'
x
'
,
Choose
:
'
x
'
,
A
:
'
x
'
}]}
/>
)
: setresult
(
<AdminQuiz QuizNum={e.target.id} data={JSON.parse
(
localStorage.getItem
(
'QnA'
))
} /
>
)
console
.
log
(
'
data
'
)
console
.
log
(
data
)
console
.
log
(
QuizNum
)
}
}
function
handleClickAddQuiz
()
{
function
handleClickAddQuiz
()
{
...
...
src/AdminQuiz.js
View file @
dd0704fc
...
@@ -7,7 +7,6 @@ let QnAadmin = {}
...
@@ -7,7 +7,6 @@ let QnAadmin = {}
let
savechoose
=
{}
let
savechoose
=
{}
function
AdminQuiz
(
props
)
{
function
AdminQuiz
(
props
)
{
const
[
question
,
setQuestion
]
=
useState
(
''
)
const
[
question
,
setQuestion
]
=
useState
(
''
)
const
[
choose
,
setChoose
]
=
useState
(
''
)
const
[
choose
,
setChoose
]
=
useState
(
''
)
const
[
answer
,
setAnswer
]
=
useState
(
''
)
const
[
answer
,
setAnswer
]
=
useState
(
''
)
...
...
src/Home.js
View file @
dd0704fc
...
@@ -4,6 +4,14 @@ import React, { useState } from 'react'
...
@@ -4,6 +4,14 @@ import React, { useState } from 'react'
import
{
Redirect
}
from
'
react-router-dom
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
function
Home
()
{
function
Home
()
{
let
info
=
[{
password
:
"
0319
"
,
AdminPassword
:
"
0001
"
,
Time
:
"
30010
"
}]
//수정.추가
if
(
JSON
.
parse
(
localStorage
.
getItem
(
"
Set
"
))
===
null
){
}
else
{
info
=
JSON
.
parse
(
localStorage
.
getItem
(
"
Set
"
))
}
//수정. 추가
const
[
name
,
setName
]
=
useState
(
''
)
const
[
name
,
setName
]
=
useState
(
''
)
const
[
password
,
SetPassword
]
=
useState
(
''
)
const
[
password
,
SetPassword
]
=
useState
(
''
)
const
[
done
,
setDone
]
=
useState
(
false
)
const
[
done
,
setDone
]
=
useState
(
false
)
...
...
src/Quiz.js
View file @
dd0704fc
...
@@ -20,10 +20,10 @@ function Quiz() {
...
@@ -20,10 +20,10 @@ function Quiz() {
//for each 사용하기
//for each 사용하기
let
Solutions
=
[]
//빈 배열
let
Solutions
=
[]
//빈 배열
console
.
log
(
localQnA
)
console
.
log
(
localQnA
)
localQnA
.
map
((
x
)
=>
{
//A만 꺼내서 q에 추가
// Answers.push(0)
localQnA
.
forEach
((
element
)
=>
{
return
Solutions
.
push
(
x
.
A
)
Solutions
.
push
(
Number
(
element
.
A
)
)
})
})
;
useEffect
(()
=>
{
useEffect
(()
=>
{
for
(
let
i
=
1
;
i
<=
Solutions
.
length
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
Solutions
.
length
;
i
++
)
{
Answers
.
push
(
0
)
Answers
.
push
(
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