Commit d3d5613c authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

a

parent 72b2be6f
...@@ -24,15 +24,15 @@ function Home() { ...@@ -24,15 +24,15 @@ function Home() {
return ( return (
<> <>
{done ? <Redirect to='/quiz' /> : ''} {done ? <Redirect to='/quiz' /> : ''}
<div className="container-fluid"> <div className="container-fluid">
<div className="text-center"> <div className="h-100 text-center">
<div> <div className="mb-5">
이름을 입력하세요 이름을 입력하세요
</div> </div>
<input className="inputBox" onChange={handleChange} /> <input className="inputBox" onChange={handleChange} />
<div className='Box2'> <div className='Box2'>
<button className="btn btn-dark" onClick={checking}>Quiz Start !</button> <button className="btn btn-dark" onClick={checking}>Quiz Start !</button>
</div> </div>
</div> </div>
{/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */} {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
</div> </div>
......
.Main { .container-fluid {
background: gray; background: white;
background-image: url(''); width: 100%;
display: inline-block; height: 500px;
border: 3px solid black; /* background-image: url('./img/img_quiz.png');
width: 750px; background-repeat: no-repeat;
height: 180px; background-position: right;
text-align: center; background-size: 200px; */
margin-left: 410px;
margin-top: 10px;
font-size: 120px;
font-family: cursive;
color : greenyellow;
text-shadow :
-3px -3px 0 #000, /* 왼쪽 위 그림자 */
3px -3px 0 #000, /* 오른쪽 위 그림자 */
-3px 3px 0 #000, /* 왼쪽 아래 그림자 */
3px 3px 0 #000; /* 오른쪽 아래 그림자 */
}
/* .Name {} */
.Box {
text-align: center;
margin: 0 auto;
margin-top: 75px;
}
.QuizStart {
margin: 30px;
margin-left: 650px;
margin-top: 150px;
margin-bottom: 200px;
width: 220px;
height: 50px;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
font-size: 20px;
letter-spacing: 3px;
}
.card{
text-align: center;
margin: 100px;
font-size: 10px;
} }
...@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom'; ...@@ -3,6 +3,7 @@ import { Link } 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'
import fight from './img/img_quiz.png' import fight from './img/img_quiz.png'
import './Quiz.css'
const QnA = [ const QnA = [
...@@ -12,88 +13,91 @@ const QnA = [ ...@@ -12,88 +13,91 @@ const QnA = [
] ]
function Quiz() { function Quiz() {
let [question, setQuestion] = useState({ const [question, setQuestion] = useState({
...QnA[0], ...QnA[0],
i: 0, i: 0,
page: 0, page: 0,
}) })
let [selected, setSelected] = useState("") //선택한 답을 보여줄 것들 const [selected, setSelected] = useState("") //선택한 답을 보여줄 것들
// const [checked, setChecked] = useState(false)
function handleQuestion() { function handleQuestion() {
setQuestion({ ...QnA[question.i + 1], i: question.i + 1, page: question.page + 1 }) setQuestion({ ...QnA[question.i + 1], i: question.i + 1, page: question.page + 1 })
// setChecked(false)
} }
let handleChange = (ev) => { let handleChange = (ev) => {
ev.preventDefault() //새로고침 안되도록 // ev.preventDefault() //새로고침 안되도록
setSelected(ev.target.value) //selected값 변경 setSelected(ev.target.value) //selected값 변경
let checked_number = ev.target.id; let checked_number = ev.target.id;
localStorage.setItem(''+(question.N), Number(checked_number)+1) localStorage.setItem('' + (question.N), Number(checked_number) + 1)
localStorage.setItem('정답' + (question.N), QnA[question.N-1].A) localStorage.setItem('정답' + (question.N), QnA[question.N - 1].A)
} }
return ( return (
<> <div className="container-fluid position-absolute">
<div style={{ fontSize: '80px', marginBottom: '100px', textAlign: "center", backgroundColor: 'yellow' }}>미적분학 퀴즈</div> <div className="text-center h2 font-weight-bold bg-warning py-2">미적분학 퀴즈</div>
<img src={fight} style={{ position: "absolute", left: "1050px", top: '200px' }} alt="lion" /> {/* <div >
<div className="Quiz" > <img src={fight} className="float-right mr-5 h-50" alt="lion" />
<h1><img src={logo} style={{ marginLeft: "450px" }} width='75' height='75' alt='question' /> <span style={{ fontSize: "75px", marginLeft: "30px" }}>{question.Q}</span></h1> </div> */}
{/* <div style={{ marginTop: "30px", marginBottom: "30px", marginLeft:'450px', fontSize:'40px' }}>정답을 선택하세요</div> */} <div className="row justify-content-md-center" >
<div className="col text-right">
<div> <h1>
<form> <img src={logo} width='50' height='50' alt='question' />
{question.Choose.map((a, index) => </h1>
<div key={index}>
<input type="radio" name='answer' id={index} value={a} onClick={handleChange} style={{ marginLeft: "475px", width: "25px", height: "25px" }} />
<label htmlFor={a} style={{ fontSize: "40px", marginLeft: "22px" }}>{a}</label>
</div>
)}
<input hidden type="submit" value="확인" /> {/*버튼 숨김*/}
</form>
<p style={{ fontSize: "40px", marginLeft: "480px" }}>Answer :<span style={{ color: "green", fontWeight: "bold", fontSize: "90px", marginLeft: "30px" }}> {selected}</span> {/* 선택한 보여줌 */}<span style={{ marginLeft: "50px" }}> {(question.page === QnA.length - 1)
? <Link to="/end">제출</Link>
: <button type="button" onClick={handleQuestion} style={{ width: "85px", height: "40px" }} >다음</button>
}</span>
</p>
</div> </div>
<div className="col-md-auto">
<div className="h2 mt-2">
{question.Q}
</div>
<div className="mt-2">
<form>
{question.Choose.map((a, index) =>
<div key={index}>
<input type="radio" name='answer' id={index} value={a} onClick={handleChange} />
<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> {/* 선택한 보여줌 */}
<div className="text-center my-3"> {(question.page === QnA.length - 1)
? <Link to="/end">
<button className="btn btn-outline-success">제출</button>
</Link>
: <button type="button" className="btn btn-outline-dark" onClick={handleQuestion}>다음</button>
}
</div>
<p className="h3 text-center text-danger ">
<Timer
initialTime={3600000}
direction="backward"
checkpoints={[
{
time: 0,
callback: <Link to="/end">제출</Link>
// history.go(1)
}
]}
>
{() => (
<>
<Timer.Minutes /> : <Timer.Seconds></Timer.Seconds> / 60 : 00 </>
)}
</Timer> {/* npm i react-compound-timer */}
</p>
</div>
</div>
<div className="col">
</div>
{/* 마지막 질문일 경우 /end페이지로 이동, 그렇지 않을경우는 this.handleQuestion발생 */}
{/* {(question.page === QnA.length - 1)
? <Link to="/end">제출</Link>
: <button type="button" onClick={handleQuestion} >다음</button>
} */}
{/* <input onKeyPress="this.enterkey()"/> */}
<p style={{ textAlign: "center", fontSize: "30px", color: "crimson" }}>
<Timer
initialTime={3600000}
direction="backward"
checkpoints={[
{
time: 0,
callback: <Link to="/end">제출</Link>
// history.go(1)
}
]}
>
{() => (
<>
<Timer.Minutes /> : <Timer.Seconds></Timer.Seconds> / 60 : 00 </>
)}
</Timer> {/* npm i react-compound-timer */}
</p>
</div> </div>
</> </div>
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment