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() {
...
@@ -27,7 +27,7 @@ function Admin() {
setresult
(
<
AdminQuiz
quizNum
=
{
e
.
target
.
id
}
fn
=
{
handleClickSave
}
data
=
{
dbRef
.
current
[
e
.
target
.
id
-
1
]}
/>
)
/
/
설명
부탇드립니다
.
setresult
(
<
AdminQuiz
quizNum
=
{
e
.
target
.
id
}
fn
=
{
handleClickSave
}
data
=
{
dbRef
.
current
[
e
.
target
.
id
-
1
]}
/>
)
/
/
설명
부탇드립니다
.
}
}
else
{
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
]}
/>
)
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 = {}
...
@@ -7,19 +7,28 @@ let savechoose = {}
function
AdminQuiz
(
props
)
{
function
AdminQuiz
(
props
)
{
const
[
question
,
setQuestion
]
=
useState
(
props
.
data
.
Q
)
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
[
answer
,
setAnswer
]
=
useState
(
props
.
data
.
A
)
const
[
selectOption
,
setselectOption
]
=
useState
(
1
)
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가 발생하여 값을 업데이트 시켜줍니다.
// props.quizNum가 바뀔때마다 즉, Admin.js에서 퀴즈버튼을 바꿔누를때마다 useEffect가 발생하여 값을 업데이트 시켜줍니다.
useEffect
(()
=>
{
useEffect
(()
=>
{
setQuestion
(
props
.
data
.
Q
)
setQuestion
(
props
.
data
.
Q
)
setC
hoose
(
props
.
data
.
Choose
)
//
setC(props.data.Choose)
setAnswer
(
props
.
data
.
A
)
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
// eslint-disable-next-line
},
[
props
.
quizNum
])
},
[
props
.
quizNum
])
const
handleChangeQuestion
=
(
event
)
=>
{
const
handleChangeQuestion
=
(
event
)
=>
{
QnAadmin
[
'
Q
'
]
=
event
.
target
.
value
QnAadmin
[
'
Q
'
]
=
event
.
target
.
value
setQuestion
(
event
.
target
.
value
)
setQuestion
(
event
.
target
.
value
)
...
@@ -28,7 +37,7 @@ function AdminQuiz(props) {
...
@@ -28,7 +37,7 @@ function AdminQuiz(props) {
const
handleChangeChoose
=
(
event
)
=>
{
const
handleChangeChoose
=
(
event
)
=>
{
savechoose
[
event
.
target
.
id
]
=
event
.
target
.
value
savechoose
[
event
.
target
.
id
]
=
event
.
target
.
value
setChoose
(
event
.
target
.
value
)
setChoose
(
event
.
target
.
value
)
console
.
log
(
event
.
target
.
value
)
//
console.log(event.target.value)
}
}
const
handleChangeanswer
=
(
event
)
=>
{
const
handleChangeanswer
=
(
event
)
=>
{
...
@@ -44,7 +53,7 @@ function AdminQuiz(props) {
...
@@ -44,7 +53,7 @@ function AdminQuiz(props) {
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
/div
>
<
/div
>
<
/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
>
<
/div
>
)
)
setselectOption
(
selectOption
+
1
)
setselectOption
(
selectOption
+
1
)
...
@@ -63,8 +72,6 @@ function AdminQuiz(props) {
...
@@ -63,8 +72,6 @@ function AdminQuiz(props) {
}
}
else
{
else
{
QnAadmin
[
'
Choose
'
]
=
Object
.
values
(
savechoose
)
QnAadmin
[
'
Choose
'
]
=
Object
.
values
(
savechoose
)
console
.
log
(
savechoose
)
console
.
log
(
QnAadmin
.
Choose
)
QnAadmin
[
'
N
'
]
=
String
(
props
.
quizNum
)
QnAadmin
[
'
N
'
]
=
String
(
props
.
quizNum
)
props
.
fn
(
QnAadmin
)
props
.
fn
(
QnAadmin
)
QnAadmin
=
{}
QnAadmin
=
{}
...
@@ -90,9 +97,9 @@ function AdminQuiz(props) {
...
@@ -90,9 +97,9 @@ function AdminQuiz(props) {
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
/div
>
<
/div
>
<
/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
>
<
/div
>
{
list
.
map
((
element
)
=>
element
)}
{
list
.
map
((
element
,
index
)
=>
element
)}
<
button
className
=
"
btn btn-outline-secondary btn-sm
"
onClick
=
{
addSelectOption
}
>+<
/button
>
<
button
className
=
"
btn btn-outline-secondary btn-sm
"
onClick
=
{
addSelectOption
}
>+<
/button
>
<
/div
>
<
/div
>
<
/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