Databases: courses and modinfo

Databases: courses and modinfo

by Jalil K -
Number of replies: 2

Hi Guys,

Im importing data from my courses database into Moodle. So far Ive populated the fields that I need - however there is one which I dont quite understand. Can anyone explain what the modinfo field should have inside it?

Are there any fields that *SHOULD* have a value in them.... Ive populated the fields witht he red astrixes

Thanks

Average of ratings: -
In reply to Jalil K

Re: Databases: courses and modinfo

by Jalil K -

Right, been reading through quite a few threads in the forums and the modinfo seems to quite clearly be an important field. As far as I can see it is what determines what "options/navigation" comes up on the left or the right of that course.

Can anyone out there please help me understand the values I need to put in this field. Do I also need to populate the mdl_context and mdl_context_rel fields as well. Ive got my course data populated, works great. When I log in as the admin to one of my courses I need to get the options on the left hand side which allow me to check participants forum etc.

I have an example of a course generated from Moodle:

a:1:{i:1;O:8:"stdClass":6:{s:2:"cm";i:1;s:3:"mod";s:5:"forum";s:7:"section";s:1:"0";s:4:"name";s:10:"News+forum";s:7:"visible";s:1:"1";s:5:"extra";s:0:"";}}

What does this all mean, and do I need everything...even tried to copy and paste this data into the other courses but bit had any luck displaying the options.

Many Thanks to anyone that replies

In reply to Jalil K

Re: Databases: courses and modinfo

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Jali,

the course->modinfo field contains one "summary" of all the activities in the course. It's a serialised array of data and it's used to get some important information (visibility, groupmode, sections..) and it's used to render the course main page faster.

From your posts above it seems that you are, manually, creating courses and adding sections and activities to them.

If everything has been properly populated, all you have to do, in php is to execute the function:
rebuild_course_cache($courseid)
(where $courseid is the id field of the course that you've created.

Once executed, the course->modinfo will contain the required information and all the activities will appear ok in the course.

But remember that everything (course_modules, course_sections, activity tables...) have to be properly and coherently in place before calling such function.

Ciao smile