Skip to content

Commit

Permalink
Fixed possible score null
Browse files Browse the repository at this point in the history
In a recent update Canvas changed how assignment scores are displayed, breaking the extension. This push should fix that bug.
  • Loading branch information
da-stoi committed Jan 5, 2023
1 parent 41fcd45 commit 54fa2cc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/getAssignments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ export function getAssignments(): Assignment[] {
// Get the assignment average score
const average: number = parseFloat(scoreDetails?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[0].getElementsByTagName('td')[0].innerText?.trim().split('\n')[1].trim() || '0');

// Get the assignment possible score (total points)
const possible: number = parseFloat(assignment.querySelector('.possible')?.textContent?.trim() || '0');

let score: number = 0;
// Handle pass/fail assignments
const gradeElement = assignment.querySelector('.grade');

// Get the possible score
const possible: number = parseFloat(gradeElement?.nextElementSibling?.textContent?.split('/')[1].trim() || '0');

const gradeIcon = gradeElement?.getElementsByTagName('i')[0];
if (gradeIcon && gradeIcon.classList.contains('icon-check')) {
score = possible;
Expand Down

0 comments on commit 54fa2cc

Please sign in to comment.