Hello Amir,
You need to give the course module id from the mdl_course_modules table in the situation listed above.
You can run the following query to get the course module id that you want:
SELECT cm.id AS "course module id", l.id AS "lesson id"Best of luck with your plugin.
FROM mdl_course_modules cm
JOIN mdl_modules m ON cm.module = m.id AND m.name = 'lesson'
JOIN mdl_lesson l ON cm.instance = l.id
WHERE l.id = 4 -- Change the 4 here to the lesson ID that you want.