Compare commits

...

7 Commits

Author SHA1 Message Date
Hykilpikonna b5b9f14a49 [U] Pre-release v0.2.2.303 2019-09-30 21:16:53 -04:00
Hykilpikonna fc93cd1248 [+] Skip if not graded 2019-09-30 21:05:39 -04:00
Hykilpikonna 6e58c634a1 [F] Correct course average grade graph calculation 2019-09-30 21:05:29 -04:00
Hykilpikonna 10cca344c7 [M] Copy old course calculation method to deprecated 2019-09-30 21:05:07 -04:00
Hykilpikonna cdf58ea3a0 [O] Specify type for weighting map 2019-09-30 21:04:47 -04:00
Hykilpikonna d97c80afbb [U] Update course model to match the update 2019-09-30 19:25:59 -04:00
Hykilpikonna 8c7d028f5b [R] Update screenshot 2019-09-29 19:51:19 -04:00
6 changed files with 166 additions and 34 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ This is a website that generates visual representation of students' grade data o
**Here's how it looks like right now:** *(Now all of you know my grades ;-;)*
![](https://i.imgur.com/xl3Q4Nt.jpg)
![](https://user-images.githubusercontent.com/22280294/65841599-155ead00-e2f2-11e9-9d9f-c2f23c45d9a4.png)
<br>
+6
View File
@@ -41,6 +41,12 @@ export interface Course
level: string,
scaleUp: number,
grading:
{
method: string,
weightingMap: {[index: string]: number}
}
assignments: Grade[]
}
+1 -1
View File
@@ -13,7 +13,7 @@ export default class Constants
'| |. , |---|,---.,---.| , .,---,,---.,---.\n' +
' \\ / >< | || |,---|| | | .-\' |---\'| \n' +
' `\' \' ` ` \'` \'`---^`---\'`---|\'---\'`---\'` \n' +
' v0.2.1.295 `---\' ';
' v0.2.2.303 `---\' ';
// Graph Theme
public static THEME =
@@ -83,17 +83,6 @@ export default class GraphOverall extends Vue
dates.push(new Date(date));
}
// Initialize course specific variables
let courseScores: {[index: string]: any} = {};
let courseMaxScores: {[index: string]: any} = {};
let courseIndexes: {[index: string]: any} = {};
courses.forEach(course =>
{
courseScores[course.name] = 0;
courseMaxScores[course.name] = 0;
courseIndexes[course.name] = course.assignments.length - 1;
});
// Compute the rows data
let rows: {[index: string]: any}[] = [];
dates.forEach(date =>
@@ -104,33 +93,67 @@ export default class GraphOverall extends Vue
// Loop through courses
courses.forEach(course =>
{
// Reversed loop through the assignments
for (let r = courseIndexes[course.name]; r >= 0; r--)
// Total Mean
if (course.grading.method == 'TOTAL_MEAN')
{
let assignment = course.assignments[r];
let score = 0;
let max = 0;
// If assignment should be displayed
if (assignment.complete != 'Complete') continue;
// Date is being looked at
let assignmentDate = new Date(assignment.date);
if (assignmentDate.getTime() == date.getTime())
// Loop through assignments
course.assignments.forEach(assignment =>
{
// Record scores
courseScores[course.name] += assignment.score;
courseMaxScores[course.name] += assignment.scoreMax;
}
// If assignment should be displayed
if (assignment.complete != 'Complete') return;
// Not now
else if (assignmentDate > date)
{
courseIndexes[course.name] = r;
break;
}
// Date is being looked at
let assignmentDate = new Date(assignment.date);
if (assignmentDate.getTime() < date.getTime())
{
// Record scores
score += assignment.score;
max += assignment.scoreMax;
}
});
// Add average to the row
row[course.name] = score / max * 100;
}
else if (course.grading.method == 'PERCENT_TYPE')
{
let typeScores: {[index: string]: any} = {};
let typeCounts: {[index: string]: any} = {};
// Add average to the row
row[course.name] = courseScores[course.name] / courseMaxScores[course.name] * 100;
// Loop through assignments
course.assignments.forEach(assignment =>
{
// If assignment should be displayed
if (assignment.complete != 'Complete') return;
// Date is being looked at
let assignmentDate = new Date(assignment.date);
if (assignmentDate.getTime() < date.getTime())
{
// Record scores
if (typeScores[assignment.type] == undefined) typeScores[assignment.type] = 0;
typeScores[assignment.type] += assignment.score / assignment.scoreMax;
if (typeCounts[assignment.type] == undefined) typeCounts[assignment.type] = 0;
typeCounts[assignment.type] ++;
}
});
let score = 0;
// Count
for (let type in typeScores)
{
score += typeScores[type] * course.grading.weightingMap[type] / typeCounts[type];
console.log(type);
}
// Add average to the row
row[course.name] = score * 100;
}
});
// Add it to the array
+3
View File
@@ -24,6 +24,9 @@ export class CourseUtils
// Skip courses without assignments
if (course.assignments.length == 0) return;
// Skip if there are no grading scale
if (course.grading.method == 'NOT_GRADED') return;
// Add it to the list
result.push(course);
+100
View File
@@ -0,0 +1,100 @@
// Initialize course specific variables
let courseScores: {[index: string]: any} = {};
let courseMaxScores: {[index: string]: any} = {};
let courseIndexes: {[index: string]: any} = {};
courses.forEach(course =>
{
courseScores[course.name] = 0;
courseMaxScores[course.name] = 0;
courseIndexes[course.name] = course.assignments.length - 1;
});
// Compute the rows data
let rows: {[index: string]: any}[] = [];
dates.forEach(date =>
{
// Define row object
let row: {[index: string]:any} = {'date': date.toLocaleDateString('en-US')};
// Loop through courses
courses.forEach(course =>
{
// Reversed loop through the assignments
for (let r = courseIndexes[course.name]; r >= 0; r--)
{
let assignment = course.assignments[r];
// If assignment should be displayed
if (assignment.complete != 'Complete') continue;
// Date is being looked at
let assignmentDate = new Date(assignment.date);
if (assignmentDate.getTime() == date.getTime())
{
// Detect grading method and record scores
if (course.grading.method == 'TOTAL_MEAN')
{
courseScores[course.name] += assignment.score;
courseMaxScores[course.name] += assignment.scoreMax;
}
else if (course.grading.method == 'PERCENT_TYPE')
{
let scale = course.grading.weightingMap[assignment.type];
courseScores[course.name] += assignment.score * scale;
courseMaxScores[course.name] += assignment.scoreMax * scale;
}
}
// Not now
else if (assignmentDate > date)
{
courseIndexes[course.name] = r;
break;
}
}
// Add average to the row
row[course.name] = courseScores[course.name] / courseMaxScores[course.name] * 100;
});
// Add it to the array
rows.push(row);
});
else if (course.grading.method == 'PERCENT_TYPE')
{
let typeScores: {[index: string]: any} = {};
let typeCounts: {[index: string]: any} = {};
// Loop through assignments
course.assignments.forEach(assignment =>
{
// If assignment should be displayed
if (assignment.complete != 'Complete') return;
// Date is being looked at
let assignmentDate = new Date(assignment.date);
if (assignmentDate.getTime() < date.getTime())
{
// Record scores
if (typeScores[assignment.type] == undefined) typeScores[assignment.type] = 0;
typeScores[assignment.type] += assignment.score / assignment.scoreMax;
if (typeCounts[assignment.type] == undefined) typeCounts[assignment.type] = 0;
typeCounts[assignment.type] ++;
}
});
let score = 0;
// Count
for (let type in typeScores)
{
score += typeScores[type] * course.grading.weightingMap[type] / typeCounts[type];
console.log(type);
}
// Add average to the row
row[course.name] = score * 100;
}