This question has been asked before - https://moodle.org/mod/forum/discuss.php?d=331304 but no answer appears to have been suggested. Since it was a while back - maybe someone has found a solution. I supposed I could do something in add_instance but I rather not let the user see the option to add the module.
You have two options here:
- Alter the addinstance function of your activity to prevent creation of new instance. User will see the module in the dialog for adding new activity.
- Create custom theme and in that theme override the course renderer method \core_course_renderer::course_section_add_cm_control since it is there where initialization of the course module list is performed. Adjust the code there to fit your purposes. Unfortunately only when using your custom theme will the user see desired behavior.
Looks like it will have to be the add_instance then Thanks Darko.