Skip to main content

Import into an existing course

By default, Course Creator AI always creates a new course from the approved plan. Administrators can also allow course creators to import the generated content into an existing course instead. This page explains how to enable the feature, what each setting does and which permissions users need.

info

This feature is available from Course Creator AI 2.0.8. It is disabled by default.

How the import works​

When a user imports into an existing course (the target course), the plugin does not modify the target course directly. Instead:

  1. The AI generates the course as usual, as a temporary course in the target course's category.
  2. The target course is copied with all its user data: enrolments, role assignments, groups, grades and the user data of its activities.
  3. The copy takes the original full name, short name and category. It is a new course, so it has a new course ID.
  4. The original course is kept as a hidden backup and renamed with a timestamp: the short name gets a .<timestamp> suffix and the full name gets a (<timestamp>) suffix. For example, MATH101 becomes MATH101.1760961234 and Mathematics becomes Mathematics (1760961234).
  5. The generated content is imported into the copy, according to the Import content mode setting.
  6. The temporary generated course is deleted.

If any step fails, the copy is deleted and the original course is restored with its original names and visibility. The generated course is kept so the user can still open it from their creation session. A failed import is never retried automatically.

warning

Because the copy has a new course ID, links or integrations that point to the original course ID (for example, bookmarked URLs or external systems that store course IDs) will point to the hidden backup, not to the imported course.

Enable the feature​

  1. Log in to your Moodle site as an administrator and go to Site administration > Plugins > Local plugins > Course Creator AI > General settings.
  2. Check Allow importing into an existing course.
  3. Choose the Import content mode and Import execution options described below. These two settings only appear while Allow importing into an existing course is checked.
  4. Click Save changes.

Settings​

Allow importing into an existing course​

  • Default: off.
  • When off, the course creation flow is unchanged: users can only create new courses.
  • When on, users who hold the required permissions on at least one course see a Destination selector when reviewing the course details, with the options Create as a new course and Import into an existing course. Site administrators always see it.

Import content mode​

Defines what happens to the existing content of the target course copy.

OptionWhat it doesChoose it when
Replace all existing content (default)Removes every section and activity of the copy first, so only the generated content remains. Enrolments, role assignments, groups and groupings are kept.You want the generated course to completely replace the structure of the course, for example to rebuild a course for a new term.
Keep the existing content and append the generated sections after itLeaves the original sections and activities untouched and adds the generated sections after the last existing section, each with its own name and activities.You want to extend an existing course with new AI-generated units without losing what is already there.
info

In both modes, the imported course keeps the enrolled users, their role assignments, and the course groups and groupings. Replace all existing content only replaces the course content: it removes the original sections and activities, so the data that belongs to those activities (such as their grades, attempts or submissions) is no longer in the imported course. That data stays in the hidden original course. With Keep the existing content and append the generated sections after it, the original activities and their data stay in the imported course.

Import execution​

Defines where the import runs once the AI has generated the course.

OptionWhat it doesChoose it when
In the background (cron task) (default)Queues an ad hoc task that cron runs. The creation page shows a progress card and checks the result periodically. Large courses are not affected by request time limits.Your site has cron running regularly.
In the foreground (same request)Runs the copy and the import inside the same request, so cron is not needed. The request must finish within the web server and browser time limits.Cron is not available on your site.
warning

With In the background (cron task), the import only runs when cron runs. If cron is disabled or not running, the import stays queued indefinitely and the creation page shows it as queued. The queued task appears in Site administration > Server > Tasks > Ad hoc tasks as Import an AI-generated course into an existing course. An administrator can run pending ad hoc tasks from the command line with php admin/cli/adhoc_task.php --execute.

note

With In the foreground (same request), the browser waits up to about 3 minutes for the course generation and the import to finish together. If a large course takes longer, the browser may show a connection error while the server keeps working; the real result is saved in the creation session and is shown when the user reopens it.

Import a course step by step​

