Skip to content

Commit

Permalink
Modified course class to automatically calculate credit hours
Browse files Browse the repository at this point in the history
Signed-off-by: Suhas Hariharan <hariharan774531@sas.edu.sg>
  • Loading branch information
Suhas Hariharan committed Mar 17, 2020
1 parent 3c19935 commit ef63cf4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/js/models/Course.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
import { calculate_credit_hours } from '../helpers';

export default class Course {
#name;
Expand All @@ -40,13 +41,13 @@ export default class Course {
* @param {Assignment[]} [assignments] number of missing assignments
* @param {Number?} [creditHour] number of credit hours this course counts for, optional
*/
constructor (name, link, grade, finalPercent, assignments, creditHour) {
constructor (name, link, grade, finalPercent, assignments) {
this.#name = name;
this.#link = link;
this.#grade = grade;
this.#finalPercent = finalPercent;
this.#assignments = assignments;
this.#creditHour = creditHour;
this.#creditHour = calculate_credit_hours(this.#name);
}

get name () {
Expand Down
6 changes: 3 additions & 3 deletions src/js/saspowerschoolff.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import $ from 'jquery';
const browser = require('webextension-polyfill');

import { calculate_gpa, extractFinalPercent, gradeToGPA, calculate_credit_hours } from './helpers';
import { calculate_gpa, extractFinalPercent, gradeToGPA } from './helpers';

// Vue Components
import Vue from 'vue';
Expand Down Expand Up @@ -120,7 +120,7 @@ function main_page () {
}
if ($course.length === 1) {
const temp = $course.parents().eq(1).children("td[align=left]").text().match(".*(?=Details)")[0];
courses.push(new Course(temp.trim(), `https://powerschool.sas.edu.sg/guardian/${$course.attr('href')}`, $course.text(), 0, "", calculate_credit_hours(temp.trim())));
courses.push(new Course(temp.trim(), `https://powerschool.sas.edu.sg/guardian/${$course.attr('href')}`, $course.text(), 0, ""));
if (gradeToGPA($course.text()) !== -1) {
new (Vue.extend(ClassGrade))({
propsData: {
Expand Down Expand Up @@ -238,7 +238,7 @@ function calculate_cumulative_gpa (current_courses) {
const $prev_course = element_list[t];
// Creates course object with each course from grade history page
const course = new Course($prev_course.getElementsByTagName("td")[0].textContent.trim(), "",
$prev_course.getElementsByTagName("td")[1].textContent.trim(), 0, "", parseFloat($prev_course.getElementsByTagName("td")[4].innerText));
$prev_course.getElementsByTagName("td")[1].textContent.trim(), 0, "");

courses.push(course);
}
Expand Down

0 comments on commit ef63cf4

Please sign in to comment.