Skip to content

Commit 6116904

Browse files
authored
Merge pull request #324 from sas-fossdev/v2feature/gpa
Add GPA calculation and customization
2 parents eb7abe4 + 78bbeaf commit 6116904

File tree

17 files changed

+343
-16
lines changed

17 files changed

+343
-16
lines changed

.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing
2+
The main branch for version 2 is v2. Do not force push into it; please create pull requests.
3+
4+
This is a work in progress, so documentation files such as this and README.md are not fully fleshed out. Any help in this would be appreciated.
5+
6+
If you want to make a new feature, please create an issue for it and link it in your pull request.
7+
8+
### License Header
9+
10+
If you modify an existing file, add your copyright notice to the file. Something like this:
11+
```
12+
@copyright Copyright (c) <year> <your name> <<your email address>>
13+
```
14+
For a new file, add this license header to the top of the file:
15+
```
16+
/**
17+
*
18+
* @copyright Copyright (c) <year> <your name> <<your email address>>
19+
*
20+
* @author <your name> <<your email address>>
21+
*
22+
* @license GNU AGPL version 3 only
23+
*
24+
* SAS Powerschool Enhancement Suite - A browser extension to improve the experience of SAS Powerschool.
25+
*
26+
* This program is free software: you can redistribute it and/or modify
27+
* it under the terms of the GNU Affero General Public License as
28+
* published by the Free Software Foundation, version 3.
29+
*
30+
* This program is distributed in the hope that it will be useful,
31+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
32+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+
* GNU Affero General Public License for more details.
34+
*
35+
* You should have received a copy of the GNU Affero General Public License
36+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
37+
*
38+
*/
39+
```

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
<img src="https://cdn.ydgkim.com/gschool/saspes/mainimage.png" alt="SAS Powerschool Enhancement Suite" height="200">
33
</p>
44

5+
# SAS PES v2
6+
57
SAS PES is an extension using the WebExtension standard for use by **Singapore American School students only**. The extension provides various enhancements when using Powerschool at SAS.
68

79
Regardless of what the extension calculates, teachers are able to override the final grade. **DO NOT RELY ON THE DATA FROM THIS EXTENSION!!**
810

11+
Version 2 aims to fix all the current problems with the extension, modernize the code, and add new features students would like.
12+
13+
## Contributing
14+
15+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md).

manifest.config.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { defineManifest } from '@crxjs/vite-plugin'
22
import packageJson from './package.json'
3+
import 'dotenv/config'
34
const { version } = packageJson
45

56

67

