Get correct id in lesson activity link.

Get correct id in lesson activity link.

by Amir Mustafa -
Number of replies: 2

Hello Friends,

In the plugin I need to put the lesson activity link. At first I though that is the lesson id and gave it. But I am getting errors.

Lesson y is there  with id 15 in the mdl_lesson table in the moodle database.

Please guide me.

Attachment 1.png
Attachment 2.png
Average of ratings: -
In reply to Amir Mustafa

Re: Get correct id in lesson activity link.

by Adrian Greeve -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers

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"
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.
Best of luck with your plugin.

Average of ratings: Useful (1)
In reply to Adrian Greeve

Re: Get correct id in lesson activity link.

by Amir Mustafa -

Thank you Adrian

Your solution worked like a charm smile smile