Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #114 from Adamv27/audit-backend
Browse files Browse the repository at this point in the history
Audit Backend
  • Loading branch information
hcientist authored Apr 3, 2024
2 parents da4e585 + fde2df2 commit af852a4
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ export function getEnrollments() {
}

export function getStudentAssignments(slug) {
const activitySort = (a, b) => { // FIXME: this is a disaster.
const ordering = {
Melody: 1,
Bassline: 2,
Creativity: 3,
Reflection: 4,
Connect: 5,
Aural: 3,
Exploratory: 3,
Theoretical: 3,
MelodyPost: 3.1,
BasslinePost: 3.2,
};
const c = a.activity_type_name.split(' ')[0];
const d = b.activity_type_name.split(' ')[0];
const result = ordering[c] - ordering[d];
return result;
};
return () =>
getSession()
.then((session) => {
Expand All @@ -58,21 +40,8 @@ export function getStudentAssignments(slug) {
}
);
})
.then((response) => response.json())
.then((results) => {
const grouped = results.reduce((acc, obj) => {
// const key = obj.piece_name;
const key = obj.piece_slug;
if (!acc[key]) {
acc[key] = [];
}
// Add object to list for given key's value
acc[key].push(obj);
return acc;
}, {});
// FIXME: this should respect order from server/pieceplan and mayeb do this as a backup?
Object.values(grouped).forEach(pieceAssignments=>pieceAssignments.sort(activitySort));
return grouped;
.then((response) => {
return response.json()
});
}

Expand Down

0 comments on commit af852a4

Please sign in to comment.