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

  1. On site A, create a course with at least one lesson and one activity.
  2. Export it and import the archive on site B. The course is created correctly.
  3. Back on site A, change something visible: the course title, a lesson body, an activity question.
  4. Export the course again and import the new archive on site B.
  5. 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.
CommentFileSizeAuthor
#6 lms_yaml-overwrite-content.png40.19 KBalbeorte

Issue fork lms_yaml-3616283

Command icon 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

albeorte created an issue. See original summary.

albeorte’s picture

Issue summary: View changes
albeorte’s picture

Issue summary: View changes
albeorte’s picture

Issue summary: View changes

albeorte’s picture

StatusFileSize
new40.19 KB

Changes have been made to allow users to select the option to overwrite the content if it already exists.

Overwrite checkbox

Ready to check! https://git.drupalcode.org/project/lms_yaml/-/merge_requests/3

albeorte’s picture

Status: Active » Needs review
albeorte’s picture

Version: 1.0.0-beta2 » 1.0.x-dev
graber’s picture

Should 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.

albeorte’s picture

If possible, please include it in version 1.0.x until version 2.0.x is finalized.

Thank you!

  • graber committed 8c73cb16 on 1.0.x authored by albeorte
    #3616283: Allow re-importing a course over an existing one (optional...
graber’s picture

Status: Needs review » Fixed

Committed. 2.0.x has a beta release now, 1.0.x will receive minimal support.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.