how to get Course id (by DB)

how to get Course id (by DB)

by Francesco Pisano -
Number of replies: 2

Hello,

  I would like to insert in the sourse code (i think in format.php) of the "topics format" a string that get the course id and write it in every (or in only one) topic description.


Anyone can help me?


I'm using moodle 3.4.


Thank you,

 Francesco

Average of ratings: -
In reply to Francesco Pisano

Re: how to get Course id (by DB)

by Dom Royko -
Picture of Plugin developers

Are you sure you want to do that?  I just want to make sure we're talking about the same thing, because a Moodle database id for a course is going to be of very limited use to a typical Moodle user.

If all you want to know is the id of a course when you're looking at the UI, you can check that in the URL (if it's visible) which will take the form ".../course/view.php?id=...".

If you do want to edit the source, you will likely be looking at a particular format renderer, or the default renderer in course/format/renderer.php.

Maybe those hints will point you a little further along.


In reply to Dom Royko

Re: how to get Course id (by DB)

by Francesco Pisano -

Hi Dom!


Yes, I'm sure.

Because I have to develop a new course format plugin.

I have to automaticlly modify db after course creation and I think will be necessay to know (and use) the course id for the update of the db values.


I will develop a format course that automatically set restrict access on creation.


Have you got any advice?


Thank you