Skip to content

Commit

Permalink
session objectives now use multiple columns
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Oct 1, 2024
1 parent 843049a commit 487b446
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions packages/frontend/app/components/reports/subject/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,39 @@ export default class ReportsSubjectSessionComponent extends Component {
];
const result = await this.graphql.find('sessions', filters, attributes.join(','));
const sortedResults = sortBy(result.data.sessions, 'title');

const objectives = sortedResults.map(({ sessionObjectives }) => {
return mapBy(sessionObjectives, 'title');
});
const maxObjectiveCount = objectives.reduce((longest, current) => {
return current.length > longest.length ? current : longest;
}, []).length;

const mappedResults = sortedResults.map(({ title, course, sessionObjectives, description }) => {
return [
const results = [
title,
course.title,
this.academicYearCrossesCalendarYearBoundaries
? `${course.year} - ${course.year + 1}`
: `${course.year}`,
striptags(description),
striptags(mapBy(sessionObjectives, 'title').join()),
];
sessionObjectives.forEach((objective) => {
results.push(striptags(objective.title));
});
return results;
});

return [
[
this.intl.t('general.session'),
this.intl.t('general.course'),
this.intl.t('general.academicYear'),
this.intl.t('general.description'),
this.intl.t('general.objectives'),
],
...mappedResults,
const columns = [
this.intl.t('general.session'),
this.intl.t('general.course'),
this.intl.t('general.academicYear'),
this.intl.t('general.description'),
];
[...Array(maxObjectiveCount + 1).keys()].slice(1).map((key) => {
columns.push(`${this.intl.t('general.objective')} ${key}`);
});

return [columns, ...mappedResults];
}
}

0 comments on commit 487b446

Please sign in to comment.