Skip to content

Commit 4743f77

Browse files
committed
Keeping solution boxes closed when there are too many solutions/users/assignments.
1 parent 19fab61 commit 4743f77

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/pages/AssignmentSolutions/AssignmentSolutions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ class AssignmentSolutions extends Component {
633633
a.name.lastName.localeCompare(b.name.lastName, locale) ||
634634
a.name.firstName.localeCompare(b.name.firstName, locale)
635635
)
636-
.map(user => (
636+
.map((user, _, students) => (
637637
<Row key={user.id}>
638638
<Col sm={12}>
639639
<Box
@@ -654,7 +654,7 @@ class AssignmentSolutions extends Component {
654654
</>
655655
}
656656
collapsable
657-
isOpen
657+
isOpen={students.length <= 50 && (assignmentSolutions?.size ?? 0) <= 200}
658658
noPadding
659659
unlimitedHeight>
660660
<SolutionsTable

src/pages/GroupUserSolutions/GroupUserSolutions.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ const prepareTableColumnDescriptors = lruMemoize((assignments, groupId, locale,
230230
return columns;
231231
});
232232

233+
const getSolutionsCount = lruMemoize((assignments, getAssignmentSolutions) =>
234+
assignments.reduce((acc, assignment) => acc + (getAssignmentSolutions(assignment.id)?.size || 0), 0)
235+
);
236+
233237
const prepareTableData = lruMemoize((assignments, getAssignmentSolutions, getRuntime, onlyBestSolutionsCheckbox) => {
234238
const res = [];
235239
assignments.forEach(assignment =>
@@ -529,7 +533,10 @@ class GroupUserSolutions extends Component {
529533
</>
530534
}
531535
collapsable
532-
isOpen
536+
isOpen={
537+
assignments.length <= 50 &&
538+
getSolutionsCount(assignments, getAssignmentSolutions) <= 200
539+
}
533540
noPadding
534541
unlimitedHeight>
535542
<SolutionsTable

src/redux/selectors/usersGroups.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { isStudentLocked } from '../../components/helpers/exams.js';
1010
const getState = state => state;
1111
const getParam = (_, id) => id;
1212

13-
// users of type in particualar groups
13+
// users of type in particular groups
1414
const usersIdsOfGroup = (type, groupId) =>
1515
createSelector(groupSelectorCreator(groupId), group =>
1616
group && isReady(group) ? group.getIn(['data', 'privateData', type], EMPTY_LIST).toArray() : []

0 commit comments

Comments
 (0)