End.js 1.57 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
    let Scores = []
    let Score = 0
    JSON.parse(localStorage.getItem('Answers'))
baesangjune's avatar
.    
baesangjune committed
11
12
    for (let i = 0; i < 3; i++) {

baesangjune's avatar
baesangjune committed
13
        if (JSON.parse(localStorage.getItem('Answers'))[i] === JSON.parse(localStorage.getItem('Solutions'))[i]) {
baesangjune's avatar
0    
baesangjune committed
14

baesangjune's avatar
baesangjune committed
15
            Scores[i] = 1
baesangjune's avatar
.    
baesangjune committed
16
17
18

        }
        else {
baesangjune's avatar
0805    
baesangjune committed
19

baesangjune's avatar
baesangjune committed
20
            Scores[i] = 0
baesangjune's avatar
.    
baesangjune committed
21
        }
baesangjune's avatar
baesangjune committed
22
        Score += Scores[i]
baesangjune's avatar
.    
baesangjune committed
23
24
    }

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

baesangjune's avatar
baesangjune committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
                        {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'>Total Score : {Score}</p>
                    </div>
                    <div style={{ marginTop: '100px' }} className="Box text-center">
                        <img src={tr} alt="수고" />

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

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

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