feat: enable Student Notes by default in InheritanceMixin#381
Open
alenkadev wants to merge 3 commits into
Open
feat: enable Student Notes by default in InheritanceMixin#381alenkadev wants to merge 3 commits into
alenkadev wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Enables the Student Notes feature by default for courses by changing the InheritanceMixin.edxnotes field default from False to True, so courses that don’t explicitly set this advanced setting will now have Student Notes enabled when the global ENABLE_EDXNOTES feature flag is on.
Changes:
- Changed
InheritanceMixin.edxnotesdefault fromFalsetoTrueto enable Student Notes by default at the course setting level.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """ | ||
| def setUp(self): | ||
| super().setUp() | ||
| ApplicationFactory(name=settings.EDXNOTES_CLIENT_NAME) |
881de37 to
8afcb00
Compare
Comment on lines
65
to
66
| @patch.dict('django.conf.settings.FEATURES', {'ENABLE_EDXNOTES': False}) | ||
| class SplitTestBlockTest(XModuleXmlImportTest, PartitionTestCase): |
8afcb00 to
e1d803b
Compare
Comment on lines
+71
to
+75
| # Mock the OAuth2 client lookup for edxnotes to avoid infrastructure requirement in tests | ||
| oauth2_patcher = patch('openedx.core.djangoapps.oauth_dispatch.models.OAuth2Client.objects.get') | ||
| oauth2_patcher.return_value = Mock(client_id='edx-notes-test', redirect_uris='') | ||
| oauth2_patcher.start() | ||
| self.addCleanup(oauth2_patcher.stop) |
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
Comment on lines
+71
to
+80
| # Mock the OAuth2 client lookup for edxnotes to avoid infrastructure requirement in tests | ||
| mock_app = Mock() | ||
| mock_app.client_id = 'edx-notes-test' | ||
| mock_app.client_secret = 'test-secret' | ||
| oauth2_patcher = patch( | ||
| 'lms.djangoapps.edxnotes.helpers.Application.objects.get', | ||
| return_value=mock_app, | ||
| ) | ||
| oauth2_patcher.start() | ||
| self.addCleanup(oauth2_patcher.stop) |
Comment on lines
210
to
215
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings | ||
| ) |
Comment on lines
+71
to
+75
| # Mock the OAuth2 client lookup for edxnotes to avoid infrastructure requirement in tests | ||
| oauth2_patcher = patch('lms.djangoapps.edxnotes.helpers.get_edxnotes_id_token') | ||
| mock_get_token = oauth2_patcher.start() | ||
| mock_get_token.return_value = 'test-token' | ||
| self.addCleanup(oauth2_patcher.stop) |
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
Comment on lines
+72
to
+75
| oauth2_patcher = patch('lms.djangoapps.edxnotes.decorators.get_edxnotes_id_token') | ||
| mock_get_token = oauth2_patcher.start() | ||
| mock_get_token.return_value = 'test-token' | ||
| self.addCleanup(oauth2_patcher.stop) |
Comment on lines
+71
to
+74
| # Mock the OAuth2 client lookup for edxnotes to avoid infrastructure requirement in tests | ||
| oauth2_patcher = patch('lms.djangoapps.edxnotes.helpers.get_edxnotes_id_token', return_value='test-token') | ||
| oauth2_patcher.start() | ||
| self.addCleanup(oauth2_patcher.stop) |
Comment on lines
210
to
215
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings | ||
| ) |
baa8142 to
70e1a5d
Compare
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
70e1a5d to
0998505
Compare
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
0998505 to
ec551ab
Compare
Comment on lines
+60
to
+63
| log.warning(ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| f'OAuth2 Client with name [{settings.EDXNOTES_CLIENT_NAME}] does not exist.' | ||
| ) | ||
| )) | ||
| return None |
Comment on lines
57
to
+63
| try: | ||
| notes_application = Application.objects.get(name=settings.EDXNOTES_CLIENT_NAME) | ||
| except Application.DoesNotExist: | ||
| raise ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| log.warning(ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| f'OAuth2 Client with name [{settings.EDXNOTES_CLIENT_NAME}] does not exist.' | ||
| ) | ||
| )) | ||
| return None |
Comment on lines
57
to
+63
| try: | ||
| notes_application = Application.objects.get(name=settings.EDXNOTES_CLIENT_NAME) | ||
| except Application.DoesNotExist: | ||
| raise ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| log.warning(ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| f'OAuth2 Client with name [{settings.EDXNOTES_CLIENT_NAME}] does not exist.' | ||
| ) | ||
| )) | ||
| return None |
Comment on lines
53
to
67
| def get_edxnotes_id_token(user): | ||
| """ | ||
| Returns generated ID Token for edxnotes. | ||
| """ | ||
| try: | ||
| notes_application = Application.objects.get(name=settings.EDXNOTES_CLIENT_NAME) | ||
| except Application.DoesNotExist: | ||
| raise ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| f'OAuth2 Client with name [{settings.EDXNOTES_CLIENT_NAME}] does not exist.' | ||
| log.warning( | ||
| 'OAuth2 Client with name [%s] does not exist. EdxNotes will be disabled.', | ||
| settings.EDXNOTES_CLIENT_NAME | ||
| ) | ||
| return None | ||
| return create_jwt_for_user( | ||
| user, secret=notes_application.client_secret, aud=notes_application.client_id | ||
| ) |
Comment on lines
210
to
214
| edxnotes = Boolean( | ||
| display_name=_("Enable Student Notes"), | ||
| help=_("Enter true or false. If true, students can use the Student Notes feature."), | ||
| default=False, | ||
| default=True, | ||
| scope=Scope.settings |
Comment on lines
57
to
+64
| try: | ||
| notes_application = Application.objects.get(name=settings.EDXNOTES_CLIENT_NAME) | ||
| except Application.DoesNotExist: | ||
| raise ImproperlyConfigured( # lint-amnesty, pylint: disable=raise-missing-from | ||
| f'OAuth2 Client with name [{settings.EDXNOTES_CLIENT_NAME}] does not exist.' | ||
| log.warning( | ||
| 'OAuth2 Client with name [%s] does not exist. EdxNotes will be disabled.', | ||
| settings.EDXNOTES_CLIENT_NAME | ||
| ) | ||
| return None |
Comment on lines
+126
to
+127
| @ddt.ddt | ||
| @patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) |
Comment on lines
+60
to
+64
| log.warning( | ||
| 'OAuth2 Client with name [%s] does not exist. EdxNotes will be disabled.', | ||
| settings.EDXNOTES_CLIENT_NAME | ||
| ) | ||
| return None |
Comment on lines
+88
to
+92
| def test_app_enabled_by_default(self): | ||
| """ | ||
| Test that the app tab is disabled by default. | ||
| Test that the app tab is enabled by default. | ||
| """ | ||
| assert not self.course_app_class.is_enabled(self.course.id) | ||
| assert self.course_app_class.is_enabled(self.course.id) |
57b1e03 to
40c1544
Compare
Comment on lines
+60
to
+64
| log.warning( | ||
| 'OAuth2 Client with name [%s] does not exist. EdxNotes will be disabled.', | ||
| settings.EDXNOTES_CLIENT_NAME | ||
| ) | ||
| return None |
Comment on lines
+88
to
+92
| def test_app_enabled_by_default(self): | ||
| """ | ||
| Test that the app tab is disabled by default. | ||
| Test that the app tab is enabled by default. | ||
| """ | ||
| assert not self.course_app_class.is_enabled(self.course.id) | ||
| assert self.course_app_class.is_enabled(self.course.id) |
Comment on lines
+22
to
+26
| def test_app_disabled_by_default(self): | ||
| """ | ||
| Override base mixin behavior: Notes is enabled by default. | ||
| """ | ||
| assert self.course_app_class.is_enabled(self.course.id) |
Comment on lines
+60
to
+64
| log.warning( | ||
| 'OAuth2 Client with name [%s] does not exist. EdxNotes will be disabled.', | ||
| settings.EDXNOTES_CLIENT_NAME | ||
| ) | ||
| return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Enable the Student Notes feature by default by changing the default value of the edxnotes setting in InheritanceMixin from False to True.
jira_link- https://2u-internal.atlassian.net/browse/LP-952