Skip to content

fix(create): persist and display Demo and Module item ordering #182

Description

@kbuffardi

Problem

Reordering exercises in the Demo editor must persist and display in the configured top-to-bottom order. Module resource selection must support adding several resources into a visible draggable list, preserving its top-to-bottom order across save and reload.

Scope and approach\

Demo exercises

  • Retain the existing DemoExercises.order schema and update behavior; no new Demo ordering model or migration is needed.
  • Ensure the learner-facing GET /api/demos/:uid/attempt query orders exercises by DemoExercises.order ASC.
  • Verify the existing Demo editor drag state is submitted as the ordered exercise-ID array and is restored after saving and reopening.

Module resources

  • Add an ordering column to ModuleResources, with a deterministic backfill.
  • Introduce/register an explicit ModuleResources join model and use it for the Module-Resource association.
  • On module creation and update, persist each resource association using the submitted resource-ID order.
  • Apply resource ordering to every relevant read path: module create/update reloads, module GET/list, course/student-course payloads, and the module-resource SQL used by the Demo attempt endpoint.
  • Replace the Module form’s multiselect presentation with a cleared single-select picker and visible selected-resource rows below it. Exclude already selected resources, allow removal, and reuse the existing @dnd-kit sortable interaction for top-to-bottom reordering.
  • Correct the Module draft type so its resource state is ordered IDs (or equivalent selected-item data), removing the existing Resource[]/ID mismatch and @ts-ignore workarounds.

Acceptance criteria\

  • Dragging and saving a Demo’s exercises preserves that order when reopening its editor and on the learner Read view
  • A Module user can select multiple resources one at a time; each appears below the selector, can be removed, and can be reordered by drag-and-drop.
  • Saving and reopening a Module retains the configured resource order.\n- [ ] Module resources are returned in that order from all affected API/read paths.
  • Tests cover persisted/retrieved API ordering plus Demo and Module editor interactions.

Verification

  • API tests for Demo attempt exercise order and Module resource order after update/reload.
  • Component or Cypress coverage for Demo drag-save-reopen and Module multi-select, reorder, save, and reopen.
  • Run the relevant test suites and production client/API builds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions