Skip to content

Fix the Instructor Dashboard crash caused for feedback xblock - #22

Merged
salman2013 merged 4 commits into
mainfrom
salman/feedbackblock-fix
Apr 15, 2026
Merged

Fix the Instructor Dashboard crash caused for feedback xblock#22
salman2013 merged 4 commits into
mainfrom
salman/feedbackblock-fix

Conversation

@salman2013

@salman2013 salman2013 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the Instructor Dashboard crash caused by an indirect import chain that pulls in openedx.core.djangoapps.content.search — an app not registered in INSTALLED_APPS on the LMS.

Resolves: openedx/FeedbackXBlock#164

Root Cause

When the AddFeedbackTab filter pipeline renders the Feedback tab on the Instructor Dashboard, filters.py imports get_lms_link_for_item directly from cms.djangoapps.contentstore.utils. This triggers the following import chain at module load time:

cms.djangoapps.contentstore.utils
  → cms/djangoapps/contentstore/toggles.py
    → openedx.core.djangoapps.content.search.api
      → SearchAccess (model)

The content.search app was introduced in 2024 and is only available in the CMS (Studio) context. Because it is not included in INSTALLED_APPS on 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_item from cms.djangoapps.contentstore.utils is replaced with a locally re-implemented version in feedback/utils.py. The new implementation uses SiteConfiguration.get_value_for_org (guarded by a try/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

  1. Install the XBlock from this branch.

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

  3. Navigate to the Instructor Dashboard of a course using the Feedback XBlock.

  4. Click the Feedback tab — it should render without errors.

Testing Results After Fix:

Screenshot 2026-04-14 at 12 41 24 PM

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Apr 14, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @salman2013!

This repository is currently unmaintained.

🔘 Find a technical reviewer To get help with finding a technical reviewer, reach out to the community contributions project manager for this PR:
  1. On the right-hand side of the PR, find the Contributions project, click the caret in the top right corner to expand it, and check the "Primary PM" field for the name of your project manager.
  2. Find their GitHub handle here.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.81%. Comparing base (d4ad4ac) to head (aeeb453).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/feedback/utils.py 86.36% 1 Missing and 2 partials ⚠️
src/feedback/extensions/filters.py 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 80.81% <93.54%> (+1.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@salman2013 salman2013 changed the title Fixed the lms link imports to avoid a runtime error Fix the Instructor Dashboard crash caused for feedback xblock Apr 14, 2026
@salman2013
salman2013 requested a review from kdmccormick April 14, 2026 08:02
@kdmccormick
kdmccormick requested a review from feanil April 14, 2026 13:26

@kdmccormick kdmccormick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for porting the fix over! I have one request, but if you agree with it, then this is good to merge 👍🏻

Comment thread src/feedback/utils.py Outdated
Comment on lines +20 to +25
try:
# pylint: disable=import-outside-toplevel
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration

except ImportError:
return None

@kdmccormick kdmccormick Apr 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Suggested change
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with your suggested changes and have updated the code accordingly. Thanks.

@kdmccormick
kdmccormick removed the request for review from feanil April 14, 2026 13:42
Base automatically changed from salman/feedbackblock to main April 14, 2026 14:31
@salman2013
salman2013 merged commit f58d4d1 into main Apr 15, 2026
7 checks passed
@salman2013
salman2013 deleted the salman/feedbackblock-fix branch April 15, 2026 08:06
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feedback tab in Instructor Dashboard breaks due to indirect import of unregistered app in Sumac+

3 participants