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
7791de51
Commit
7791de51
authored
Aug 19, 2020
by
baesangjune
Browse files
.
parent
b5f735f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Admin.js
View file @
7791de51
...
...
@@ -27,7 +27,7 @@ function Admin() {
setresult
(
<
AdminQuiz
quizNum
=
{
e
.
target
.
id
}
fn
=
{
handleClickSave
}
data
=
{
dbRef
.
current
[
e
.
target
.
id
-
1
]}
/>
)
/
/
설명
부탇드립니다
.
}
else
{
dbRef
.
current
[
e
.
target
.
id
-
1
]
=
{
'
Q
'
:
'
x
'
,
'
Choose
'
:[
0
,
0
,
0
,
0
],
'
A
'
:
'
x
'
}
dbRef
.
current
[
e
.
target
.
id
-
1
]
=
{
'
Q
'
:
'
문제를 입력하세요
'
,
'
Choose
'
:[
'
0
'
,
'
0
'
,
'
0
'
,
'
0
'
],
'
A
'
:
'
정답을 입력하세요
'
}
setresult
(
<
AdminQuiz
quizNum
=
{
e
.
target
.
id
}
fn
=
{
handleClickSave
}
data
=
{
dbRef
.
current
[
e
.
target
.
id
-
1
]}
/>
)
}
}
...
...
src/AdminQuiz.js
View file @
7791de51
...
...
@@ -7,19 +7,28 @@ let savechoose = {}
function
AdminQuiz
(
props
)
{
const
[
question
,
setQuestion
]
=
useState
(
props
.
data
.
Q
)
const
[
choose
,
setChoose
]
=
useState
(
props
.
data
.
Choose
)
// const [choose, setChoose] = useState(props.data.Choose)
const
[
choose
,
setChoose
]
=
useState
(
''
)
const
[
answer
,
setAnswer
]
=
useState
(
props
.
data
.
A
)
const
[
selectOption
,
setselectOption
]
=
useState
(
1
)
// const [c, setC] = useState(props.data.Choose)
console
.
log
(
props
.
data
.
Choose
)
console
.
log
(
choose
)
// console.log
// props.quizNum가 바뀔때마다 즉, Admin.js에서 퀴즈버튼을 바꿔누를때마다 useEffect가 발생하여 값을 업데이트 시켜줍니다.
useEffect
(()
=>
{
setQuestion
(
props
.
data
.
Q
)
setC
hoose
(
props
.
data
.
Choose
)
//
setC(props.data.Choose)
setAnswer
(
props
.
data
.
A
)
console
.
log
(
props
.
data
.
Choose
)
console
.
log
(
choose
)
// document.getElementById('3').value = c[2]
// document.getElementById('4').value = c[3]
// setcn(props.data.Choose)
// eslint-disable-next-line
},
[
props
.
quizNum
])
const
handleChangeQuestion
=
(
event
)
=>
{
QnAadmin
[
'
Q
'
]
=
event
.
target
.
value
setQuestion
(
event
.
target
.
value
)
...
...
@@ -28,7 +37,7 @@ function AdminQuiz(props) {
const
handleChangeChoose
=
(
event
)
=>
{
savechoose
[
event
.
target
.
id
]
=
event
.
target
.
value
setChoose
(
event
.
target
.
value
)
console
.
log
(
event
.
target
.
value
)
//
console.log(event.target.value)
}
const
handleChangeanswer
=
(
event
)
=>
{
...
...
@@ -44,7 +53,7 @@ function AdminQuiz(props) {
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
/div
>
<
/div
>
<
input
type
=
"
text
"
class
=
"
form-control
"
id
=
{
String
(
selectOption
+
1
)}
value
=
{
choose
[
selectOption
]}
placeholder
=
{(
selectOption
+
1
)
+
'
번 보기를 입력하세요
'
}
onChange
=
{
handleChangeChoose
}
/
>
<
input
type
=
"
text
"
class
=
"
form-control
"
id
=
{
String
(
selectOption
+
1
)}
placeholder
=
{(
selectOption
+
1
)
+
'
번 보기를 입력하세요
'
}
onChange
=
{
handleChangeChoose
}
/
>
<
/div
>
)
setselectOption
(
selectOption
+
1
)
...
...
@@ -63,8 +72,6 @@ function AdminQuiz(props) {
}
else
{
QnAadmin
[
'
Choose
'
]
=
Object
.
values
(
savechoose
)
console
.
log
(
savechoose
)
console
.
log
(
QnAadmin
.
Choose
)
QnAadmin
[
'
N
'
]
=
String
(
props
.
quizNum
)
props
.
fn
(
QnAadmin
)
QnAadmin
=
{}
...
...
@@ -90,9 +97,9 @@ function AdminQuiz(props) {
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
/div
>
<
/div
>
<
input
type
=
"
text
"
className
=
"
form-control
"
id
=
'
1
'
value
=
{
choose
[
0
]}
placeholder
=
"
보기를 입력하세요
"
onChange
=
{
handleChangeChoose
}
/
>
<
input
type
=
"
text
"
className
=
"
form-control
"
id
=
'
1
'
placeholder
=
"
1번
보기를 입력하세요
"
onChange
=
{
handleChangeChoose
}
/
>
<
/div
>
{
list
.
map
((
element
)
=>
element
)}
{
list
.
map
((
element
,
index
)
=>
element
)}
<
button
className
=
"
btn btn-outline-secondary btn-sm
"
onClick
=
{
addSelectOption
}
>+<
/button
>
<
/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