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
87cdc656
Commit
87cdc656
authored
Aug 17, 2020
by
Jiwon Yoon
Browse files
Merge branch 'Sangjune' into jiwon
parents
dcb4e853
fbdf8414
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Admin.js
View file @
87cdc656
...
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
...
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
import
AdminQuiz
from
'
./AdminQuiz
'
import
AdminQuiz
from
'
./AdminQuiz
'
import
AdminSetting
from
'
./AdminSetting
'
import
AdminSetting
from
'
./AdminSetting
'
let
QuizBtn
=
[]
let
QuizBtn
=
[]
function
Admin
()
{
function
Admin
()
{
...
@@ -10,13 +9,12 @@ function Admin() {
...
@@ -10,13 +9,12 @@ function Admin() {
const
[
result
,
setresult
]
=
useState
(
''
)
const
[
result
,
setresult
]
=
useState
(
''
)
const
[
QuizBtnCount
,
setQuizBtnCount
]
=
useState
(
4
)
const
[
QuizBtnCount
,
setQuizBtnCount
]
=
useState
(
4
)
function
handleClickSetting
()
{
function
handleClickSetting
()
{
setresult
(
<
AdminSetting
/>
)
setresult
(
<
AdminSetting
/>
)
}
}
function
handleClickQuiz
(
e
)
{
function
handleClickQuiz
(
e
)
{
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'
))
} /
>
)
}
}
function
handleClickAddQuiz
()
{
function
handleClickAddQuiz
()
{
...
...
src/AdminQuiz.js
View file @
87cdc656
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
// import Admin from './Admin'
let
list
=
[]
let
list
=
[]
let
QnAadmins
=
[]
let
QnAadmins
=
[]
let
QnAadmin
=
{}
let
QnAadmin
=
{}
let
savechoose
=
{}
let
savechoose
=
{}
function
AdminQuiz
(
props
)
{
function
AdminQuiz
(
props
)
{
const
[
question
,
setQuestion
]
=
useState
(
''
)
const
[
question
,
setQuestion
]
=
useState
(
''
)
...
@@ -19,19 +16,19 @@ function AdminQuiz(props) {
...
@@ -19,19 +16,19 @@ function AdminQuiz(props) {
const
[
c
,
setc
]
=
useState
([])
const
[
c
,
setc
]
=
useState
([])
const
[
a
,
seta
]
=
useState
(
''
)
const
[
a
,
seta
]
=
useState
(
''
)
useEffect
(()
=>
{
//
useEffect(()=>{
setQuestion
(
''
)
//
setQuestion('')
if
(
props
.
data
[
props
.
QuizNum
-
1
]){
//
if(props.data[props.QuizNum-1]){
setq
(
props
.
data
[
props
.
QuizNum
-
1
].
Q
)
//
setq(props.data[props.QuizNum-1].Q)
setc
(
props
.
data
[
props
.
QuizNum
-
1
].
Choose
)
//
setc(props.data[props.QuizNum-1].Choose)
seta
(
props
.
data
[
props
.
QuizNum
-
1
].
A
)
//
seta(props.data[props.QuizNum-1].A)
}
//
}
else
{
//
else {
setq
(
'
보기를 입력하세요
'
)
//
setq('보기를 입력하세요')
setc
([
'
보기를 입력하세요
'
,
'
보기를 입력하세요
'
,
'
보기를 입력하세요
'
,
'
보기를 입력하세요
'
])
//
setc(['보기를 입력하세요','보기를 입력하세요','보기를 입력하세요','보기를 입력하세요'])
seta
(
'
보기를 입력하세요
'
)
//
seta('보기를 입력하세요')
}
//
}
},[
props
.
QuizNum
])
//
},[props.QuizNum])
const
handleChangeQuestion
=
(
event
)
=>
{
const
handleChangeQuestion
=
(
event
)
=>
{
QnAadmin
[
'
Q
'
]
=
event
.
target
.
value
QnAadmin
[
'
Q
'
]
=
event
.
target
.
value
...
@@ -56,7 +53,7 @@ function AdminQuiz(props) {
...
@@ -56,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
)}
placeholder
=
{
c
[
1
]}
onChange
=
{
handleChangeChoose
}
/
>
<
input
type
=
"
text
"
class
=
"
form-control
"
id
=
{
String
(
selectOption
+
1
)}
placeholder
=
{
props
.
data
[
props
.
QuizNum
-
1
].
Choose
===
null
?
(
selectOption
+
1
)
+
'
번 보기를 입력하세요
'
:
props
.
data
[
props
.
QuizNum
-
1
].
Choose
[
selectOption
]}
onChange
=
{
handleChangeChoose
}
/
>
<
/div
>
<
/div
>
)
)
setselectOption
(
selectOption
+
1
)
setselectOption
(
selectOption
+
1
)
...
@@ -80,41 +77,42 @@ function AdminQuiz(props) {
...
@@ -80,41 +77,42 @@ function AdminQuiz(props) {
QnAadmins
.
push
(
QnAadmin
)
QnAadmins
.
push
(
QnAadmin
)
QnAadmin
=
{}
QnAadmin
=
{}
localStorage
.
setItem
(
'
QnA
'
,
JSON
.
stringify
(
QnAadmins
))
localStorage
.
setItem
(
'
QnA
'
,
JSON
.
stringify
(
QnAadmins
))
console
.
log
(
QnAadmins
)
// console.log(QnAadmins)
// setselectOption(1)
alert
(
'
입력이 완료되었습니다.
'
)
alert
(
'
입력이 완료되었습니다.
'
)
}
}
}
}
// function handleChangeQuestion(){}
return
(
return
(
<
div
className
=
""
id
=
"
Quiz1
"
>
<
div
className
=
""
id
=
"
Quiz1
"
>
<
h2
className
=
"
p-3 border text-center
bg-white font-weight-bold
"
>
{
String
(
props
.
QuizNum
)}
번
문제만들기
<
/h2
>
<
h2
className
=
"
p-3 border text-center
"
>
{
String
(
props
.
QuizNum
)}
번
문제만들기
<
/h2
>
<
div
className
=
"
p-3 borber
"
>
<
div
className
=
"
p-3 borber
"
>
<
div
className
=
"
p-3
"
>
<
div
className
=
"
p-3
"
>
<
span
className
=
"
font-weight-bold mr-2 h3
"
>
1
.
문제
입력하기
<
/span
>
<
span
className
=
"
font-weight-bold mr-2 h3
"
>
1
.
문제
입력하기
<
/span
>
<
input
type
=
"
text
"
id
=
"
inputQuiz
"
className
=
"
form-control
"
value
=
{
question
}
onChange
=
{
handleChangeQuestion
}
placeholder
=
{
q
}
/
>
<
input
type
=
"
text
"
id
=
"
inputQuiz
"
className
=
"
form-control
"
onChange
=
{
handleChangeQuestion
}
placeholder
=
{
props
.
data
[
props
.
QuizNum
-
1
].
Q
===
'
x
'
?
'
문제를 입력하세요
'
:
props
.
data
[
props
.
QuizNum
-
1
].
Q
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
p-3
"
>
<
div
className
=
"
p-3
"
>
<
span
className
=
"
font-weight-bold mr-2 h3
"
>
2
.
보기
입력하기
<
/span
>
<
span
className
=
"
font-weight-bold mr-2 h3
"
>
2
.
보기
입력하기
<
/span
>
<
div
className
=
"
p-3
"
>
<
div
className
=
"
p-3
"
>
<
div
className
=
"
input-group
"
>
<
div
className
=
"
input-group
"
>
<
div
className
=
"
input-group-prepend
"
>
<
div
className
=
"
input-group-prepend
"
>
<
div
className
=
"
input-group-text
"
>
<
div
className
=
"
input-group-text
"
>
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
input
type
=
"
radio
"
checked
=
{
false
}
name
=
"
answer
"
/>
<
/div
>
<
/div
>
<
/div
>
<
input
type
=
"
text
"
className
=
"
form-control
"
id
=
'
1
'
value
=
{
choose
}
placeholder
=
{
c
[
0
]}
onChange
=
{
handleChangeChoose
}
/
>
<
/div
>
<
/div
>
{
list
.
map
((
element
)
=>
element
)}
<
input
type
=
"
text
"
className
=
"
form-control
"
id
=
'
1
'
placeholder
=
{
props
.
data
[
props
.
QuizNum
-
1
].
Choose
===
'
x
'
?
'
1번 보기를 입력하세요
'
:
props
.
data
[
props
.
QuizNum
-
1
].
Choose
[
0
]}
onChange
=
{
handleChangeChoose
}
/
>
<
button
className
=
"
btn btn-outline-secondary btn-sm
"
onClick
=
{
addSelectOption
}
>+<
/button
>
<
/div
>
<
/div
>
{
list
.
map
((
element
)
=>
element
)}
<
button
className
=
"
btn btn-outline-secondary btn-sm
"
onClick
=
{
addSelectOption
}
>+<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
p-3
"
>
<
div
className
=
"
p-3
"
>
<
span
className
=
"
font-weight-bold mr-2 h3
"
>
정답
:
<
/span
>
<
span
className
=
"
font-weight-bold mr-2 h3
"
>
정답
:
<
/span
>
<
input
type
=
"
text
"
value
=
{
answer
}
onChange
=
{
handleChangeanswer
}
placeholder
=
{
a
}
/
>
<
input
type
=
"
text
"
value
=
{
answer
}
onChange
=
{
handleChangeanswer
}
placeholder
=
{
props
.
data
[
props
.
QuizNum
-
1
].
A
===
'
x
'
?
'
정답를 입력하세요
'
:
props
.
data
[
props
.
QuizNum
-
1
].
A
}
/
>
<
/div
>
<
/div
>
<
label
for
=
"
inputLogin
"
className
=
"
d-flex justify-content-center
"
>
<
label
for
=
"
inputLogin
"
className
=
"
d-flex justify-content-center
"
>
...
...
src/AdminSetting.js
View file @
87cdc656
...
@@ -43,25 +43,24 @@ function AdminSetting() {
...
@@ -43,25 +43,24 @@ function AdminSetting() {
alert
(
'
저장이 완료되었습니다.
'
)
alert
(
'
저장이 완료되었습니다.
'
)
console
.
log
(
Setadmin
)
console
.
log
(
Setadmin
)
// setDoneset(true)
}
}
}
}
return
(
return
(
<
div
>
<
div
className
=
"
col-8
"
>
<
h2
className
=
"
p-3 border text-center
bg-white font-weight-bold
"
>
관리자
설정
변경
창
<
/h2
>
<
h2
className
=
"
p-3 border text-center
"
>
관리자
설정
변경
창
<
/h2
>
<
div
className
=
"
p-3 border
"
>
<
div
className
=
"
p-3 border
"
>
<
h
2
>
변경할
비밀번호를
입력하세요
<
/h
2
>
<
h
4
>
변경할
비밀번호를
입력하세요
<
/h
4
>
<
input
type
=
"
text
"
onChange
=
{
handleChangePassword
}
placeholder
=
"
New Password
"
/>
<
input
type
=
"
text
"
onChange
=
{
handleChangePassword
}
placeholder
=
"
New Password
"
/>
<
/div
>
<
/div
>
<
div
className
=
"
p-3 border
"
>
<
div
className
=
"
p-3 border
"
>
<
h
2
>
변경할
관리자
비밀번호를
입력하세요
<
/h
2
>
<
h
4
>
변경할
관리자
비밀번호를
입력하세요
<
/h
4
>
<
input
type
=
"
text
"
onChange
=
{
handleChangeAdminPassword
}
placeholder
=
"
New Admin Password
"
/>
<
input
type
=
"
text
"
onChange
=
{
handleChangeAdminPassword
}
placeholder
=
"
New Admin Password
"
/>
<
/div
>
<
/div
>
<
div
className
=
"
p-3 border
"
>
<
div
className
=
"
p-3 border
"
>
<
h
2
>
타이머를
설정하세요
(
초단위
)
<
/h
2
>
<
h
4
>
타이머를
설정하세요
(
초단위
)
<
/h
4
>
<
input
type
=
"
text
"
onChange
=
{
handleChangeTime
}
placeholder
=
"
Set Time
"
/>
<
input
type
=
"
text
"
onChange
=
{
handleChangeTime
}
placeholder
=
"
Set Time
"
/>
<
/div
>
<
/div
>
...
...
src/App.js
View file @
87cdc656
import
React
from
'
react
'
;
import
React
from
'
react
'
;
// import './App.css';
import
Home
from
'
./Home
'
import
Home
from
'
./Home
'
import
Quiz
from
'
./Quiz
'
import
Quiz
from
'
./Quiz
'
import
End
from
'
./End
'
import
End
from
'
./End
'
...
...
src/Quiz.js
View file @
87cdc656
...
@@ -3,8 +3,11 @@ import { Link, Redirect } from 'react-router-dom';
...
@@ -3,8 +3,11 @@ import { Link, Redirect } from 'react-router-dom';
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
logo
from
'
./img/img_question.png
'
import
logo
from
'
./img/img_question.png
'
let
localQnA
=
JSON
.
parse
(
localStorage
.
getItem
(
'
QnA
'
))
let
localQnA
=
JSON
.
parse
(
localStorage
.
getItem
(
'
QnA
'
))
let
Answers
=
[]
let
Answers
=
[]
function
Quiz
()
{
function
Quiz
()
{
...
@@ -27,17 +30,11 @@ function Quiz() {
...
@@ -27,17 +30,11 @@ function Quiz() {
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
localStorage
.
setItem
(
"
Solutions
"
,
JSON
.
stringify
(
Solutions
))
localStorage
.
setItem
(
"
Solutions
"
,
JSON
.
stringify
(
Solutions
))
}
}
// eslint-disable-next-line
},
[])
},
[])
//그걸 로컬에 저장
//foreach 쓰기
let
finalQnA
=
localQnA
.
map
((
x
,
index
)
=>
{
//delete x.A //A 삭제
return
{
...
x
,
N
:
index
+
1
}
//N 추가
})
function
handleQuestion
()
{
function
handleQuestion
()
{
setQuestion
({
...
localQnA
[
question
.
N
]
})
setQuestion
({
...
localQnA
[
question
.
N
]
})
setSelected
(
""
)
//페이지 넘어가면 selected 초기화
setSelected
(
""
)
//페이지 넘어가면 selected 초기화
...
@@ -82,7 +79,7 @@ function Quiz() {
...
@@ -82,7 +79,7 @@ function Quiz() {
<
/div
>
<
/div
>
<
p
className
=
"
h3 text-center text-danger
"
>
<
p
className
=
"
h3 text-center text-danger
"
>
<
Timer
<
Timer
initialTime
=
{
300
1
0
}
initialTime
=
{
3000
}
direction
=
"
backward
"
direction
=
"
backward
"
checkpoints
=
{[
checkpoints
=
{[
{
{
...
...
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