feat: enable Student Notes by default in InheritanceMixin#381
Closed
alenkadev wants to merge 7 commits into
Closed
feat: enable Student Notes by default in InheritanceMixin#381alenkadev wants to merge 7 commits into
alenkadev wants to merge 7 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 | ||
| ) |
Comment on lines
+21
to
+22
| @pytest.fixture(autouse=True) | ||
| def create_edxnotes_oauth_client(django_db_blocker): |
db318d4 to
af01753
Compare
Comment on lines
+7
to
+17
| @pytest.fixture(autouse=True) | ||
| def create_edxnotes_oauth_client(db): | ||
| """ | ||
| Create edx-notes OAuth2 Application for LMS tests. | ||
| """ | ||
| if settings.FEATURES.get('ENABLE_EDXNOTES', False): | ||
| from oauth2_provider.models import Application | ||
| from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory | ||
|
|
||
| if not Application.objects.filter(name=settings.EDXNOTES_CLIENT_NAME).exists(): | ||
| ApplicationFactory(name=settings.EDXNOTES_CLIENT_NAME) |
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) |
af01753 to
8807fd6
Compare
Comment on lines
+22
to
+27
| 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
+21
to
+38
| @pytest.fixture(autouse=True) | ||
| def create_edxnotes_oauth_client(db): | ||
| """ | ||
| Create edx-notes OAuth2 Application for all tests when | ||
| ENABLE_EDXNOTES is enabled and the setting is configured. | ||
| """ | ||
| client_name = getattr(settings, 'EDXNOTES_CLIENT_NAME', None) | ||
| if not client_name: | ||
| return | ||
|
|
||
| if not getattr(settings, 'FEATURES', {}).get('ENABLE_EDXNOTES', False): | ||
| return | ||
|
|
||
| from oauth2_provider.models import Application | ||
| from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory | ||
|
|
||
| if not Application.objects.filter(name=client_name).exists(): | ||
| ApplicationFactory(name=client_name) |
Comment on lines
+21
to
+37
| @pytest.fixture(autouse=True) | ||
| def create_edxnotes_oauth_client(db): | ||
| """ | ||
| Create edx-notes OAuth2 Application for all tests when | ||
| ENABLE_EDXNOTES is enabled and the setting is configured. | ||
|
|
||
| Uses direct model creation to avoid creating an extra User | ||
| (which breaks tests that count users or look them up by unique fields). | ||
| """ | ||
| client_name = getattr(settings, 'EDXNOTES_CLIENT_NAME', None) | ||
| if not client_name: | ||
| return | ||
|
|
||
| if not getattr(settings, 'FEATURES', {}).get('ENABLE_EDXNOTES', False): | ||
| return | ||
|
|
||
| from oauth2_provider.models import Application |
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
+26
to
+32
| from django.test import SimpleTestCase, TestCase as DjangoTestCase | ||
|
|
||
| # Only run for tests with DB access. | ||
| if request.cls: | ||
| if issubclass(request.cls, SimpleTestCase) and not issubclass(request.cls, DjangoTestCase): | ||
| return | ||
|
|
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
+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
+28
to
+33
| # Only run for Django class-based tests with DB access. | ||
| if not request.cls: | ||
| return | ||
| if not issubclass(request.cls, TransactionTestCase): | ||
| return | ||
|
|
Comment on lines
+22
to
+27
| 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
+20
to
+24
| @pytest.fixture(autouse=True) | ||
| def create_edxnotes_oauth_client(request): | ||
| """ | ||
| Create edx-notes OAuth2 Application for tests that have DB access | ||
| when ENABLE_EDXNOTES is enabled. |
| self.split_test_block.runtime.modulestore = mocked_modulestore | ||
|
|
||
|
|
||
| # @patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) |
| assert len(children) == 2 | ||
|
|
||
|
|
||
| # @patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) |
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
+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
+28
to
+32
| # Only run for Django class-based tests with DB access. | ||
| if not request.cls: | ||
| return | ||
| if not issubclass(request.cls, TransactionTestCase): | ||
| return |
Comment on lines
+49
to
+55
| if not Application.objects.filter(name=client_name).exists(): | ||
| Application.objects.create( | ||
| name=client_name, | ||
| user=None, | ||
| client_type=Application.CLIENT_CONFIDENTIAL, | ||
| authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS, | ||
| ) |
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