Commit d809327d authored by baesangjune's avatar baesangjune
Browse files

end 수정

parent b7609d2f
...@@ -5,44 +5,44 @@ import tr from './img_end.jpg'; ...@@ -5,44 +5,44 @@ import tr from './img_end.jpg';
// import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
function End() { function End() {
let a = [] let Scores = []
let Score = 0
JSON.parse(localStorage.getItem('Answers'))
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
if (localStorage.getItem(''+(i+1)) === localStorage.getItem('정답'+(i+1))) { if (JSON.parse(localStorage.getItem('Answers'))[i] === JSON.parse(localStorage.getItem('Solutions'))[i]) {
a[i] =1 Scores[i] = 1
localStorage.setItem('채점'+(i+1),'O')
} }
else { else {
a[i] =0 Scores[i] = 0
localStorage.setItem('채점'+(i+1),'X')
} }
Score += Scores[i]
} }
return ( return (
<> <>
<div className="card" style={{fontSize:'30px', textAlign:"center"}} > <div className="card" style={{ fontSize: '30px', textAlign: "center" }} >
<div className='card-header'> <div className='card-header'>
-채점표- -채점표-
<div className='card-body'> <div className='card-body'>
<h3 className='card-title'>이름 : {localStorage.getItem('name')}</h3> <h3 className='card-title'>이름 : {localStorage.getItem('name')}</h3>
{Scores.map(score => {
for (let i = 0; i < 3; i++) {
if (score === 1) {
return <p className='card-text'>Quiz {(i + 1)} : 'O' </p>
}
else { return <p className='card-text'>Quiz {(i + 1)} : 'X' </p> }
}
<p className='card-text'>Quiz 1 : {localStorage.getItem('채점1')}</p> })}
<p className='card-text'>Quiz 2 : {localStorage.getItem('채점2')}</p> <p className='card-text'>Total Score : {Score}</p>
<p className='card-text'>Quiz 3 : {localStorage.getItem('채점3')}</p>
<p className='card-text'>Total Score : {a[0] + a[1] + a[2]}</p>
</div> </div>
<div style={{marginTop:'100px'}}className="Box text-center"> <div style={{ marginTop: '100px' }} className="Box text-center">
<img src={tr} alt="수고" /> <img src={tr} alt="수고" />
</div> </div>
......
...@@ -11,7 +11,7 @@ function Home() { ...@@ -11,7 +11,7 @@ function Home() {
setName(event.target.value) setName(event.target.value)
} }
function checking(event) { function checking() {
if (!name) { if (!name) {
alert('이름을 입력하세요') alert('이름을 입력하세요')
} }
...@@ -24,6 +24,7 @@ function Home() { ...@@ -24,6 +24,7 @@ function Home() {
return ( return (
<> <>
{done ? <Redirect to='/quiz' /> : ''} {done ? <Redirect to='/quiz' /> : ''}
<div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}> <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
{/* <div className="Main"></div> */} {/* <div className="Main"></div> */}
...@@ -39,8 +40,6 @@ function Home() { ...@@ -39,8 +40,6 @@ function Home() {
{/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */} {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
</div> </div>
<div>계산수학</div>
</div> </div>
</> </>
......
...@@ -10,7 +10,9 @@ const QnA = [ ...@@ -10,7 +10,9 @@ const QnA = [
{ Q: "3 - 1 = ?", Choose: [1, 2, 3, 4], A: "2", N: 3 } { Q: "3 - 1 = ?", Choose: [1, 2, 3, 4], A: "2", N: 3 }
] ]
let Answers = []
let Solutions = [4, 3, 2]
localStorage.setItem('Solutions', JSON.stringify(Solutions))
function Quiz() { function Quiz() {
let [question, setQuestion] = useState({ let [question, setQuestion] = useState({
...@@ -28,11 +30,9 @@ function Quiz() { ...@@ -28,11 +30,9 @@ function Quiz() {
ev.preventDefault() //새로고침 안되도록 ev.preventDefault() //새로고침 안되도록
setSelected(ev.target.value) //selected값 변경 setSelected(ev.target.value) //selected값 변경
let checked_number = ev.target.id; Answers[question.N - 1] = Number(ev.target.id)+1
localStorage.setItem(''+(question.N), Number(checked_number)+1)
localStorage.setItem('정답' + (question.N), QnA[question.N-1].A)
localStorage.setItem('Answers', JSON.stringify(Answers))
} }
return ( return (
<> <>
......
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