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
09887379
Commit
09887379
authored
Aug 10, 2020
by
Jiwon Yoon
Browse files
Merge branch 'Sangjune' into jiwon
parents
fa3d05da
c3ab49b5
Changes
8
Show whitespace changes
Inline
Side-by-side
src/Admin.js
0 → 100644
View file @
09887379
import
React
,
{
useState
}
from
'
react
'
;
// import { Link } from 'react-router-dom';
function
Admin
()
{
// let QnAadmin = []
// let Q = []
// let choose = []
// let N = []
const
[
number
,
setNumber
]
=
useState
(
''
)
const
[
question
,
setQuestion
]
=
useState
(
''
)
const
[
choose
,
setChoose
]
=
useState
(
''
)
const
[
answer
,
setAnswer
]
=
useState
(
''
)
const
[
done
,
setDone
]
=
useState
(
false
)
const
handleChangenumber
=
(
event
)
=>
{
setNumber
(
event
.
target
.
value
)
}
const
handleChangequestion
=
(
event
)
=>
{
setQuestion
(
event
.
target
.
value
)
}
const
handleChangechoose
=
(
event
)
=>
{
setChoose
(
event
.
target
.
value
)
}
const
handleChangeanswer
=
(
event
)
=>
{
setAnswer
(
event
.
target
.
value
)
}
function
handleClick
()
{
alert
(
'
입력이 완료되었습니다
'
)
localStorage
.
setItem
(
'
N
'
,
number
)
localStorage
.
setItem
(
'
Q
'
,
question
)
localStorage
.
setItem
(
'
Choose
'
,
choose
)
localStorage
.
setItem
(
'
Answer
'
,
answer
)
setDone
(
true
)
}
return
(
<>
{
done
?
alert
(
'
모두 입력되었습니다.
'
)
:
''
}
<
div
>
<
div
className
=
"
container
"
>
<
div
className
=
"
row d-flex justify-content-center
"
>
<
div
className
=
"
col-8
"
>
<
h1
className
=
"
p-3 border
"
>
관리자
문제제출
창
<
/h1
>
<
div
className
=
"
p-3 border
"
>
<
h2
>
문제번호를
입력하세요
<
/h2
>
<
input
type
=
"
text
"
onChange
=
{
handleChangenumber
}
placeholder
=
"
Nunber
"
/>
<
/div
>
<
div
className
=
"
p-3 border
"
>
<
h2
>
문제를
입력하세요
<
/h2
>
<
input
type
=
"
text
"
onChange
=
{
handleChangequestion
}
placeholder
=
"
Question
"
/>
<
/div
>
<
div
className
=
"
p-3 border
"
>
<
h2
>
보기를
입력하세요
(
배열형태
)
<
/h2
>
<
input
type
=
"
text
"
onChange
=
{
handleChangechoose
}
placeholder
=
"
Choose
"
/>
<
/div
>
<
div
className
=
"
p-3 border
"
>
<
h2
>
답을
입력하세요
<
/h2
>
<
input
type
=
"
text
"
onChange
=
{
handleChangeanswer
}
placeholder
=
"
Answer
"
/>
<
/div
>
<
label
for
=
"
inputLogin
"
className
=
"
d-flex justify-content-center
"
>
<
button
className
=
"
mt-4 btn btn-dark
"
onClick
=
{
handleClick
}
>
작성완료
<
/button
>
<
/label
>
<
/div
>
<
/div
>
<
/div
>
{
/* <div className="p-3 border">
<h2>패스워드를 입력하세요</h2>
<input type="text" onChange={handleChangeanswer} placeholder="Answer" />
</div> */
}
<
/div
>
<
/
>
)
}
export
default
Admin
\ No newline at end of file
src/App.js
View file @
09887379
...
...
@@ -3,8 +3,9 @@ import './App.css';
import
Home
from
'
./Home
'
import
Quiz
from
'
./Quiz
'
import
End
from
'
./End
'
import
Admin
from
'
./Admin
'
import
{
BrowserRouter
as
Router
,
Link
,
Switch
,
Route
}
from
'
react-router-dom
'
;
import
{
BrowserRouter
as
Router
,
Link
,
Switch
,
Route
,
Redirect
}
from
'
react-router-dom
'
;
function
App
()
{
return
(
...
...
@@ -17,15 +18,15 @@ function App() {
<
hr
/>
<
div
>
<
Switch
>
<
Route
exact
path
=
"
/
"
>
<
Home
/>
<
/
Route
>
<
Route
path
=
"
/quiz
"
>
<
Quiz
/>
<
/Route
>
<
Route
path
=
"
/
end
"
>
<
End
/>
<
/Route
>
<
Route
exact
path
=
"
/
"
component
=
{
Home
}
/
>
<
Route
path
=
"
/quiz
"
component
=
{
Quiz
}
/
>
<
Route
path
=
"
/end
"
component
=
{
End
}
/
>
<
Route
path
=
"
/
admin
"
component
=
{
Admin
}
/
>
<
Redirect
path
=
"
/admin
"
to
=
"
/admin
"
/
>
<
/Switch
>
<
/div
>
<
/Router
>
...
...
src/App2.js
0 → 100644
View file @
09887379
import
React
from
'
react
'
;
import
'
./App.css
'
;
function
App
()
{
return
(
<
div
>
<
header
>
<
Link
to
=
"
/
"
>
<
button
>
Calculus
<
/button
>
<
/Link
>
<
/header
>
<
hr
/>
<
/div
>
)
}
export
default
App
;
\ No newline at end of file
src/End.js
View file @
09887379
import
React
from
'
react
'
import
'
./End.css
'
import
tr
from
'
./img/img_end.jpg
'
;
// import tr from './img_end.jpg';
// import { Link } from 'react-router-dom';
...
...
src/Home.js
View file @
09887379
// import bg from './img_study.jpg'
// import korea from './img_korea.jpg'
import
React
,
{
useState
}
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
Redirect
}
from
'
react-router-dom
'
;
function
Home
()
{
const
[
name
,
setName
]
=
useState
(
''
)
const
[
password
,
SetPassword
]
=
useState
(
''
)
const
[
done
,
setDone
]
=
useState
(
false
)
const
[
admin
,
setAdmin
]
=
useState
(
false
);
const
handleChangename
=
(
event
)
=>
{
setName
(
event
.
target
.
value
)
}
...
...
@@ -16,14 +17,21 @@ function Home() {
SetPassword
(
event
.
target
.
value
)
}
function
checking
()
{
function
handleClick
()
{
if
(
!
name
)
{
alert
(
'
이름을 입력하세요
'
)
}
else
if
(
!
password
)
{
alert
(
'
비밀번호를 입력하세요
'
)
}
else
if
(
password
!==
'
0000
'
)
{
else
if
(
name
===
'
admin
'
&&
password
===
'
0001
'
)
{
console
.
log
(
'
done
'
)
return
(
setAdmin
(
true
)
)
}
else
if
(
password
!==
'
0319
'
)
{
alert
(
'
유효한 비밀번호를 입력하세요
'
)
}
else
{
...
...
@@ -35,55 +43,41 @@ function Home() {
}
return
(
<>
{
admin
?
<
Redirect
to
=
'
/admin
'
/>
:
''
}
{
done
?
<
Redirect
to
=
'
/quiz
'
/>
:
''
}
{
/* <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
<div className="Main"></div> */
}
<
div
style
=
{{
fontSize
:
'
70px
'
,
marginBottom
:
'
100px
'
,
textAlign
:
'
center
'
,
backgroundColor
:
'
#AE0E36
'
}}
>
{
/* <img alt='korea' src={korea} width='10%'/> */
}
<
h1
className
=
"
h-3 mb-5 mx-3 text-center bg-danger py-2
"
>
KOREA
UNIVERSITY
<
/h1
>
<
form
className
=
"
d-flex justify-content-center
"
>
<
div
className
=
"
table table-bordered
"
style
=
{{
width
:
"
400px
"
}}
>
<
label
for
=
"
inputId
"
className
=
"
d-flex justify-content-center
"
>
정보
입력
<
/label
>
<
div
className
=
"
form-group text-center
"
>
<
label
for
=
"
inputName
"
>
이름입력
<
input
className
=
"
ml-3 inputBox
"
onChange
=
{
handleChangename
}
placeholder
=
"
Name
"
/>
<
/label
>
<
label
for
=
"
inputPassword
"
>
비밀번호
<
input
type
=
'
password
'
className
=
"
ml-3 inputBox
"
onChange
=
{
handleChangepassword
}
placeholder
=
"
Password
"
/>
<
/label
>
<
div
className
=
"
form-group for login
"
>
<
label
for
=
"
inputLogin
"
className
=
"
d-flex justify-content-center
"
>
<
button
className
=
"
mt-4 btn btn-dark
"
onClick
=
{
handleClick
}
>
Login
<
/button
>
<
/label
>
<
/div
>
<
div
className
=
"
d-flex justify-content-center
"
>
<
table
className
=
"
table table-bordered dark-table
"
style
=
{{
width
:
"
400px
"
}}
>
<
thead
className
=
"
text-center
"
>
<
tr
style
=
{{
height
:
"
0 px
"
}}
>
정보
입력
<
/tr
>
<
/thead
>
<
tbody
className
=
"
text-center
"
>
<
tr
>
<
td
>
이름
입력
<
input
className
=
"
ml-2 inputBox
"
onChange
=
{
handleChangename
}
/></
td
>
<
/tr
>
<
tr
>
<
td
>
비밀번호
<
input
type
=
'
password
'
className
=
"
ml-2 inputBox
"
onChange
=
{
handleChangepassword
}
/></
td
>
<
/tr
>
<
tr
>
<
td
><
button
className
=
"
mt-4 btn btn-dark
"
onClick
=
{
checking
}
>
Login
<
/button></
td
>
<
/tr
>
<
/tbody
>
<
/table
>
<
/div
>
{
/* <div className="Box" style={{ border: 'solid', position: 'absolute', top: "300px", left: "68%"}} > */
}
{
/* <div className="Name" style={{boxShadow: '5px 5px 5px 5px gray', border: 'solid', fontSize: '30px', position: "absolute", top: "300px", left: "68%" }}>
이름(Name)
<input style={{ padding: '5px', border: 'solid', borderRight: 'none', borderBottom: 'none', borderTop: 'none', marginLeft: '105px', inlineSize: '160px', blockSize: '40px', fontSize: '40px' }} onChange={handleChangename} />
<
/div
>
<div className="Name" style={{ boxShadow: '5px 5px 5px 5px gray',border: 'solid', fontSize: '30px', position: "absolute", top: "360px", left: "68%" }}>
비밀번호(Password)
<input type='password' style={{ padding: '5px', border: 'solid', borderRight: 'none', borderBottom: 'none', borderTop: 'none', marginLeft: '0px', inlineSize: '160px', blockSize: '40px', fontSize: '40px' }} onChange={handleChangepassword} />
<
/div
>
<div className='Box2'>
<button style={{boxShadow: '5px 5px 5px 5px gray', marginLeft: '82%', marginTop: '10%', blockSize: '50px', inlineSize: '175px', fontSize: '35px' }} className="QuizStart" onClick={checking}>Start !</button>
</div> */
}
{
/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
{
/* </div> */
}
{
/* </div> */
}
<
/form
>
<
/
>
)
...
...
src/Quiz.js
View file @
09887379
import
React
,
{
useState
}
from
'
react
'
import
{
Link
}
from
'
react-router-dom
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
Timer
from
'
react-compound-timer
'
;
// 타이머쓰기위해 import
import
logo
from
'
./img/img_question.png
'
...
...
@@ -9,7 +9,8 @@ const QnA = [
{
Q
:
"
3 - 1 = ?
"
,
Choose
:
[
1
,
2
,
3
,
4
],
A
:
"
2
"
,
N
:
3
}
]
let
Answers
=
[]
let
Answers
=
[
0
,
0
,
0
]
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
let
Solutions
=
[
4
,
3
,
2
]
function
Quiz
()
{
...
...
@@ -21,6 +22,8 @@ function Quiz() {
})
const
[
selected
,
setSelected
]
=
useState
(
""
)
//선택한 답을 보여줄 것
const
[
timeout
,
settimeout
]
=
useState
(
false
)
function
handleQuestion
()
{
setQuestion
({
...
QnA
[
question
.
i
+
1
],
i
:
question
.
i
+
1
,
page
:
question
.
page
+
1
})
setSelected
(
""
)
//페이지 넘어가면 Your Answer 초기화
...
...
@@ -31,10 +34,9 @@ function Quiz() {
setSelected
(
ev
.
target
.
value
)
//selected값 변경
Answers
[
question
.
N
-
1
]
=
Number
(
ev
.
target
.
id
)
+
1
localStorage
.
setItem
(
'
Answers
'
,
JSON
.
stringify
(
Answers
))
console
.
log
(
Answers
)
}
return
(
<>
<
div
className
=
"
container-fluid
"
>
<
div
className
=
"
text-center h2 font-weight-bold bg-warning py-2
"
>
미적분학
퀴즈
<
/div
>
<
div
className
=
"
row justify-content-md-center
"
>
...
...
@@ -55,7 +57,6 @@ function Quiz() {
<
label
className
=
"
font-weight-bold
"
htmlFor
=
{
a
}
>
{
a
}
<
/label
>
<
/div
>
)}
<
input
hidden
type
=
"
submit
"
value
=
"
확인
"
/>
{
/*버튼 숨김*/
}
<
/form
>
<
span
className
=
"
h5 font-weight-bold
"
>
Your
Answer
:
<
/span
>
<
span
className
=
"
h2 font-weight-bold text-danger
"
>
{
selected
}
<
/span> {/
*
선택한
값
보여줌
*
/
}
...
...
@@ -68,13 +69,16 @@ function Quiz() {
<
/div
>
<
p
className
=
"
h3 text-center text-danger
"
>
<
Timer
initialTime
=
{
36000
00
}
initialTime
=
{
36000
}
direction
=
"
backward
"
checkpoints
=
{[
{
time
:
1
,
callback
:()
=>
alert
(
'
시간이 초과되었습니다.
'
),
},
{
time
:
0
,
callback
:
<
Link
to
=
"
/end
"
>
제출
<
/Link
>
// history.go(1)
callback
:
()
=>
settimeout
(
true
),
}
]}
>
...
...
@@ -90,6 +94,8 @@ function Quiz() {
<
/div
>
<
/div
>
<
/div
>
{
timeout
?
<
Redirect
to
=
'
/end
'
/>
:
''
}
<
/
>
)
...
...
src/index.js
View file @
09887379
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
'
react-dom
'
import
'
./index.css
'
;
import
App
from
'
./App
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
;
...
...
src/index2.js
0 → 100644
View file @
09887379
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
'
react-dom
'
import
'
./index.css
'
;
import
Home
from
'
./Home
'
import
Quiz
from
'
./Quiz
'
import
End
from
'
./End
'
import
{
BrowserRouter
as
Router
,
Route
}
from
'
react-router-dom
'
;
// import Quiz from './Quiz';
import
*
as
serviceWorker
from
'
./serviceWorker
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
ReactDOM
.
render
(
<
Router
>
<
Route
exact
path
=
"
/
"
component
=
{
Home
}
/
>
<
Route
path
=
'
/quiz
'
component
=
{
Quiz
}
/
>
<
Route
path
=
'
/end
'
component
=
{
End
}
/
>
<
/Router>
,
document
.
getElementById
(
'
root
'
)
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker
.
unregister
();
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