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

refactor: Refactor & add required rapid response counterpart #275

Merged
merged 1 commit into from
Dec 2, 2021

Conversation

arslanashraf7
Copy link

Related Ticket:

#273

Description

We did some platform changes to use some of the rapid response functionality & later on we used to cherry-pick that with every Open edX release. Now we are trying to refactor and migrate all this code into a plugin in https://github.com/mitodl/open-edx-plugins.

What this PR does?

  • It picks only the relevant parts of the commit(bbe7d06)
  • It's currently in progress, But if we can move all the code to the plugin then this PR will contain the remaining counterpart.

How to test?

This should be tested once we create a rapid response plugin in https://github.com/mitodl/open-edx-plugins.

@@ -237,6 +239,10 @@ def instructor_dashboard_2(request, course_id): # lint-amnesty, pylint: disable

certificate_invalidations = CertificateInvalidation.get_certificate_invalidations(course_key)

# x block asides enabled, included rapid response tab
if XBlockAsidesConfig.current().enabled:
Copy link
Author

@arslanashraf7 arslanashraf7 Nov 18, 2021

Choose a reason for hiding this comment

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

@pdpinch We've been adding the Rapid Responses tab in the instructor dashboard based on a condition if xBlockAside is added/enabled. Should I keep it like that or should I do it like something similar as we did for canvas integration e.g. Show the canvas tab if the plugin is not installed - (We removed a feature flag there)?

*Edit(17:56 GMT+5) Show the canvas tab if the plugin is installed

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that's a better pattern and it would be good to be consistent.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Updated my message above, I meant Show the canvas tab if the plugin is installed. But you already got it right I believe.

@arslanashraf7 arslanashraf7 force-pushed the arslan/273-rapid-response branch 5 times, most recently from 691ae7c to f6c7cc6 Compare November 19, 2021 12:30
@gsidebo gsidebo self-assigned this Nov 29, 2021
@@ -237,6 +237,21 @@ def instructor_dashboard_2(request, course_id): # lint-amnesty, pylint: disable

certificate_invalidations = CertificateInvalidation.get_certificate_invalidations(course_key)

# x block asides enabled, included rapid response tab
Copy link

Choose a reason for hiding this comment

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

I don't think this comment is necessary

Comment on lines 241 to 244
if 'ol_openedx_rapid_response.app.RapidResponsePluginConfig' in settings.INSTALLED_APPS:
from openedx.core.djangoapps.plugins.constants import ProjectType
from edx_django_utils.plugins import get_plugins_view_context
from ol_openedx_rapid_response.constants import RAPID_RESPONSE_PLUGIN_VIEW_NAME # pylint: disable=import-error
Copy link

Choose a reason for hiding this comment

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

These inline imports aren't great for a few reasons. One reason is that if there's an import error, we wouldn't know until this function is called. I tried this locally and it seems to work.

Add this to the bottom of the imports at the top of the module:

rapid_response_enabled = 'ol_openedx_rapid_response.app.RapidResponsePluginConfig' in settings.INSTALLED_APPS
if rapid_response_enabled:
    from openedx.core.djangoapps.plugins.constants import ProjectType
    from edx_django_utils.plugins import get_plugins_view_context
    from ol_openedx_rapid_response.constants import RAPID_RESPONSE_PLUGIN_VIEW_NAME  # pylint: disable=import-error

Then update this block:

Suggested change
if 'ol_openedx_rapid_response.app.RapidResponsePluginConfig' in settings.INSTALLED_APPS:
from openedx.core.djangoapps.plugins.constants import ProjectType
from edx_django_utils.plugins import get_plugins_view_context
from ol_openedx_rapid_response.constants import RAPID_RESPONSE_PLUGIN_VIEW_NAME # pylint: disable=import-error
if rapid_response_enabled:

Copy link
Author

@arslanashraf7 arslanashraf7 Dec 2, 2021

Choose a reason for hiding this comment

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

I gave it a cleaner look instead of checking the plugin installation and then fetching the context we'll just fetch the context which will be a dict/None based on if the plugin is installed or not. Also, there has been an Upstream PR for making more general improvements and when that's merged we'll make our plugins context generic too.

@arslanashraf7
Copy link
Author

@gsidebo This is ready for review again.

Copy link

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

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

Looks great! Great job on finding get_plugins_view_context. That's so much cleaner than the conditional imports

@arslanashraf7 arslanashraf7 changed the title refactor!: Refactor the code used for rapid response refactor: Refactor & add required rapid response counterpart Dec 2, 2021
@arslanashraf7 arslanashraf7 merged commit 91b24d3 into mitx/maple Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants