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
c6d01df3
Commit
c6d01df3
authored
Aug 12, 2020
by
Jiwon Yoon
Browse files
a
parent
e67f66d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/AdminQuiz.js
View file @
c6d01df3
...
...
@@ -2,46 +2,71 @@ import React, { useState } from 'react';
let
list
=
[]
let
QnAadmins
=
[]
let
QnAadmin
=
{}
function
AdminQuiz
()
{
const
[
question
,
setQuestion
]
=
useState
(
''
)
const
[
choose
,
setChoose
]
=
useState
(
''
)
const
[
answer
,
setAnswer
]
=
useState
(
''
)
const
[
selectOption
,
setselectOption
]
=
useState
(
1
)
const
handleChangeQuestion
=
(
event
)
=>
{
QnAadmin
[
'
Q
'
]
=
event
.
target
.
value
setQuestion
(
event
.
target
.
value
)
}
const
handleChangeChoose
=
(
event
)
=>
{
QnAadmin
[
'
Choose
'
]
=
event
.
target
.
value
setChoose
(
event
.
target
.
value
)
}
const
handleChangeanswer
=
(
event
)
=>
{
QnAadmin
[
'
A
'
]
=
event
.
target
.
value
setAnswer
(
event
.
target
.
value
)
}
function
addSelectOption
()
{
list
.
push
(
<
div
className
=
"
input-group
"
>
<
div
className
=
"
input-group-prepend
"
>
<
div
className
=
"
input-group-text
"
>
<
input
type
=
"
radio
"
name
=
"
answer
"
/>
<
input
type
=
"
radio
"
id
=
{
selectOption
+
1
}
name
=
"
answer
"
/>
<
/div
>
<
/div
>
<
input
type
=
"
text
"
class
Name
=
"
form-control
"
placeholder
=
"
보기를 입력하세요
"
onChange
=
{
handleChangeChoose
}
/
>
<
input
type
=
"
text
"
class
=
"
form-control
"
placeholder
=
"
보기를 입력하세요
"
onChange
=
{
handleChangeChoose
}
/
>
<
/div
>
)
setselectOption
(
selectOption
+
1
)
}
function
handleClick
()
{
alert
(
'
입력이 완료되었습니다
'
)
// localStorage.setItem('Q', question)
// localStorage.setItem('Choose', choose)
// localStorage.setItem('Answer', answer)
// localStorage.setItem('P', password)
// localStorage.setItem('AP', adminpassword)
// localStorage.setItem('T', time * 1000)
if
(
!
question
)
{
alert
(
'
문제가 입력되지 않았습니다.
'
)
}
else
if
(
!
choose
)
{
alert
(
'
보기가 입력되지 않았습니다.
'
)
}
else
if
(
!
answer
)
{
alert
(
'
정답이 입력되지 않았습니다.
'
)
}
else
{
console
.
log
(
QnAadmin
)
QnAadmins
.
push
(
QnAadmin
)
localStorage
.
setItem
(
'
QnA
'
,
JSON
.
stringify
(
QnAadmins
))
console
.
log
(
QnAadmins
)
alert
(
'
입력이 완료되었습니다.
'
)
}
}
...
...
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