id's not matching up

id's not matching up

by jonathan Mc Namee -
Number of replies: 3

Hi all,

I'm developing a tutor feedback system for moodle, and have a problem with id's not matching up. for example, when the tutor feedback is sending data back to be processed, it also includes the $id variable to identify the module instance, so I can record what instance the data belongs to. however, when I go to say, delete the module, I reckoned all i'd have to do was put an sql query in the delete_instance() function, and i could use this to clear any instance information from my tables. however, the $id provided here is different!

where I'd be expecting a value like 86, I'd get a value like 74!

I haven't been using the get instance functions, as I could get by til now with just the $id variable.

could someone post whatever code I need to get back the 'proper' $id so I can tie the Tutor_feedback instances to my tables?

Jonathan

Average of ratings: -
In reply to jonathan Mc Namee

Re: id's not matching up

by Gustav W Delius -
Every table in the Moodle database has its own id field. I am not quite sure what you are trying to do but I suspect what is confusing you is that when you create an activity there are two id numbers created, one for the course_modules table and one for the table that holds the information about the instances of the particular type of module. So for example a newly created forum will show up with one id in the forum table and with a different one in the course_modules table. The 'instance' field of the entry in the course_modules table gives you the id of the entry in the course_modules table. Maybe that answers your question?
In reply to Gustav W Delius

Re: id's not matching up

by Ray Kingdon -
Yes, Gustav has hit the nail on the head big grin. If you have a look at mod/assignment/view.php it can deal with either the module id or the course_module id (coming into it). Nice but in my view a bit over the top. In my modules I just pass the course module id, see for example mod/dialogue/view.php. So when you call the next page you have to use the course module id. It keeps things a bit simpler (and straightforward) and I'm all for that wink.
In reply to Ray Kingdon

Re: id's not matching up

by jonathan Mc Namee -

yeah, I got a hand with it this morning, (thanks una!). Instead of using $id, I use this:$test = get_record("course_modules","id",$id);

and then insert $test->instance instead of $id wherever needed.

all working fine now!!

thanks for your help,

Jonathan