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() {
}
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'
))
} /
>
)
console
.
log
(
'
data
'
)
console
.
log
(
data
)
console
.
log
(
QuizNum
)
(
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'
))
} /
>
)
}
function
handleClickAddQuiz
()
{
...
...
src/AdminQuiz.js
View file @
dd0704fc
...
...
@@ -7,7 +7,6 @@ let QnAadmin = {}
let
savechoose
=
{}
function
AdminQuiz
(
props
)
{
const
[
question
,
setQuestion
]
=
useState
(
''
)
const
[
choose
,
setChoose
]
=
useState
(
''
)
const
[
answer
,
setAnswer
]
=
useState
(
''
)
...
...
src/Home.js
View file @
dd0704fc
...
...
@@ -4,6 +4,14 @@ import React, { useState } from 'react'
import
{
Redirect
}
from
'
react-router-dom
'
;
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
[
password
,
SetPassword
]
=
useState
(
''
)
const
[
done
,
setDone
]
=
useState
(
false
)
...
...
src/Quiz.js
View file @
dd0704fc
...
...
@@ -20,10 +20,10 @@ function Quiz() {
//for each 사용하기
let
Solutions
=
[]
//빈 배열
console
.
log
(
localQnA
)
localQnA
.
map
((
x
)
=>
{
//A만 꺼내서 q에 추가
// Answers.push(0)
return
Solutions
.
push
(
x
.
A
)
})
localQnA
.
forEach
((
element
)
=>
{
Solutions
.
push
(
Number
(
element
.
A
)
)
})
;
useEffect
(()
=>
{
for
(
let
i
=
1
;
i
<=
Solutions
.
length
;
i
++
)
{
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