End.js 1.43 KB
Newer Older
Jiwon Yoon's avatar
g    
Jiwon Yoon committed
1
import React from 'react'
Jiwon Yoon's avatar
a    
Jiwon Yoon committed
2
3
4
5
import './End.css'
import tr from './img/img_end.jpg';


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

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

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

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

Jiwon Yoon's avatar
home    
Jiwon Yoon committed
19
20
        }
        else {
baesangjune's avatar
0805    
baesangjune committed
21

baesangjune's avatar
baesangjune committed
22
            scores[i] = 0
Jiwon Yoon's avatar
home    
Jiwon Yoon committed
23
        }
baesangjune's avatar
baesangjune committed
24
        score += scores[i]
Jiwon Yoon's avatar
home    
Jiwon Yoon committed
25
    }
Jiwon Yoon's avatar
a    
Jiwon Yoon committed
26

Jiwon Yoon's avatar
Jiwon Yoon committed
27
    return (
Jiwon Yoon's avatar
home    
Jiwon Yoon committed
28
        <>
baesangjune's avatar
end    
baesangjune committed
29
30
31
32
33
34
35
36
37
38
            <div className="container">
                <h2>채점표</h2>
                <table className="table table-bordered" >
                    <thead>
                        <tr>
                            <th>응시자</th>
                            <th>{localStorage.getItem('name')}</th>
                        </tr>
                    </thead>
                    <tbody>
baesangjune's avatar
baesangjune committed
39
                        {scores.map((score, index) => {
baesangjune's avatar
baesangjune committed
40

baesangjune's avatar
end    
baesangjune committed
41
                            return (score === 1) ? <tr><td>Quiz {index + 1}</td> <td> O </td></tr> : <tr><td>Quiz {index + 1}</td> <td> X</td></tr>
baesangjune's avatar
baesangjune committed
42
                        })}
baesangjune's avatar
end    
baesangjune committed
43
44
45
46
47
48
                        <tr>
                            <td>총점</td>
                            <td>{score}</td>
                        </tr>
                    </tbody>
                </table>
Jiwon Yoon's avatar
home    
Jiwon Yoon committed
49
            </div>
baesangjune's avatar
end    
baesangjune committed
50
51
52
53


            

Jiwon Yoon's avatar
home    
Jiwon Yoon committed
54
        </>
Jiwon Yoon's avatar
Jiwon Yoon committed
55
56
57
58

    )
}

Jiwon Yoon's avatar
home    
Jiwon Yoon committed
59
export default End;