Add group_work_allowed boolean to CourseInstance to avoid expensive l… #1368
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ookup on every page load
Fixes #1367
Description
What?
This PR replaces the automated logic for showing/hiding the "Form a group" menu item with a manual boolean setting, which is set at the course instance level. Note, that this PR requires a migration.
Why?
The previous implementation created way too many queries for each page load just to decide whether to show a menu item or not. The result should at least be cached if a manual setting is considered too much work for the course staff.
How?
A new boolean property group_work_allowed is added into the CourseInstance class. This is referenced in the course/templates/course/_course_menu.html template instead of checking whether the instance_max_group_size method returns a value greater than one.
Fixes #1367
This PR should be completed by adding checks to set the new boolean according to whether there are group-allowing assignments when data is imported via gitmanager. Also disabling the boolean could be prevented when an existing course has group-allowing assignments. User documentation would also need to be updated to include the new setting.
Testing
Remember to add or update unit tests for new features and changes.
What type of test did you run?
Tested changing the "Students can form groups" setting in Edit course -> Course, and that the "Form a group" appears/disappears when clicking Save. Checked cloning the course instance, and that the setting from source instance persists.
Did you test the changes in
Think of what is affected by these changes and could become broken
Translation
Programming style
Have you updated the README or other relevant documentation?
Is it Done?
Clean up your git commit history before submitting the pull request!