[F] Load grading for each term
This commit is contained in:
+27
-22
@@ -152,32 +152,37 @@ export default class App extends Vue
|
|||||||
// Loop through all the courses
|
// Loop through all the courses
|
||||||
for (const course of this.filteredCourses)
|
for (const course of this.filteredCourses)
|
||||||
{
|
{
|
||||||
// Check if already exist in cookies
|
for (const i of [0, 1, 2, 3])
|
||||||
if (this.$cookies.isKey('va.grading.' + course.assignmentsId))
|
|
||||||
{
|
{
|
||||||
course.grading = {method: 'TOTAL_MEAN', weightingMap: {}};
|
const cookieIndex = `va.grading.${i}.${course.assignmentsId}`;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request grading scheme for this course
|
// Check if already exist in cookies
|
||||||
App.http.post('/grading', {'assignmentsId': course.assignmentsId}).then(response =>
|
if (this.$cookies.isKey(cookieIndex))
|
||||||
{
|
|
||||||
// Check success
|
|
||||||
if (response.success)
|
|
||||||
{
|
{
|
||||||
// Add it to course
|
course.grading[i] = {method: 'TOTAL_MEAN', weightingMap: {}};
|
||||||
course.grading = response.data;
|
continue;
|
||||||
|
|
||||||
// If it's total_mean, cache it to cookies
|
|
||||||
// This is because only percent_type can update over time
|
|
||||||
if (course.grading.method == 'TOTAL_MEAN')
|
|
||||||
{
|
|
||||||
this.$cookies.set('va.grading.' + course.assignmentsId, 'TOTAL_MEAN', '3d');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else throw new Error(response.data);
|
|
||||||
})
|
// Request grading scheme for this course at this grading period
|
||||||
.catch(e => this.showError(`Error: Grading data failed to load.\n(${e})`))
|
App.http.post('/grading/term', {assignmentsId: course.assignmentsId, term: i}).then(resp =>
|
||||||
|
{
|
||||||
|
// Check success
|
||||||
|
if (resp.success)
|
||||||
|
{
|
||||||
|
// Add it to course
|
||||||
|
course.grading[i] = resp.data;
|
||||||
|
|
||||||
|
// If it's total_mean, cache it to cookies
|
||||||
|
// This is because only percent_type can update over time
|
||||||
|
if (course.grading[i].method == 'TOTAL_MEAN')
|
||||||
|
{
|
||||||
|
this.$cookies.set(cookieIndex, 'TOTAL_MEAN', 'd');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else throw new Error(resp.data);
|
||||||
|
})
|
||||||
|
.catch(e => this.showError(`Error: Grading data failed to load.\n(${e})`))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for done
|
// Wait for done
|
||||||
|
|||||||
Reference in New Issue
Block a user