LMSouq
moodle-core Open

Create Moodle activities programmatically

CH
Christos312
1 month ago
3 views
Problem Description
Does anyone know if it’s possible to add an activity programmatically to a course in Moodle? I was thinking to maybe use the class `module_add_instance()` from the lib.php of my custom plugin... e.g. function feedback_add_instance(stdClass $mod) { global $DB; $newmodule->timecreated = time(); // You may have to add extra stuff in here. $newmodule->id = $DB->insert_record('exams', $newmodule); unicexams_grade_item_update($newmodule); return $newmodule->id; } But then again: What is the `$mod` variable? What does it contain and how to construct it? Does anyone has knowledge on the subject? Or something to advise?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base