8+
export const realVersion = `${new Date().getUTCFullYear()}.${new Date().getUTCMonth() + 1}${String(new Date().getUTCDate()).padStart(2, "0")}.${new Date().getUTCMinutes()}${String(new Date().getUTCHours()).padStart(2, "0")}.${new Date().getUTCSeconds()}${String(new Date().getUTCMilliseconds()).padStart(3, "0")}`;
79
export default defineManifest(async (env) => ({
810
manifest_version: 3,
911
// In UTC time: YYYY.MMDD.HHMM.SSmmm
10-
version: `${new Date().getUTCFullYear()}.${new Date().getUTCMonth() + 1}${String(new Date().getUTCDate()).padStart(2, "0")}.${new Date().getUTCMinutes()}${String(new Date().getUTCHours()).padStart(2, "0")}.${new Date().getUTCSeconds()}${String(new Date().getUTCMilliseconds()).padStart(3, "0")}`,
12+
version: realVersion,
1113
// semver is OK in "version_name"
12-
version_name: version,
14+
version_name: version + (process.argv[4] === "production" ? "" : ` Dev Build ${realVersion}`),
1315
"name": "SAS Powerschool Enhancement Suite",
1416
"description": "Provides various enhancements for SAS Powerschool",
1517
"action": {
@@ -27,6 +29,12 @@ export default defineManifest(async (env) => ({
2729
{
2830
"matches": ["https://powerschool.sas.edu.sg/public/*"],
2931
"js": ["src/content_script/home/index.ts"]
32+
},
33+
{
34+
"matches": [
35+
"https://powerschool.sas.edu.sg/guardian/home.html*"
36+
],
37+
"js": ["src/content_script/guardianHome/index.ts"]
3038
}
3139
],
3240
"permissions": ["storage"],

package-lock.json

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"type": "module",
77
"scripts": {
88
"dev": "vite",
9-
"build": "vite build",
9+
"build:dev": "vite build ./ development; echo 'Development build done.';",
10+
"build:prod": "vite build ./ production; echo 'Production build done.';",
1011
"preview": "vite preview",
1112
"check": "svelte-check --tsconfig ./tsconfig.json",
1213
"format": "prettier --write ."
@@ -20,6 +21,7 @@
2021
"@types/webextension-polyfill": "^0.10.7",
2122
"@typescript-eslint/eslint-plugin": "^6.16.0",
2223
"autoprefixer": "^10.4.16",
24+
"dotenv": "^16.3.1",
2325
"postcss": "^8.4.32",
2426
"prettier": "^3.1.1",
2527
"prettier-plugin-svelte": "^3.1.2",

src/content_script/def/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* @copyright Copyright (c) 2023 Anvay Mathur <[email protected]>
3+
* @copyright Copyright (c) 2023-2024 Anvay Mathur <[email protected]>
44
*
55
* @author Anvay Mathur <[email protected]>
66
*
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
console.log("RERENDERING");
8+
9+
$: sem1GPA = classManager.calculateGPA(1);
10+
$: sem2GPA = classManager.calculateGPA(2);
11+
12+
let editGrades = false;
13+
</script>
14+
15+
{#if sem1GPA && sem1GPA !== -1}
16+
<p>First Semester GPA: {classManager.calculateGPA(1).toFixed(2)}</p>
17+
{:else}
18+
<p>First Semester GPA: N/A</p>
19+
{/if}
20+
21+
{#if sem2GPA && sem2GPA !== -1}
22+
<p>Second Semester GPA: {classManager.calculateGPA(2).toFixed(2)}</p>
23+
{:else}
24+
<p>Second Semester GPA: N/A</p>
25+
{/if}
26+
27+
<label class="tw-flex tw-items-center tw-gap-2">
28+
<input type="checkbox" class="!tw-m-0" bind:checked={editGrades} />
29+
Edit grades for GPA calculation
30+
</label>
31+
32+
{#if editGrades}
33+
<table class="!tw-w-auto grid zebra tw-mb-4">
34+
<thead>
35+
<th> Class </th>
36+
<th> S1 Grade </th>
37+
<th> S2 Grade </th>
38+
<th> Credits </th>
39+
<th> AP/AT </th>
40+
</thead>
41+
<tbody>
42+
{#each classManager.classes as c, i}
43+
<tr>
44+
<td> {c.name} </td>
45+
<td>
46+
<select
47+
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
48+
bind:value={classManager.classes[i].grade.s1}
49+
>
50+
{#each listOfGrades as grade}
51+
<option value={grade}
52+
>{grade}
53+
{grade !== "INC" ? `(${gradeToPercent[grade]}%)` : ""}
54+
</option>
55+
{/each}
56+
</select>
57+
</td>
58+
<td>
59+
<select
60+
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
61+
bind:value={classManager.classes[i].grade.s2}
62+
>
63+
{#each listOfGrades as grade}
64+
<option value={grade}
65+
>{grade}
66+
{grade !== "INC" ? `(${gradeToPercent[grade]}%)` : ""}
67+
</option>
68+
{/each}
69+
<option value={null}>No grade</option>
70+
</select>
71+
</td>
72+
<td>
73+
<select
74+
class="tw-rounded-md tw-h-full tw-border-[#CCCCCC] tw-border-solid tw-border tw-p-1"
75+
bind:value={classManager.classes[i].credits}
76+
>
77+
<option value={0}>0</option>
78+
<option value={0.5}>0.5</option>
79+
<option value={1}>1</option>
80+
<option value={2}>2</option>
81+
</select>
82+
</td>
83+
<td class="tw-align-middle tw-text-center">
84+
<input
85+
type="checkbox"
86+
class="!tw-m-0"
87+
bind:checked={classManager.classes[i].isBoosted}
88+
/>
89+
</td>
90+
</tr>
91+
{/each}
92+
</tbody>
93+
</table>
94+
{/if}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
*
3+
* @copyright Copyright (c) 2023-2024 Anvay Mathur <[email protected]>
4+
*
5+
* @author Anvay Mathur <[email protected]>
6+
*
7+
* @license GNU AGPL-3.0-only
8+
*
9+
* SAS Powerschool Enhancement Suite - A browser extension to improve the experience of SAS Powerschool.
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Affero General Public License as
13+
* published by the Free Software Foundation, version 3.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
25+
import { Class, ClassManager } from "../../models/classes";
26+
import GPA from "./GPA.svelte";
27+
import { listOfGrades, type Grade } from "../../models/grades";
28+
29+
const classManager = new ClassManager([]);
30+
31+
const rows = document.querySelectorAll(".linkDescList.grid > tbody > tr.center:not(.th2)");
32+
33+
for (const row of rows) {
34+
const nameEle = row.querySelector("td:nth-child(2)");
35+
const s1GradeEle = row.querySelector("td:nth-child(3)");
36+
const s2GradeEle = row.querySelector("td:nth-child(4)");
37+
38+
if (!nameEle || !s1GradeEle || !s2GradeEle) continue;
39+
40+
const name = nameEle.firstChild?.textContent?.trim();
41+
if (!name) continue;
42+
43+
let s1Grade: string | null = s1GradeEle.textContent?.trim()!;
44+
if (!s1Grade) continue;
45+
if (!listOfGrades.includes(s1Grade as Grade)) s1Grade = null;
46+
47+
let s2Grade: string | null = s2GradeEle.textContent?.trim()!;
48+
if (!s2Grade) continue;
49+
if (!listOfGrades.includes(s2Grade as Grade)) s2Grade = null;
50+
51+
if (!s1Grade && !s2Grade) continue;
52+
classManager.addClass(new Class(name, { s1: s1Grade as Grade | null, s2: s2Grade as Grade | null }))
53+
}
54+
55+
56+
console.log(classManager);
57+
const target = document.createElement("div");
58+
document
59+
.querySelector("#content-main > .box-round")
60+
?.insertBefore(target, document.querySelector("#quickLookup"));
61+
62+
new GPA({ target: target as Element, props: { classManager: classManager } });

src/content_script/home/Home.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
/**
33
*
4-
* @copyright Copyright (c) 2023 Anvay Mathur <[email protected]>
4+
* @copyright Copyright (c) 2023-2024 Anvay Mathur <[email protected]>
55
*
66
* @author Anvay Mathur <[email protected]>
77
*

0 commit comments

Comments
 (0)