Skip to content

fix: apply library_content transformer to all ItemBankMixin xblocks#37830

Merged
kdmccormick merged 5 commits intoopenedx:masterfrom
eduNEXT:mfmz/modify-content-library-transformers
Apr 7, 2026
Merged

fix: apply library_content transformer to all ItemBankMixin xblocks#37830
kdmccormick merged 5 commits intoopenedx:masterfrom
eduNEXT:mfmz/modify-content-library-transformers

Conversation

@MaferMazu
Copy link
Copy Markdown
Contributor

@MaferMazu MaferMazu commented Dec 31, 2025

Description

This PR adds logic to the library_content transformer to support all xblocks that inherit from ItemBankMixin.

Supporting information

Specific case (The problem)

When creating a Problem Bank component, the structure of the xblock doesn't match (the user can solve 3 problems of 5), in the grade the system evaluates 5 problems when only 3 are solvable for the user.

image Screenshot in Studio of a Problem Bank Screenshot from 2026-01-06 15-59-37 Screenshot in LMS of the Problem Bank image Screenshot in Progress inside the LMS, related to the Problem Bank

Inside

The transformer didn't remove the non-selected children from the problem bank (randomized content from a content library v2 - itembankblock in the code), so the structure shows inconsistent information (more questions/grades than the user is available to see/solve)

Solution

Adding the logic to analyze the block_class and check whether it inherits from itembankmixin. I apply the same logic as the legacy library content to all xblocks with randomized content, without removing support for the legacy libraries.

Testing instructions

Pre-requisites:

  • Have a tutor environment with a master or a release greater than or equal to teak (cherry-pick the commit from this branch or use this branch if you are using master)
  • Have a course, and in Settings > Scheduled & Details, verify the course start date (use an old date, for example, 2020)
  • Configure grading Settings > Grading.

Test:

LegacyLibraries

  1. Create a Legacy Library (in Studio, click Legacy Libraries, and then +New Library) and add some problems for testing.
  2. In a course, add a subsection, and then a unit, and then a "Legacy Library" component. (configure grade to the subsection)
  3. Edit the "Legacy Library" component to use the library created, and if you want, you can configure how many problems are going to show to the student.
  4. Publish the content.
  5. Click view live version.

Things to verify in LMS (with the live version or a student account):

  • In the outline, the section shows the correct number of questions.
  • In the progress page, in the detailed grades, you should only see the gradable XBlocks available.

ProblemBank

  1. Create a Content Library (in Studio, click +New Library) and add some problems for testing.
  2. In a course, add a subsection, and then a unit, and then a "Problem Bank" component. (configure grade to the subsection)
  3. Add components to the "Problem Bank", and if you want, you can configure how many problems are going to show to the student.
  4. Publish the content.
  5. Click view live version.

Things to verify in LMS (with the live version or a student account):
The same from the LegacyLibraries

Another Xblock (optional)

  1. Install an Xblock that inherits from ItemBankMixin (for example, https://github.com/eduNEXT-collab/xblock-exam-question-bank)
  2. Activate the plugin in the course https://github.com/eduNEXT-collab/xblock-exam-question-bank?tab=readme-ov-file#enabling-the-xblock-in-a-course
  3. In a course, add a subsection, and then a unit, and then an "Advanced" component, and select the custom XBlock. (configure grade to the subsection)
  4. Publish the content.
  5. Click view live version.

Things to verify in LMS (with the live version or a student account):
The same from the LegacyLibraries

Screenshots

Base
image
Problem Bank Configuration (to show 1 of 4 problems)

Before
image
Problem Bank in LMS (problem: in the sidebar bar, it shows we had four problems available when we have 1)

After
image
Problem Bank in LMS (It shows we have 1 question) ✅
image
Progress in LMS (In the grade details, we have the correct information) ✅

@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Dec 31, 2025

Thanks for the pull request, @MaferMazu!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 31, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Dec 31, 2025
@MaferMazu MaferMazu force-pushed the mfmz/modify-content-library-transformers branch 3 times, most recently from f3c61ae to 2682a9a Compare January 2, 2026 17:15
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jan 5, 2026
@MaferMazu MaferMazu force-pushed the mfmz/modify-content-library-transformers branch 3 times, most recently from 95561fb to 8090f8a Compare January 6, 2026 20:12
Copy link
Copy Markdown
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! It seems like an important bug to fix, and I appreciate the clear description and diagnosis. I did some testing just now and can confirm the bugs you're seeing. I haven't tried this fix out yet, but it seems right to me.

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Jan 23, 2026
@MaferMazu MaferMazu force-pushed the mfmz/modify-content-library-transformers branch 2 times, most recently from f824b52 to 68a362d Compare February 3, 2026 17:37
@MaferMazu
Copy link
Copy Markdown
Contributor Author

@bradenmacdonald, thanks for reviewing this and for your patience. I just answered your feedback. I'm attentive to further feedback. ✨

@kdmccormick
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Very important fix, thanks for finding and fixing it @MaferMazu ! The manual testing instructions look great too. I just have a suggestion on how we could simplify the implementation.

@bradenmacdonald
Copy link
Copy Markdown
Contributor

I think this PR should be good to go once you've addressed @kdmccormick's comment. Let me know if you want any further review or testing from me.

@bradenmacdonald
Copy link
Copy Markdown
Contributor

@MaferMazu Will you be able to finish this up soon?

Also note to self: once we've merged this, we need to look into https://discuss.openedx.org/t/teak-and-ulmo-completion-checkmark-green-tick-disappears-on-refresh-for-randomized-problem-bank-xblock/18420/3 and see if it's fixed or not.

@felipemontoya
Copy link
Copy Markdown
Member

@bradenmacdonald mafe is on PTO and she will be back after next week. I'm sure she can take it on then.

@MaferMazu MaferMazu force-pushed the mfmz/modify-content-library-transformers branch from 68a362d to 5d0a030 Compare April 6, 2026 20:43
@MaferMazu MaferMazu requested a review from kdmccormick April 6, 2026 23:55
@MaferMazu
Copy link
Copy Markdown
Contributor Author

MaferMazu commented Apr 7, 2026

Thanks for your patience ✨
@kdmccormick, this is ready for a re-review. I applied your suggestion and also added tests for 'itembank' (the new problem bank). Please let me know if there is anything I can improve.

cc @bradenmacdonald

Btw, regarding #38027, and https://discuss.openedx.org/t/teak-and-ulmo-completion-checkmark-green-tick-disappears-on-refresh-for-randomized-problem-bank-xblock/18420. I replicate the behavior, and it seems fixed (create a problem bank, with 3 problems and set to show 2, and when the student finished the 2 problems, the green mark persisted)

Video demo (the important part is from 1:30, the rest was the setup)

Screencast.from.2026-04-06.19-04-17.webm

Copy link
Copy Markdown
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Thank you Mafer!! 🚀

@kdmccormick kdmccormick merged commit 42e4e0d into openedx:master Apr 7, 2026
48 checks passed
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Apr 7, 2026
@kdmccormick
Copy link
Copy Markdown
Member

Here's a backport, ready for review: #38296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants