0

I'm currently building a new moodle plugin. I'm using add_moduleinfo and update_moduleinfo. To add a new attandance atictivity in a course and update it later on.

Sadly I'm facing the issue that update_moduleinfo always throws an "invalid course module id" error. I already checked the cm entry in my database to ensure im using the right module instance.

I dont really know what to do.

            $cm = get_coursemodule_from_instance($moduleName, $activityID, $course->id);
            $moduleinfo = update_moduleinfo($cm, $moduleinfo, $course); <-- Error

Thats how I try to update the entry.

I also found that post. Didn't help anything. Moodle - Invalid course module ID

maxi hraschan
  • 153
  • 12

1 Answers1

0

I found the issue myself:

$moduleinfo->introeditor['format'] = FORMAT_HTML;
$moduleinfo->introeditor['text'] = "INTRO TEXT";
$moduleinfo->coursemodule = $cm->id;

list($cm, $moduleinfo) = update_moduleinfo($cm, $moduleinfo, $course, null);

In order to use this function the above mentioned properties need to exist in order to perform a update.

maxi hraschan
  • 153
  • 12