Once the feature is enabled, this is what a user with the required permissions does to import generated content into an existing course:

  1. Go to My courses and click Create with AI.

  2. Define the context (syllabus or prompt, guidelines, language, images) and start the planning, as when creating a new course.

  3. Review and adjust the proposed plan, then approve it with Generate course.

  4. In the Review course details panel, set Destination to Import into an existing course.

    Below the selector, the panel shows a help text that matches the site's Import content mode:

    • Replace all existing content: The selected course is copied with its settings, participants, roles, groups and grades, and the copy keeps its names while its content is replaced by the generated course (participants, roles and groups are kept, but their grades and submissions on the replaced activities are lost). The original course is renamed and hidden as a backup.
    • Keep the existing content and append the generated sections after it: The selected course is copied with its settings, participants, roles, groups and grades, and the generated sections are added after the existing ones in the copy, which keeps its names; nothing is removed and participants keep all their data. The original course is renamed and hidden as a backup.
  5. The Course name, Short name and Category fields are hidden, because the imported course keeps the names and category of the target course.

  6. In Select the category of the target course, choose the category that contains the course.

  7. In Target course, type part of the course name or short name (Type to search courses in the selected category) and select the course. The search includes subcategories and only lists courses the user can import into.

  8. Click Create course. The button stays disabled until a target course is selected.

  9. The AI generates the course. With In the background (cron task), the Importing into the existing course... card then shows the progress, and while the import runs, Open generated course opens the course generated by the AI.

  10. When the import finishes, the card shows the result:

    • Import completed: the Open imported course button opens the course with the imported content.
    • Import failed: the original course was left unchanged, and the Open generated course button opens the generated course.

If the import takes more than about 10 minutes, the page stops checking and asks the user to open the session again later. Stopping the check does not stop the import.

For the teacher's view of this flow, see Create a course with AI.

Required permissions​

The plugin does not add new capabilities for this feature. A user can import into a course only when they can already create courses with AI and hold all the following core capabilities:

CapabilityContextWhy
moodle/backup:backupcourseTarget courseBack up the original course.
moodle/restore:restorecourseTarget courseRestore the copy and import the generated content.
moodle/course:visibilityTarget courseHide the original course.
moodle/backup:userinfoTarget courseInclude the user data in the backup.
moodle/course:createCategory of the target courseCreate the copy.
moodle/restore:userinfoCategory of the target courseRestore the user data into the copy.
moodle/backup:backuptargetimportGenerated courseImport the generated content into the copy.

The Destination selector is only shown to users who hold the target course and category capabilities of this set (all except moodle/backup:backuptargetimport) on at least one course, and the course search only lists courses where the user holds them. Site administrators always qualify.

The plugin creates an AI course creator and importer role that includes everything needed to create courses with AI and import them into existing courses. Assign it in the System context to the users who need this feature. See AI creator roles.

See Permissions for the full list of capabilities and the contexts where they are checked.

How roles are copied to the imported course​

The imported course is a copy restored from a backup of the original, and Moodle restores each role assignment using the roles that the user running the import is allowed to assign. A role that the user cannot assign is replaced by the closest one they can assign (for example, Teacher (editing teacher) becomes Non-editing teacher), or skipped if there is none.

  • With the AI course creator and importer role, which can assign Teacher (editing teacher), Non-editing teacher and Student, editing teachers of the original course keep their role in the imported course.
  • With a role that cannot assign Teacher (editing teacher), such as a custom role or an importer role that existed before the plugin was installed, the other editing teachers of the original course become non-editing teachers in the imported course. To avoid this, allow the role to assign Teacher (editing teacher) in Site administration > Users > Permissions > Define roles > Allow role assignments.
  • Roles with no assignable equivalent (for example, Manager assigned in the course, or custom roles without a matching archetype) are skipped: those users remain enrolled in the imported course, but without that role.
  • Site administrators can assign any role, so imports they run are not affected.