|
| 1 | +<script lang="ts"> |
| 2 | + import { gradeToPercent, listOfGrades } from "../..//models/grades"; |
| 3 | + import type { ClassManager } from "../../models/classes"; |
| 4 | +
|
| 5 | + export let classManager: ClassManager; |
| 6 | +
|
| 7 | + $: sem1GPA = classManager.calculateGPA(1); |
| 8 | + $: sem2GPA = classManager.calculateGPA(2); |
| 9 | +
|
| 10 | + let editGrades = false; |
| 11 | + let hideGPA = true; |
| 12 | +</script> |
| 13 | + |
| 14 | +<label class="tw-flex tw-items-center tw-gap-2 tw-mb-2"> |
| 15 | + <input type="checkbox" class="!tw-m-0" bind:checked={hideGPA} /> |
| 16 | + Hide GPA |
| 17 | +</label> |
| 18 | + |
| 19 | +{#if !hideGPA} |
| 20 | + <p class="tw-font-bold">Do not rely on any data from SAS PES!!</p> |
| 21 | + {#if sem1GPA && sem1GPA !== -1} |
| 22 | + <p>First Semester GPA: {classManager.calculateGPA(1).toFixed(2)}</p> |
| 23 | + {:else} |
| 24 | + <p>First Semester GPA: N/A</p> |
| 25 | + {/if} |
| 26 | + |
| 27 | + {#if sem2GPA && sem2GPA !== -1} |
| 28 | + <p>Second Semester GPA: {classManager.calculateGPA(2).toFixed(2)}</p> |
| 29 | + {:else} |
| 30 | + <p>Second Semester GPA: N/A</p> |
| 31 | + {/if} |
| 32 | + |
| 33 | + <label class="tw-flex tw-items-center tw-gap-2 tw-mb-2"> |
| 34 | + <input type="checkbox" class="!tw-m-0" bind:checked={editGrades} /> |
| 35 | + Edit grades for GPA calculation |
| 36 | + </label> |
| 37 | + |
| 38 | + {#if editGrades} |
| 39 | + <p class="tw-mb-2"> |
| 40 | + Note: Semester classes count as 1 credit for GPA calculation. |
| 41 | + </p> |
| 42 | + <table class="!tw-w-auto grid zebra tw-mb-4"> |
| 43 | + <thead> |
| 44 | + <th> Class </th> |
| 45 | + <th> S1 Grade </th> |
| 46 | + <th> S2 Grade </th> |
| 47 | + <th> Credits </th> |
| 48 | + <th> AP/AT </th> |
| 49 | + </thead> |
| 50 | + <tbody> |
| 51 | + {#each classManager.classes as c, i} |
| 52 | + <tr> |
| 53 | + <td> {c.name} </td> |
| 54 | + <td> |
| 55 | + <select |
| 56 | + class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1" |
| 57 | + bind:value={classManager.classes[i].grade.s1} |
| 58 | + > |
| 59 | + {#each listOfGrades as grade} |
| 60 | + <option value={grade} |
| 61 | + >{grade} |
| 62 | + {grade !== "INC" ? `(${gradeToPercent[grade]}%)` : ""} |
| 63 | + </option> |
| 64 | + {/each} |
| 65 | + </select> |
| 66 | + </td> |
| 67 | + <td> |
| 68 | + <select |
| 69 | + class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1" |
| 70 | + bind:value={classManager.classes[i].grade.s2} |
| 71 | + > |
| 72 | + {#each listOfGrades as grade} |
| 73 | + <option value={grade} |
| 74 | + >{grade} |
| 75 | + {grade !== "INC" ? `(${gradeToPercent[grade]}%)` : ""} |
| 76 | + </option> |
| 77 | + {/each} |
| 78 | + <option value={null}>No grade</option> |
| 79 | + </select> |
| 80 | + </td> |
| 81 | + <td> |
| 82 | + <select |
| 83 | + class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1" |
| 84 | + bind:value={classManager.classes[i].credits} |
| 85 | + > |
| 86 | + <option value={0}>0</option> |
| 87 | + <option value={0.5}>0.5</option> |
| 88 | + <option value={1}>1</option> |
| 89 | + <option value={2}>2</option> |
| 90 | + </select> |
| 91 | + </td> |
| 92 | + <td class="tw-align-middle tw-text-center"> |
| 93 | + <input |
| 94 | + type="checkbox" |
| 95 | + class="!tw-m-0" |
| 96 | + bind:checked={classManager.classes[i].isBoosted} |
| 97 | + /> |
| 98 | + </td> |
| 99 | + </tr> |
| 100 | + {/each} |
| 101 | + </tbody> |
| 102 | + </table> |
| 103 | + {/if} |
| 104 | +{/if} |
0 commit comments