Error with course creation - course ID is empty.

Created on 23 June 2025, about 1 month ago

Problem/Motivation

I have a course content-type created that satisfies the basic fields requirements for a moodle course. When I try to create a new Course entity, I see this error :

Error creating Moodle course for Drupal entity. No course was created.
Error: @"exception":"core\\exception\\moodle_exception","errorcode":"invalidcourseid","message":"You are trying to use an invalid course ID"

Params: @"courseid":"5","categoryid":"5","fullname":"Test Course","shortname":"test-101"

(function: core_course_duplicate_course, params: @"courseid":"5","categoryid":"5","fullname":"Test Course","shortname":"test-101")

I have a field (i have tried plain text and integer) created for the content-type, machine name: field_moodle_id

I'm not clear on how this field is completed. My understanding was that Moodle would write back its course ID to complete this field.

Thanks for any guidance.

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States goose2000

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @goose2000
  • πŸ‡ΊπŸ‡ΈUnited States goose2000

    A bit more work and I was able to discover that the moodle_sync_template needed to enabled too, for any of this to work. I realized the

    function: core_course_duplicate_course

    was being called too, so to duplicate a course, if a template was being used. Think it works as designed, just a bit more documentation could be helpful. Both moodle_sync_course and moodle_sync_template should be enabled and configured.

Production build 0.71.5 2024