Skip to content

Commit

Permalink
refactor grading status loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaney committed Jul 26, 2024
1 parent ea5af0b commit 5f78acb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 10 additions & 7 deletions course_grader_vue/components/section/primary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ export default {
};
},
methods: {
applyGradingStatus: function (grading_status) {
this.gradingStatusText = this.formatGradingStatus(grading_status);
this.routerLinkTitle = this.formatLinkTitle(grading_status);
// Add secondary statusus to prop
if (grading_status.hasOwnProperty("secondary_sections")) {
this.gradingStatus = grading_status.secondary_sections;
}
},
loadSectionStatus: function () {
if (this.section.status_url) {
this.getSectionStatus(this.section.status_url).then(response => {
return response.data;
}).then(data => {
this.gradingStatusText = this.formatGradingStatus(data.grading_status);
this.routerLinkTitle = this.formatLinkTitle(data.grading_status);
// Load secondary statusus
if (data.grading_status.hasOwnProperty("secondary_sections")) {
this.gradingStatus = data.grading_status.secondary_sections;
}
this.applyGradingStatus(data.grading_status);
}).catch(error => {
console.log(error.message);
});
Expand Down
14 changes: 8 additions & 6 deletions course_grader_vue/components/section/secondary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,26 @@ export default {
};
},
methods: {
applyGradingStatus: function (grading_status) {
this.gradingStatusText = this.formatGradingStatus(grading_status);
this.routerLinkTitle = this.formatLinkTitle(grading_status);
},
loadSectionStatus: function () {
if (this.section.status_url) {
this.getSectionStatus(this.section.status_url).then(response => {
return response.data;
}).then(data => {
this.gradingStatusText = this.formatGradingStatus(data.grading_status);
this.routerLinkTitle = this.formatLinkTitle(data.grading_status);
this.applyGradingStatus(data.grading_status);
}).catch(error => {
console.log(error.message);
});
} else {
grading_status = this.gradingStatus.find((gs) =>
// Check for a grading status in the prop
let grading_status = this.gradingStatus.find((gs) =>
gs.section_id === this.section.section_id
);
if (grading_status) {
this.gradingStatusText = this.formatGradingStatus(grading_status);
this.routerLinkTitle = this.formatLinkTitle(grading_status);
this.applyGradingStatus(grading_status);
}
}
},
Expand Down

0 comments on commit 5f78acb

Please sign in to comment.