End.js 1.58 KB
Newer Older
baesangjune's avatar
0805    
baesangjune committed
1
import React from 'react'
baesangjune's avatar
.    
baesangjune committed
2
import tr from './img_end.jpg';
baesangjune's avatar
.    
baesangjune committed
3

Jiwon Yoon's avatar
Jiwon Yoon committed
4

baesangjune's avatar
.    
baesangjune committed
5
// import { Link } from 'react-router-dom';
Jiwon Yoon's avatar
Jiwon Yoon committed
6
7

function End() {
baesangjune's avatar
baesangjune committed
8
9
10
11
12
    let scores = []
    let score = 0
    const answers = JSON.parse(localStorage.getItem('Answers'))
    const solutions = JSON.parse(localStorage.getItem('Solutions'))
    for (let i = 0; i < answers.length ; i++) {
baesangjune's avatar
.    
baesangjune committed
13

baesangjune's avatar
baesangjune committed
14
        if (answers[i] === solutions[i]) {
baesangjune's avatar
0    
baesangjune committed
15

baesangjune's avatar
baesangjune committed
16
            scores[i] = 1
baesangjune's avatar
.    
baesangjune committed
17
18
19

        }
        else {
baesangjune's avatar
0805    
baesangjune committed
20

baesangjune's avatar
baesangjune committed
21
            scores[i] = 0
baesangjune's avatar
.    
baesangjune committed
22
        }
baesangjune's avatar
baesangjune committed
23
        score += scores[i]
baesangjune's avatar
.    
baesangjune committed
24
25
    }

Jiwon Yoon's avatar
Jiwon Yoon committed
26
    return (
baesangjune's avatar
.    
baesangjune committed
27
        <>
baesangjune's avatar
baesangjune committed
28
            <div className="card" style={{ fontSize: '30px', textAlign: "center" }} >
baesangjune's avatar
.    
baesangjune committed
29
                <div className='card-header'>
baesangjune's avatar
baesangjune committed
30
                    -채점표-
baesangjune's avatar
.    
baesangjune committed
31
                <div className='card-body'>
baesangjune's avatar
baesangjune committed
32
                        <h3 className='card-title'>이름 : {localStorage.getItem('name')}</h3>
baesangjune's avatar
.    
baesangjune committed
33

baesangjune's avatar
baesangjune committed
34
35
                        {scores.map((score, index) => {
                            
baesangjune's avatar
baesangjune committed
36
                                if (score === 1) {
baesangjune's avatar
baesangjune committed
37
                                    return <p className='card-text'>Quiz {index+1} : 'O' </p>
baesangjune's avatar
baesangjune committed
38
                                }
baesangjune's avatar
baesangjune committed
39
                                else { return <p className='card-text'>Quiz {index+1} : 'X' </p> }
baesangjune's avatar
baesangjune committed
40

baesangjune's avatar
baesangjune committed
41
                            
baesangjune's avatar
baesangjune committed
42
43

                        })}
baesangjune's avatar
baesangjune committed
44
                        <p className='card-text'>Total Score : {score}</p>
baesangjune's avatar
baesangjune committed
45
46
47
48
49
                    </div>
                    <div style={{ marginTop: '100px' }} className="Box text-center">
                        <img src={tr} alt="수고" />

                    </div>
baesangjune's avatar
.    
baesangjune committed
50
                </div>
baesangjune's avatar
.    
baesangjune committed
51
52
53
            </div>
        </>

Jiwon Yoon's avatar
Jiwon Yoon committed
54
55
56
    )
}

baesangjune's avatar
.    
baesangjune committed
57
58
export default End;