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

feat: add CourseApp for Learning Assistant feature and register as entrypoint #52

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

MichaelRoytman
Copy link
Member

@MichaelRoytman MichaelRoytman commented Jan 10, 2024

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 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.

image image

@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-135-CourseApp-plugin branch from 61a8e66 to 03ccf9a Compare January 10, 2024 17:21

app_id = 'learning_assistant'
name = 'Learning Assistant'
description = 'TBD'
Copy link
Member Author

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': [
Copy link
Member Author

@MichaelRoytman MichaelRoytman Jan 10, 2024

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.

@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-135-CourseApp-plugin branch 5 times, most recently from d77cadf to 440c711 Compare January 10, 2024 22:17
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.
Copy link
Member

Choose a reason for hiding this comment

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

ahh good idea

learning_assistant/utils.py Show resolved Hide resolved


@frozen
class LearningAssistantCourseEnabledData:
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-135-CourseApp-plugin branch from 440c711 to 39b5ab4 Compare January 11, 2024 20:39
Copy link
Member

@alangsto alangsto left a 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
Copy link
Member

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
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

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

makes sense to me 👍

@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-135-CourseApp-plugin branch 3 times, most recently from deb03c4 to 35d74e6 Compare January 23, 2024 19:57
@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-135-CourseApp-plugin branch 2 times, most recently from 5bf4885 to ef032a0 Compare February 6, 2024 19:36
…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.
@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-135-CourseApp-plugin branch from ef032a0 to 705b526 Compare February 6, 2024 19:56
@MichaelRoytman MichaelRoytman merged commit b64608f into main Feb 7, 2024
8 checks passed
@MichaelRoytman MichaelRoytman deleted the michaelroytman/COSMO-135-CourseApp-plugin branch February 7, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants