Problem/Motivation
A course exported from one environment and imported into another cannot be updated through a subsequent import. Once the course exists on the destination site, re-importing a file containing changes
has no effect: the course, its lessons, and its activities remain exactly as they were.
A course exported from one environment and imported into another cannot be updated through a
subsequent import. Once the course exists on the destination site, re-importing a file containing changes
has no effect: the course, its lessons, and its activities remain exactly as they were.
Furthermore, the user is not notified of anything. The import reports that it was successful and displays the number of items it processed, so there is no way to distinguish between what was "imported" and what was "skipped". Users naturally assume that their changes have been applied.
Currently, the only solutions are to delete the course, its lessons, and its activities from the destination site before importing—which also results in the loss of student progress—or to manually edit the UUIDs within the file, which creates a duplicate course instead of updating the original.
Steps to reproduce
- On site A, create a course with at least one lesson and one activity.
- Export it and import the archive on site B. The course is created correctly.
- Back on site A, change something visible: the course title, a lesson body, an activity question.
- Export the course again and import the new archive on site B.
- The import reports success, but the course on site B is unchanged.
Proposed resolution
1. Add a "Overwrite existing content" checkbox to the import form, unchecked by
default. When selected, courses, lessons, and activities that already exist on the site will be updated using the file instead of being skipped, including their attachments.
Display a warning next to the checkbox, such as:
Warning: the existing content of the courses on this site will be replaced by the
content in the file. Any local changes made to the affected courses, lessons, and activities will be
lost, and this action cannot be undone.
2. Warn the user when the checkbox is unchecked, and the file contains content that already exists, rather than failing silently. For example:
The following courses already exist on this site and have not been modified:
Course A, Course B. To apply the changes from the file, re-import with the “Overwrite existing content” option enabled.
3. Report what actually happened after the import: how many entities were created,
how many updated and how many skipped, rather than just how many were processed.
Two points worth highlighting from the outset:
- Existing content should be updated in place rather than deleted and recreated, so that student
answers and progress pointing at those activities survive the import. - Lessons and activities that exist in the destination site but are no longer part of the imported course should be left alone, not deleted. They stop being referenced by the course, but deleting them would destroy student data.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | lms_yaml-overwrite-content.png | 40.19 KB | albeorte |
Issue fork lms_yaml-3616283
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
albeorte commentedComment #3
albeorte commentedComment #4
albeorte commentedComment #6
albeorte commentedChanges have been made to allow users to select the option to overwrite the content if it already exists.
Ready to check! https://git.drupalcode.org/project/lms_yaml/-/merge_requests/3
Comment #7
albeorte commentedComment #8
albeorte commentedComment #9
graber commentedShould be handled in 2.0.x now as a part of the referenced issue, I can merge your solution to 1.0.x if you like too. 1.0.x will be unsupported soon.
Comment #10
albeorte commentedIf possible, please include it in version 1.0.x until version 2.0.x is finalized.
Thank you!
Comment #12
graber commentedCommitted. 2.0.x has a beta release now, 1.0.x will receive minimal support.