Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make course advanced setting invite_only configurable site-wide #27252

Merged
merged 7 commits into from
Apr 14, 2021

Conversation

asadiqbal08
Copy link
Contributor

@asadiqbal08 asadiqbal08 commented Apr 6, 2021

Fixes mitodl#135 and reference to previous PR# https://github.com/edx/edx-platform/pull/20596

Background:

We would like to make the default value of the invitation_required attribute of the courseware object configurable via a feature flag, to be named COURSE_DEFAULT_INVITE_ONLY COURSES_INVITE_ONLY

As it is currently, this is a manually updated flag in the course advanced settings and we would like to be able to manage the default value across all courses in a given deployment. The default value of the added setting should remain the same as the current setting of False, but allow us to set it to True through the existing settings mechanism.

We have merged this solution in our forked repository mitodl#126.

@openedx-webhooks
Copy link

Thanks for the pull request, @asadiqbal08! I've created OSPR-5719 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Apr 6, 2021
@natabene
Copy link
Contributor

natabene commented Apr 6, 2021

@asadiqbal08 Thank you for your contribution. Looks like this is ready for our review.

@@ -928,7 +930,7 @@ def course_about(request, course_id):

# Used to provide context to message to student if enrollment not allowed
can_enroll = bool(request.user.has_perm(ENROLL_IN_COURSE, course))
invitation_only = course.invitation_only
invitation_only = is_course_default_invite_only_enabled() or course.invitation_only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will course.invitation_only always be True or False, or can it be not set (None)?

It strikes me that with the logic here, if the toggle is set to True, it will never be possible to override it for one course. All courses will be invite only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdpinch It either be True/False.

It strikes me that with the logic here, if the toggle is set to True, it will never be possible to override it for one course. All courses will be invite only.

hmmm but what I get yet, We are giving precedence to COURSE_DEFAULT_INVITE_ONLY flag in the task.
I mean, If is_course_default_invite_only_enabled is True then all courses will be invite only. Is it not the requirement here ? mean, reference to earlier merge: PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is, the PR meets the MIT ODL use case, but I feel like the setting name suggests a different behavior. COURSE_DEFAULT_INVITE_ONLY sounds like it should only change the default setting, instead of overriding the setting for all courses.

We could either:

  • Change the logic, or
  • Change the setting to COURSES_INVITE_ONLY

@asadiqbal08 asadiqbal08 force-pushed the asadiqbal08/issue-123 branch from 6b9c553 to 7d71607 Compare April 8, 2021 10:36
@pdpinch pdpinch self-assigned this Apr 8, 2021
@pdpinch pdpinch changed the title make default value of invite_only configurable make course advanced setting invite_only configurable site-wide Apr 9, 2021
@pdpinch
Copy link
Contributor

pdpinch commented Apr 9, 2021

I updated the PR description and subject to reflect the new setting name and expected behavior. This should be reflected in the commit message as well.

Copy link
Contributor

@pdpinch pdpinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@sarina sarina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this from a naive perspective of the feature. Just a few comments for clarity, but the code looks good.

@@ -500,6 +501,39 @@ def test__has_access_course_can_enroll(self):
)
assert not access._has_access_course(user, 'enroll', course)

@override_settings(COURSES_INVITE_ONLY=False)
def test__course_default_invite_only_flag_false(self):
"""Tests that default value of COURSES_INVITE_ONLY as False."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As someone rather new to these features, the tests are somewhat unclear. Look at the above test - there's lots of comments around the assert statements & mock course creation to explain what's going on. Could you please add such comments for clarity? I wouldn't hate a more descriptive docstring, either.

Also a nit on the docstring format to do:

"""
Tests that default value of COURSES_INVITE_ONLY as False.
"""

course = self._mock_course(invitation=False)
self.assertFalse(access._has_access_course(user, 'enroll', course))

def _mock_course(self, invitation):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is specific to your tests, I wonder if it should have a more specific name such as _mock_course_with_invitation or something better than that, ha

# .. toggle_implementation: SettingToggle
# .. toggle_type: feature_flag
# .. toggle_default: False
# .. toggle_description: Set this to manage the default value for INVITE_ONLY across all courses in a given deployment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I 100% follow this description, and I'm not sure why. Maybe Setting this sets the default value of INVITE_ONLY across all courses in a given deployment

@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@asadiqbal08 asadiqbal08 requested a review from sarina April 12, 2021 12:11
Copy link
Contributor

@sarina sarina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash & rebase then myself or @pdpinch can merge

edit: please also use Conventional Commits

@openedx-webhooks
Copy link

@asadiqbal08 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

@pdpinch pdpinch deleted the asadiqbal08/issue-123 branch April 14, 2021 12:06
@sarina
Copy link
Contributor

sarina commented Apr 14, 2021

@pdpinch please be sure to use Conventional Commits before merging in the future - thanks!

blarghmatey pushed a commit to mitodl/edx-platform that referenced this pull request Sep 7, 2021
Setting COURSES_INVITE_ONLY to True overrides the INVITE_ONLY setting across all courses in a given deployment.

Co-authored-by: tasawernawaz <[email protected]>
Co-authored-by: asadiqbal08 <[email protected]>
(cherry picked from commit 80298ae)
@pdpinch
Copy link
Contributor

pdpinch commented Sep 10, 2021

Sorry @sarina I missed your comment https://github.com/edx/edx-platform/pull/27252#issuecomment-819477760 -- but I thought this was a conventional commit: edx/edx-platform@80298ae

Did I overlook something?

@sarina
Copy link
Contributor

sarina commented Sep 13, 2021

@pdpinch huh. I just looked at the list of commits on the PR and saw none of them were conventional:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upstream "make default value of invite_only configurable"
6 participants