End.js 1.73 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
37
38
39
40
                        return (score===1) ? <p className='card-text'>Quiz {index+1} : 'O' </p>  : <p className='card-text'>Quiz {index+1} : 'X' </p>
                                // if (score === 1) {
                                //     return <p className='card-text'>Quiz {index+1} : 'O' </p>
                                // }
                                // else { return <p className='card-text'>Quiz {index+1} : 'X' </p> }
baesangjune's avatar
baesangjune committed
41

baesangjune's avatar
baesangjune committed
42
                            
baesangjune's avatar
baesangjune committed
43
44

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

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

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

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