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

Audit Backend #114

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading