Simon-Initiative / course-digest

Tool to produce a summary or digest of OLI course package contents
MIT License
2 stars 0 forks source link

[ENHANCEMENT] DND Fixes: strip id-qualified styles; handle images in layout [MER-2518][MER-2519] #196

Closed andersweinstein closed 1 year ago

andersweinstein commented 1 year ago

This fixes two DND issues blocking migration of the PC Hardware/Software/Concepts of Computing course family:

  1. The style sheets use element-id-qualified styles of the form
#dpch01_lbd08 table, #dpch01_lbd08 th, #dpch01_lbd08 td {
                border: 1px solid black;
           ...

These ids are not used on any parent element in the torus implementation, so these styles have no effect, preventing the implementation from working at all (e.g. target table cells wind up having zero height.)

This has digest tool detect and strip these ids from stylesheets. Detection by regex match relies on heuristic, the presence of an underscore, to distinguish #ids from hex color specs of the form #ffe that may also occur within the stylesheet string. Adequate for the cases we have to deal with.

Also strips "all: initialize" which same stylesheets often included, since it causes problems.

  1. PCHW course uses DNDs in which draggables ('initiators') are images, not text, and also includes static images in some layout tables ('targetArea's). Digest tool was not processing image references in either of these locations, so these images were not getting included in the media library and relative references to webcontent were not rewritten in these contexts. This change adds this processing for these image refs. Also ensures images in the layout are non-draggable, necessary to ensure click on image drags the containing div with its magic id.

Test case from PCHW exercising both added to migration test course.