Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenk committed Apr 26, 2023
1 parent aca759e commit fc4bacb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/data/selectors/grades.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export const formatMinAssignmentGrade = (percentGrade, options) => (
* @param {string} label - assignment filter label
* @return {string[]} - list of table headers
*/
export const headingMapper = (category, label = 'All') => {
export const headingMapper = (
category,
label = 'All',
hasMastersTrack,
) => {
const filters = {
all: section => section.label,
byCategory: section => section.label && section.category === category,
Expand All @@ -105,17 +109,25 @@ export const headingMapper = (category, label = 'All') => {
} else {
filter = filters.byLabel;
}

const {
username,
fullName,
email,
totalGrade,
} = Headings;
let userIdentificationHeadings;
if (hasMastersTrack) {
userIdentificationHeadings = [username, fullName, email];
} else {
userIdentificationHeadings = [username];
}

const filteredLabels = (entry) => entry.filter(filter).map(s => s.label);

return (entry) => (
entry
? [username, fullName, email, ...filteredLabels(entry), totalGrade]
? [...userIdentificationHeadings, ...filteredLabels(entry), totalGrade]
: []
);
};
Expand Down
1 change: 1 addition & 0 deletions src/data/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const formattedGradeLimits = (state) => {
export const getHeadings = (state) => grades.headingMapper(
filters.assignmentType(state) || 'All',
filters.selectedAssignmentLabel(state) || 'All',
tracks.stateHasMastersTrack(state),
)(grades.getExampleSectionBreakdown(state));

/**
Expand Down

0 comments on commit fc4bacb

Please sign in to comment.