Add group_work_allowed boolean to CourseInstance to avoid expensive l…
…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.
- How to test your changes in A-plus
- How to test accessibility
What type of test did you run?
- [ ] Accessibility test using the WAVE extension.
- [x] Django unit tests.
- [ ] Selenium tests.
- [ ] Other test. (Add a description below)
- [x] Manual testing.
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
- [x] Chrome
- [ ] Firefox
- [ ] This pull request cannot be tested in the browser.
Think of what is affected by these changes and could become broken
Translation
- [x] Did you modify or add new strings in the user interface? (Read about how to create translation)
Programming style
- [x] Did you follow our style guides?
- [x] Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)
Have you updated the README or other relevant documentation?
- [ ] documents inside the doc directory.
- [ ] README.md.
- [ ] Aplus Manual.
- [ ] Other documentation (mention below which documentation).
Is it Done?
- [ ] Reviewer has finished the code review
- [ ] After the review, the developer has made changes accordingly
- [ ] Customer/Teacher has accepted the implementation of the feature
Clean up your git commit history before submitting the pull request!