Compare commits

...

12 Commits

Author SHA1 Message Date
Hykilpikonna 35a85d8e83 [U] Release v0.2.3.315 2019-10-01 19:19:27 -04:00
Hykilpikonna 71b0a6e4dd [-] Remove debug output 2019-10-01 19:18:51 -04:00
Hykilpikonna d4fbd04466 [F] Fix grading history lower than actual 2019-10-01 19:18:33 -04:00
Hykilpikonna 31b3814b1e [O] Ignore 0 when calculating the score 2019-10-01 19:02:41 -04:00
Hykilpikonna 1aff2b0a68 [-] Remove debug output 2019-10-01 19:02:10 -04:00
Hykilpikonna 2567fcadbd [+] Encapsulate method to calculate total-mean average 2019-10-01 18:41:42 -04:00
Hykilpikonna d9e0e9f84e [F] Fix another null case 2019-10-01 18:41:14 -04:00
Hykilpikonna 59b31ea43f [F] Fix key word typo 2019-10-01 18:41:04 -04:00
Hykilpikonna 2c8b3e0f84 [F] Fix null case 2019-10-01 18:40:54 -04:00
Hykilpikonna 6910a7b5ea [F] Fix null pointer caused by grading not existing 2019-10-01 18:30:20 -04:00
Hykilpikonna cbdcfc4ca1 [+] Check gradings after checking assignments 2019-10-01 18:30:02 -04:00
Hykilpikonna feabc336c1 [+] Create method to check course gradings 2019-10-01 18:29:50 -04:00
5 changed files with 107 additions and 10 deletions
+65 -4
View File
@@ -7,6 +7,7 @@ import JsonUtils from '@/utils/json-utils';
import pWaitFor from 'p-wait-for';
import {HttpUtils} from '@/utils/http-utils';
import {CourseUtils} from '@/utils/course-utils';
import {GPAUtils} from '@/utils/gpa-utils';
/**
* Objects of this interface represent assignment grades.
@@ -160,12 +161,11 @@ export default class App extends Vue
// Wait for assignments to be ready.
pWaitFor(() => this.isAssignmentsReady()).then(() =>
{
// When the assignments are ready
// TODO: Display loading
this.assignmentsReady = true;
// Filter courses
this.filteredCourses = CourseUtils.getGradedCourses(this.courses);
// Check grading algorithms
this.checkGradingAlgorithms();
});
}
@@ -184,6 +184,67 @@ export default class App extends Vue
return true;
}
/**
* Check the courses' grading algorithms. (Total-average or percent-type)
*/
private checkGradingAlgorithms()
{
// Loop through all the courses
for (const course of this.filteredCourses)
{
// Check if total-average grade is the same with percent-type grade
if (course.numericGrade == GPAUtils.getTotalMeanAverage(course))
{
course.grading = {method: 'TOTAL_AVERAGE', weightingMap: {}};
}
else
{
// Request grading scheme for this course
this.http.post('/grading', {'assignment_id': course.assignmentsId}).then(response =>
{
// Check success
if (response.success)
{
// Add it to course
course.grading = response.data;
}
else
{
// Show error message TODO: Show it properly
alert(response.data)
}
})
.catch(alert)
}
}
// Wait for done
pWaitFor(() => this.isGradingReady()).then(() =>
{
// When the assignments are ready
// TODO: Display loading
this.assignmentsReady = true;
})
}
/**
* Are grading algorithms ready or not.
*
* @returns boolean Ready or not
*/
private isGradingReady(): boolean
{
for (const course of this.filteredCourses)
{
if (course.grading == undefined)
{
return false;
}
}
return true;
}
/**
* This is called when a navigation tab is clicked
*
+1 -1
View File
@@ -13,7 +13,7 @@ export default class Constants
'| |. , |---|,---.,---.| , .,---,,---.,---.\n' +
' \\ / >< | || |,---|| | | .-\' |---\'| \n' +
' `\' \' ` ` \'` \'`---^`---\'`---|\'---\'`---\'` \n' +
' v0.2.2.303 `---\' ';
' v0.2.3.315 `---\' ';
// Graph Theme
public static THEME =
@@ -142,17 +142,28 @@ export default class GraphOverall extends Vue
}
});
let score = 0;
// Count total percentage (This is to avoid less than expected cases)
// Eg. If HW = 25% and Quiz = 75%, I have 1 hw and 0 quiz
// Without total percentage, the avg grade I get is 25%.
let totalPercentage = 0;
for (let type in course.grading.weightingMap)
{
if (typeScores[type] != undefined)
{
totalPercentage += course.grading.weightingMap[type];
}
}
// Count
let score = 0;
for (let type in typeScores)
{
score += typeScores[type] * course.grading.weightingMap[type] / typeCounts[type];
console.log(type);
let typeFactor = course.grading.weightingMap[type] / totalPercentage;
score += typeScores[type] * typeFactor / typeCounts[type];
}
// Add average to the row
row[course.name] = score * 100;
if (score != 0) row[course.name] = score * 100;
}
});
+1 -1
View File
@@ -26,7 +26,7 @@ export class CourseUtils
if (course.assignments.length == 0) return;
// Skip if there are no grading scale
if (course.grading.method == 'NOT_GRADED') return;
// if (course.grading.method == 'NOT_GRADED') return;
// Add it to the list
result.push(course);
+25
View File
@@ -102,4 +102,29 @@ export class GPAUtils
return -1;
}
/**
* Calculate the total-mean (total/max) average
*
* @param course Course
*/
public static getTotalMeanAverage(course: Course)
{
let score = 0;
let max = 0;
// Loop through assignments
course.assignments.forEach(assignment =>
{
// If assignment should be displayed
if (assignment.complete != 'Complete') return;
// Record scores
score += assignment.score;
max += assignment.scoreMax;
});
// Return
return score / max * 100;
}
}