openedx / openedx/frontend-app-authoring

Bugs with image URLs in Course Overview, including spurious "You've made some changes"

Open
#2,668 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
17
Forks
218
Avg merge
9d 20h
Merged PRs (30d)
20

Description

  1. The default "Course Overview" template (in overview.yaml) includes an image with the URL /static/images/placeholder-faculty.png (which gets served from the LMS (?) - http://local.openedx.io:8000/static/images/placeholder-faculty.png).
    • Bug: clicking on the editor or making any changes will trigger replaceStaticWithAsset() and change this URL to a course-specific URL that doesn't actually exist, making the image broken:

https://github.com/user-attachments/assets/72699c2b-2f54-4dc4-81f2-93b966b977e3

  1. It appears that we allow "Studio URLs" like /static/uploaded_image.png to be in the Course Overview field, but as soon as you make any edits to the HTML, they will be rewritten to /asset-v1:Org+Course+Run+type@asset+block@uploaded_image.png which will work only as long as the course ID is not changed. * Bug: If the course is imported onto a different instance with a different course ID, this URL will no longer work. The HTML editor should not actually change the URL in the HTML, and keep it as /static/foo even if it is actually served from a different URL during editing/preview.
  2. Because of replaceStaticWithAsset(), any course using either the default course overview template (1, above) or custom HTML with Studio URLs (2, above - /static/foo from "Files & Uploads") will have a bug.
    • Bug: "You've made some changes" will appear on such courses on the "Schedule & Details" page even if no changes have yet been made, because the URL rewriting has changed the HTML.
      Image

Test / Reproduction Instructions.

  1. First, disable the replaceStaticWithAsset function so it just return false; immediately. This is just to allow you to make the changes in step 3 correctly.
  2. Next, upload an image called "example.jpg" to a course, using the "Files & Uploads" page.
  3. Finally, from the "Schedule & Details" page, use the "HTML" toolbar button to set the course's "Course Overview" HTML to the following (change the two BradenX+XBT+24 parts to the correct course ID!):
<section class="about">
    <p>Here is an image from <code>overview.yaml</code>:</p>
    <p><img src="/static/images/placeholder-faculty.png" align="left" alt="Image #1" style="max-width: 200px;" /></p>
    <p>Here is an image from the course, using Studio URL:</p>
    <p><img src="/static/example.jpg" align="left" alt="Image #2" style="max-width: 200px;" /></p>
    <p>Here is an image from the course, using full web URL:</p>
    <p><img src="http://local.openedx.io:8000/asset-v1:BradenX+XBT+24+type@asset+block@example.jpg" align="left" alt="Image #3" style="max-width: 200px;" /></p>
    <p>Here is an image from the course, using partial web URL:</p>
    <p><img src="/asset-v1:BradenX+XBT+24+type@asset+block@example.jpg" align="left" alt="Image #4" style="max-width: 200px;" /></p>
</section>
  1. Restore the original replaceStaticWithAsset code.
  2. Refresh the "Schedule & Details" page. Note that some images will be broken. To fix the bug, no images should be broken, and no "You've made some changes" should appear.

Notes

Make sure that any fixes here don't introduce regressions into the WYSIWYG editor / URL features used for problems and text components, in both courses and libraries.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with replaceStaticWithAsset in src/editors/sharedComponents/TinyMceWidget/hooks.ts and reproduce the Course Overview cases using the issue's HTML and image-upload steps. Check overview.yaml and the Schedule & Details editor behavior. Done means images remain usable, no spurious "You've made some changes" appears, and WYSIWYG URL behavior for problems and text components is not regressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.