-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add CourseApp for Learning Assistant feature and register as entrypoint #52
Conversation
61a8e66
to
03ccf9a
Compare
learning_assistant/plugins.py
Outdated
|
||
app_id = 'learning_assistant' | ||
name = 'Learning Assistant' | ||
description = 'TBD' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBD: We need to provide a privacy-approved description. DO NOT merge without filling this in.
@@ -131,6 +131,12 @@ def is_requirement(line): | |||
entry_points={ | |||
'lms.djangoapp': [ | |||
"learning_assistant = learning_assistant.apps:LearningAssistantConfig" | |||
], | |||
'cms.djangoapp': [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the CourseApps
API is registered under the CMS application, the Learning Assistant
needs to be registered as a plugin there as well. Otherwise, the plugin is not included in the CMS's INSTALLED_APPS
list, which causes a runtime error, because the LearningAssistantCourseApp
plugin refers to the Learning Assistant
models, which are not available in the CMS.
d77cadf
to
440c711
Compare
Because the LearningAssistantCourseApp plugin inherits from the CourseApp class, which is imported from the | ||
edx-platform, we cannot test that plugin directly, because pytest will run outside the platform context. | ||
Instead, the CourseApp abstract methods are implemented here and | ||
imported into and used by the LearningAssistantCourseApp. This way, these implementations can be tested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh good idea
|
||
|
||
@frozen | ||
class LearningAssistantCourseEnabledData: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the data class used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following our Django App Patterns OEP, so I don't expose a modal instance via the API. I need to return something from set_learning_assistant_enabled
, because the CourseApp
ABC requires that the set_enabled
function implementation returns the value of the toggle.
On second look, I could return a boolean from set_learning_assistant_enabled
and avoid needing the data class entirely. I think I was treating set_learning_assistant_enabled
as a create/update operation and was thinking about returning the created/update object, which necessitated the data class. For now, this is a simple model/object, so that could be overkill.
If it feels heavy handed/confusing, let me know. I can return a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me 👍
* bool: whether the Learning Assistant feature is available | ||
""" | ||
# pylint: disable=import-error, import-outside-toplevel | ||
from lms.djangoapps.courseware.toggles import learning_assistant_is_active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking out loud. Does this create a cms -> learning -> lms import loop and is that a problem in any way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. I don't think so. Where do you think the loop would be? I've tried tracing it out, but I can't think of where there might be a loop currently.
I haven't seen any issues when testing the CourseApps
API in the CMS or when testing the Pages & Resources page.
Some other plugins are defined in the lms
directory (e.g. ProctoringCourseApp), so I'd imagine they would have a similar problem, if I'm understanding you correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I think a 'loop' might be the wrong term here. It's definitely weird to me we're importing from the LMS into the CMS tho. I'd expect shared code to exist in /openedx or /common. I guess if we're already following an established pattern for CourseApps best not to break it however.
440c711
to
39b5ab4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, but otherwise this looks good!
* course_key (CourseKey): the key of the course in which to get the user's role | ||
|
||
Returns: | ||
* bool: whether the Learning Assistant feature is available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: return type is the same as above
* bool: whether the Learning Assistant feature is available | ||
""" | ||
# pylint: disable=import-error, import-outside-toplevel | ||
from lms.djangoapps.courseware.toggles import learning_assistant_is_active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I think a 'loop' might be the wrong term here. It's definitely weird to me we're importing from the LMS into the CMS tho. I'd expect shared code to exist in /openedx or /common. I guess if we're already following an established pattern for CourseApps best not to break it however.
|
||
|
||
@frozen | ||
class LearningAssistantCourseEnabledData: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me 👍
deb03c4
to
35d74e6
Compare
5bf4885
to
ef032a0
Compare
…trypoint This commit adds a concrete implementation of the CourseApp ABC from the CourseApps edx-platform Django app. This enables the Learning Assistant to be represented by a card on the Studio Pages & Resources pages. Please see the associated ADR for more details. This commit also registers this CourseApp class as an entrypoint to the CourseApps edx-platfrom Django app. Because the CourseApps REST API is a part of the CMS, the Learning Assistant plugin was also added as entrypoint to the CMS.
ef032a0
to
705b526
Compare
Description
Jira: COSMO-135
NOTE: This pull request should not be merged until the configuration modal is added to the Course Authoring MFE for this feature. Please see COSMO-136 and COSMO-137.
This commit adds a concrete implementation of the
CourseApp
ABC from theCourseApps
edx-platform Django app. This enables the Learning Assistant to be represented by a card on the Studio Pages & Resources pages. Please see the associated ADR for more details.This commit also registers this
CourseApp
class as an entrypoint to theCourseApps
edx-platfrom Django app. Because theCourseApps
REST API is a part of the CMS, the Learning Assistant plugin was also added as entrypoint to the CMS.