Hello,
I have a problem in my Organization, we have a Moodle (2.9 and 3.2) with online courses and we need to remove completed or dropped enrollments from our moodle site/courses, but also we need to keep records of all enrollments, completions and group membership, for reporting (quarterly, yearly or ad-hoc).
For that reason I got idea to create copy of Moodle original tables in the same database (live Moodle). For example for enrol (original table) I made xenrol (copy of original table, with less fields), and for course (original table) I made xcourse (copy of original table, with less fields). I also made user_enrolments, groups, groups_members, course_completions, and for user I don’t need a copy, as also for grades (grades_grades_history), and certificates (there is a plugin for keeping cetificates).
After that I created a trigger on the after insert event on original course table (and similar on other tables).
DELIMITER $$
CREATE TRIGGER writetoxcourse
AFTER INSERT
ON m320_course FOR EACH ROW
BEGIN
INSERT INTO m320_xcourse (xid, xcategory, xfullname, xshortname, xidnumber, xstartdate, xenddate, xgroupmode, xgroupmodeforce, xtimecreated, xtimemodified)
VALUES (id, category, fullname, shortname , idnumber, startdate, enddate, groupmode, groupmodeforce, timecreated, timemodified);
END$$
DELIMITER ;
However, when I try to create new course, I get error from Moodle (same with other tables), and when I remove trigger from course table everything is functioning normally.
Idea of make copies of the tables in same database coming from simplicity of accessing and doing reports from standard “Configurable Reports” or “Ad-hoc”.
Maybe someone will write local plugin with this “Mini SYS in Moodle” in the future, but we need solution now (our funding depends on reporting), please help.