Is there a built-in-Moodle way to fetch the course module ID from the module instance ID (stored in my internal module table)? I'm running an ad-hoc task which sends a notification to a user. I'd want to add a link in the notification to the current module instance (
) but I cannot see how to get it easily as I only have the module instance ID while running the ad-hoc task.
I'm looking for kind of the opposite of:
$cm = get_coursemodule_from_id('tupf', $coursemoduleid);
$course = $DB->get_record('course', ['id' => $cm->course]);
$moduleinstance = $DB->get_record('modulename', ['id' => $cm->instance]);
A workaround would be to store the course module ID in my internal module table on
lib.php but this is far from ideal.
Thanks for your help!