Skip to content

Commit

Permalink
add grade history gpa tab with cumulative and edit
Browse files Browse the repository at this point in the history
Signed-off-by: Anvay Mathur <contact@anvaymathur.com>
  • Loading branch information
megagames-me committed Jan 1, 2025
1 parent 287a7e4 commit 6725b72
Show file tree
Hide file tree
Showing 19 changed files with 435 additions and 45 deletions.
12 changes: 9 additions & 3 deletions manifest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineManifest } from '@crxjs/vite-plugin'
import packageJson from './package.json'
import 'dotenv/config'
import { defineManifest } from '@crxjs/vite-plugin';
import 'dotenv/config';
import packageJson from './package.json';
const { version } = packageJson


Expand Down Expand Up @@ -47,6 +47,12 @@ export default defineManifest(async (env) => ({
"https://powerschool.sas.edu.sg/guardian/home.html*"
],
"js": ["src/content_script/guardianHome/index.ts"]
},
{
"matches": [
"https://powerschool.sas.edu.sg/guardian/termgrades.html*"
],
"js": ["src/content_script/termgrades/index.ts"]
}
],
"options_ui": {
Expand Down
2 changes: 1 addition & 1 deletion src/content_script/def/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* @copyright Copyright (c) 2023-2024 Anvay Mathur <contact@anvaymathur.com>
* @copyright Copyright (c) 2023-2025 Anvay Mathur <contact@anvaymathur.com>
*
* @author Anvay Mathur <contact@anvaymathur.com>
*
Expand Down
24 changes: 15 additions & 9 deletions src/content_script/guardianHome/GPA.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
export let classManager: ClassManager;
$: sem1GPA = classManager.calculateGPA(1);
$: sem2GPA = classManager.calculateGPA(2);
$: sem1GPA = classManager.calculateSemGPA(1);
$: sem2GPA = classManager.calculateSemGPA(2);
let editGrades = false;
let hideGPA = true;
Expand All @@ -17,16 +17,21 @@
Hide GPA
</label>

<p class="tw-font-bold">Do not rely on any data from SAS PES!!</p>

{#if !hideGPA}
<p class="tw-font-bold">Do not rely on any data from SAS PES!!</p>
<p class="tw-mb-2">
Go to the "Grade History" tab to view your overall cumulative GPA and GPA
for every semester in HS.
</p>
{#if typeof sem1GPA === "number" && sem1GPA !== -1}
<p>First Semester GPA: {classManager.calculateGPA(1).toFixed(2)}</p>
<p>First Semester GPA: {classManager.calculateSemGPA(1).toFixed(2)}</p>
{:else}
<p>First Semester GPA: N/A</p>
{/if}

{#if typeof sem2GPA === "number" && sem2GPA !== -1}
<p>Second Semester GPA: {classManager.calculateGPA(2).toFixed(2)}</p>
<p>Second Semester GPA: {classManager.calculateSemGPA(2).toFixed(2)}</p>
{:else}
<p>Second Semester GPA: N/A</p>
{/if}
Expand All @@ -38,7 +43,8 @@

{#if editGrades}
<p class="tw-mb-2">
Note: Semester classes count as 1 credit for GPA calculation.
Note: Semester classes count as 0.5 credit for GPA calculation like
normal year-long classes.
</p>
<table class="!tw-w-auto grid zebra tw-mb-4">
<thead>
Expand All @@ -51,8 +57,8 @@
<tbody>
{#each classManager.classes as c, i}
<tr>
<td> {c.name} </td>
<td>
<td class="tw-align-middle"> {c.name} </td>
<td class="tw-align-middle">
<select
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
bind:value={classManager.classes[i].grade.s1}
Expand Down Expand Up @@ -94,9 +100,9 @@
bind:value={classManager.classes[i].credits}
>
<option value={0}>0</option>
<option value={0.25}>0.25</option>
<option value={0.5}>0.5</option>
<option value={1}>1</option>
<option value={2}>2</option>
</select>
</td>
<td class="tw-align-middle tw-text-center">
Expand Down
2 changes: 1 addition & 1 deletion src/content_script/guardianHome/TY.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<div
class="tw-group tw-relative tw-inline-block tw-font-normal tw-pl-2"
class="tw-group tw-relative tw-inline-block tw-font-normal tw-pl-2 pes-ty"
bind:clientWidth={wd}
>
<button class="tw-ml-0">?</button>
Expand Down
5 changes: 4 additions & 1 deletion src/content_script/guardianHome/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* @copyright Copyright (c) 2023-2024 Anvay Mathur <contact@anvaymathur.com>
* @copyright Copyright (c) 2023-2025 Anvay Mathur <contact@anvaymathur.com>
*
* @author Anvay Mathur <contact@anvaymathur.com>
*
Expand Down Expand Up @@ -33,6 +33,9 @@ if (document.getElementById("pes-gpa")) {
document.getElementById("pes-gpa")?.remove();
}

if (document.querySelectorAll(".pes-ty").length > 0) {
document.querySelectorAll(".pes-ty").forEach((e) => e.remove());
}

const classManager = new ClassManager([]);

Expand Down
6 changes: 3 additions & 3 deletions src/content_script/home/Home.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
/**
*
* @copyright Copyright (c) 2023-2024 Anvay Mathur <contact@anvaymathur.com>
* @copyright Copyright (c) 2023-2025 Anvay Mathur <contact@anvaymathur.com>
*
* @author Anvay Mathur <contact@anvaymathur.com>
*
Expand All @@ -26,8 +26,8 @@
import { onMount } from "svelte";
import browser from "webextension-polyfill";
import sanitizeHtml from "sanitize-html";
import { marked } from "marked";
import sanitizeHtml from "sanitize-html";
let board: string | null = null;
Expand Down Expand Up @@ -91,7 +91,7 @@
<p class="tw-text-sm" id="boardText">{@html htmlT}</p>
{/if}
<p class="tw-mt-2">
Copyright &copy; 2024 Anvay Mathur and the SAS PES Authors
Copyright &copy; 2025 Anvay Mathur and the SAS PES Authors
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/content_script/home/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* @copyright Copyright (c) 2023-2024 Anvay Mathur <contact@anvaymathur.com>
* @copyright Copyright (c) 2023-2025 Anvay Mathur <contact@anvaymathur.com>
*
* @author Anvay Mathur <contact@anvaymathur.com>
*
Expand Down
2 changes: 1 addition & 1 deletion src/content_script/scores/FinalPercent.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
/**
*
* @copyright Copyright (c) 2023-2024 Anvay Mathur <contact@anvaymathur.com>
* @copyright Copyright (c) 2023-2025 Anvay Mathur <contact@anvaymathur.com>
*
* @author Anvay Mathur <contact@anvaymathur.com>
*
Expand Down
2 changes: 1 addition & 1 deletion src/content_script/scores/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* @copyright Copyright (c) 2023-2024 Anvay Mathur <contact@anvaymathur.com>
* @copyright Copyright (c) 2023-2025 Anvay Mathur <contact@anvaymathur.com>
*
* @author Anvay Mathur <contact@anvaymathur.com>
*
Expand Down
10 changes: 5 additions & 5 deletions src/content_script/scores/scoreTools/Export.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
<div>
<h1 class="!tw-mb-2 !tw-mt-3">Export Customizable Grades</h1>
<p>
This tool allows you to export your grades to a Google Spreadsheet,
containing all the weightings for assignments and categories.<b
This tool allows you to vivaciously export your grades to a Google
Spreadsheet, containing all the weightings for assignments and categories.<b
>All the data comes from the "Category Weighting and Advanced See All
Possibilities" tool.</b
> So, you can modify the category weightings and assignments. This tool is built
for final exam week when PowerSchool is closed so you can remember your grades.
This will exist until I feel like creating an in-extension solution to storing
your data.
for final exam week when PowerSchool is closed so you can vividly remember your
grades then. This will exist until I feel like creating an in-extension solution
to storing your data.
</p>
<button on:click={exportGrades}>Copy spreadsheet data to clipboard</button>
<p>
Expand Down
122 changes: 122 additions & 0 deletions src/content_script/termgrades/Cumulative.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<script lang="ts">
import type { Writable } from "svelte/store";
import { gradeToGPA, type ClassManager } from "../../models/classes";
import { formattedGrade, listOfGrades } from "../../models/grades";
export let classManager: ClassManager;
export let hideGPA: Writable<boolean>;
let editGrades = false;
$: GPA = classManager.calculateCumGPA();
</script>

<div id="pes-cum" class="tw-mb-6 -tw-mt-2">
<label
class="tw-flex tw-items-center tw-gap-2 tw-mb-2"
style="margin-left: 10px;"
>
<input type="checkbox" class="!tw-m-0" bind:checked={$hideGPA} />
Hide GPA
</label>

<p class="tw-font-bold">Do not rely on any data from SAS PES!!</p>

{#if !$hideGPA}
<p>
<span class="tw-font-bold">SAS PES Cumulative GPA: </span>{GPA == -1
? "N/A"
: GPA.toFixed(2)}
</p>

<label
class="tw-flex tw-items-center tw-gap-2 tw-mb-2"
style="margin-left: 10px;"
>
<input type="checkbox" class="!tw-m-0" bind:checked={editGrades} />
Edit grades for cumulative GPA calculation
</label>

{#if editGrades}
<p class="tw-mb-2">
Note: Semester classes count as 0.5 credit for GPA calculation like
normal year-long classes.
</p>
<table
class="!tw-w-auto grid zebra tw-mb-4"
style="margin-left: 20px !important;"
>
<thead>
<th> Class </th>
<th> Term </th>
<th> S1 Grade </th>
<th> S2 Grade </th>
<th> Credits </th>
<th> AP/AT </th>
</thead>
<tbody>
{#each classManager.classes as c, i}
<tr>
<td class="tw-align-middle"> {c.name} </td>
<td class="tw-align-middle"> {c.term}</td>
<td>
<select
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
bind:value={classManager.classes[i].grade.s1}
>
{#each listOfGrades as grade}
{#if grade !== "INC_NO_CREDIT"}
<option value={grade}
>{formattedGrade(grade)}
{grade !== "INC_NO_CLASS_CREDIT"
? `(${gradeToGPA[grade]})`
: ""}
</option>
{/if}
{/each}
<option value={null}>No grade</option>
</select>
</td>
<td>
<select
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
bind:value={classManager.classes[i].grade.s2}
>
{#each listOfGrades as grade}
{#if grade !== "INC_NO_CREDIT"}
<option value={grade}
>{formattedGrade(grade)}
{grade !== "INC_NO_CLASS_CREDIT"
? `(${gradeToGPA[grade]})`
: ""}
</option>
{/if}
{/each}
<option value={null}>No grade</option>
</select>
</td>
<td>
<select
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
bind:value={classManager.classes[i].credits}
>
<option value={0}>0</option>
<option value={0.25}>0.25</option>
<option value={0.5}>0.5</option>
<option value={1}>1</option>
</select>
</td>
<td class="tw-align-middle tw-text-center">
<input
type="checkbox"
class="!tw-m-0"
bind:checked={classManager.classes[i].isBoosted}
/>
</td>
</tr>
{/each}
</tbody>
</table>
{/if}
{/if}
</div>
26 changes: 26 additions & 0 deletions src/content_script/termgrades/TermGPAs.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script lang="ts">
import type { Writable } from "svelte/store";
import type { ClassManager } from "../../models/classes";
export let term: string;
export let classManager: ClassManager;
export let hideGPA: Writable<boolean>;
let sem1GPA = classManager.calculateSemGPA(1);
let sem2GPA = classManager.calculateSemGPA(2);
</script>

<div id="pes-term" class="tw-mb-2">
{#if !$hideGPA}
<p>
<span class="tw-font-bold"
>SAS PES {term} First Semester GPA:
</span>{sem1GPA == -1 ? "N/A" : sem1GPA.toFixed(2)}
</p>
<p>
<span class="tw-font-bold"
>SAS PES {term} Second Semester GPA:
</span>{sem2GPA == -1 ? "N/A" : sem2GPA.toFixed(2)}
</p>
{/if}
</div>
Loading

0 comments on commit 6725b72

Please sign in to comment.