openedx / frontend-lib-content-components

[Moved to openedx/frontend-app-course-authoring] A library of high-level components for content handling (viewing, editing, etc. of HTML, video, problems, etc.), to be shared by multiple MFEs.
GNU Affero General Public License v3.0
11 stars 33 forks source link

fix: removal of content after problem type tags #479

Closed KristinAoki closed 5 months ago

KristinAoki commented 5 months ago

JIRA Ticket: TNL-10674

Reporting that a pre-existing problem containing a linked image is missing when they go to edit the problem in the visual editor, and also missing if they switch to the advanced editor.

This PR fixes the intermittent problem where there is OLX after the problem type tags, (multiplechoiceresponse, numericalresponse, etc.) for simple problems. Currently the parser will some times put the OLX inside the question section; other times the parser will remove the OLX. When the OLX is removed, the user switches to the advanced editor expecting to see it, but it is not present. This PR updates the parser to check if there is OLX content after the problem type tags, and if found, redirect to the advanced editor. This change removes the possibility that previous OLX will be blindly removed and that content will be rearranged blindly.

Testing

  1. Create a new problem block
  2. Choose one of the simple problem types
  3. Add content to the problem
  4. Click "Show advanced settings"
  5. Click "Switch to advanced editor"
  6. Before the closing problem tag (</problem>) add <p>content after problem type tags</p>
  7. Click "Save"
  8. Click "Edit" for the problem that you just created
  9. Should automatically open the problem in the advanced editor
  10. Remove <p>content after problem type tags</p>
  11. Click "Save"
  12. Click "Edit" for the problem that you just created
  13. Should automatically open the problem in the visual editor
KristinAoki commented 5 months ago

@jesperhodge I think your proposed solution makes sense. I think that is what we were trying to do initially, but as new visual editor exceptions appears, we re-oriented the code to look for the exceptions.