Fix the Instructor Dashboard crash caused for feedback xblock - #22
Conversation
|
Thanks for the pull request, @salman2013! This repository is currently unmaintained. 🔘 Find a technical reviewerTo get help with finding a technical reviewer, reach out to the community contributions project manager for this PR:
Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
==========================================
+ Coverage 79.69% 80.81% +1.11%
==========================================
Files 30 31 +1
Lines 778 839 +61
Branches 50 53 +3
==========================================
+ Hits 620 678 +58
- Misses 136 137 +1
- Partials 22 24 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kdmccormick
left a comment
There was a problem hiding this comment.
Thanks for porting the fix over! I have one request, but if you agree with it, then this is good to merge 👍🏻
| try: | ||
| # pylint: disable=import-outside-toplevel | ||
| from openedx.core.djangoapps.site_configuration.models import SiteConfiguration | ||
|
|
||
| except ImportError: | ||
| return None |
There was a problem hiding this comment.
Importing from openedx-platform internals is a bad pattern that I want us to get away from, but as it stands now there is no other way for an XBlock to use SiteConfiguration
Could you add this warning and this clause which will make the code more resilient?
| try: | |
| # pylint: disable=import-outside-toplevel | |
| from openedx.core.djangoapps.site_configuration.models import SiteConfiguration | |
| except ImportError: | |
| return None | |
| # Hack: Import SiteConfiguration from openedx-platform. | |
| # Please note that XBlocks should not import core openedx-platform code. Do not | |
| # replicate this pattern elsewhere. If you need information from the platform, it's better | |
| # to catch an event, hook into a filter, or define and use an XBlock runtime service. | |
| try: | |
| # pylint: disable=import-outside-toplevel | |
| from openedx.core.djangoapps.site_configuration.models import SiteConfiguration | |
| except ImportError: | |
| if 'unittest' in sys.modules.keys(): | |
| # Fail silently when testing. We can't install openedx-platform for tests. | |
| return None | |
| # Otherwise, fail loudly, so that we will notice if the openedx-platform import path changes. | |
| raise |
note: you'll need to add import sys to the top of the module
There was a problem hiding this comment.
I agree with your suggested changes and have updated the code accordingly. Thanks.
Description
Fixes the Instructor Dashboard crash caused by an indirect import chain that pulls in
openedx.core.djangoapps.content.search— an app not registered inINSTALLED_APPSon the LMS.Resolves: openedx/FeedbackXBlock#164
Root Cause
When the
AddFeedbackTabfilter pipeline renders the Feedback tab on the Instructor Dashboard,filters.pyimportsget_lms_link_for_itemdirectly fromcms.djangoapps.contentstore.utils. This triggers the following import chain at module load time:The
content.searchapp was introduced in 2024 and is only available in the CMS (Studio) context. Because it is not included inINSTALLED_APPSon the LMS, the import fails at runtime, breaking the entire Instructor Dashboard Feedback tab for Open edX platforms running Sumac or later.For more details Ref: openedx/FeedbackXBlock#164
Fix
This PR replicates the fix from openedx/FeedbackXBlock#166: the direct import of
get_lms_link_for_itemfromcms.djangoapps.contentstore.utilsis replaced with a locally re-implemented version infeedback/utils.py. The new implementation usesSiteConfiguration.get_value_for_org(guarded by atry/except ImportError) to resolve the LMS base URL, decoupling the XBlock from CMS-only platform internals.This makes the XBlock self-contained and compatible with both LMS and Studio environments.
How to Test
Install the XBlock from this branch.
To enable the FeedbackXBlock report in the instructor dashboard, you can use the tutor inline plugins: https://github.com/openedx/FeedbackXBlock?tab=readme-ov-file#tutor-configuration
Navigate to the Instructor Dashboard of a course using the Feedback XBlock.
Click the Feedback tab — it should render without errors.
Testing Results After Fix: