Courses table manipulation - any gotcha's?

Courses table manipulation - any gotcha's?

by Sjan Evardsson -
Number of replies: 2

Here at Alaska Pacific University we are in the process of tying our Student Systems software (Datatel) to our Moodle implementation. So, for each term, whenever a course is created in Datatel, the course is created in Moodle with the startdate set to match the start date for that term.

I have added a table (mdl_terminfo) which contains the term (a varchar to hold the Datatel representation of the term, something like FA1.04), the startdate (as a date) and the enddate (as a date).

I have added a table to link the course id to the term, and then decide from there what needs to be deleted.

Because the connector and its associated pieces are in Java, the connector will be talking to the database directly. This, in itself is not a problem. However, I am concerned about row deletions from the mdl_courses table. If I delete a row directly, what kind of garbage am I missing? I am still trying to get a grasp on the coding style used in the Moodle app and am finding it difficult to grok exactly what happens when, from the site I delete a course.

Any insight would be helpful.

Thanks in advance!

Average of ratings: -
In reply to Sjan Evardsson

Re: Courses table manipulation - any gotcha's?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Are you talking about modifying tables directly from your Java application on a live Moodle system? Bad plan surprise That's one of those things you get away with for ages and then get really weird errors when you least need them.
In reply to Sjan Evardsson

Re: Courses table manipulation - any gotcha's?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
You should be fine when adding courses this way, but when you delete a course record you will be left with a lot of orphan data floating around the database.

See the function remove_course_contents() in lib/moodlelib.php