Category creation using trigger in mysql

Category creation using trigger in mysql

by haru harsha -
Number of replies: 3

I want to automate moodle system with another application database.

So i want to create course category when my application database table is filled with categories.

I have created trigger, Iam inserting values in moodle table mdl_course_categories and mdl_context , its 

getting inserted , but at UI it is not showing the created category.


Thanks in advance if anyone can help me on this

Average of ratings: -
In reply to haru harsha

Re: Category creation using trigger in mysql

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

I think you may be missing one last little piece of the puzzle, that took me hours to find when I did something similar last year smile

In one of the classes involved there is a bit around context maintenance (sorry can't remember off the top of my head where the original is). I added that code (see below) toward the end of my function (mine is in a local scheduled task plugin)

        // Context maintenance stuff.
        \context_helper::cleanup_instances();
        mtrace(' Cleaned up context instances');
        \context_helper::build_all_paths(false);

        // If you suspect that the context paths are somehow corrupt
        // replace the line above with: context_helper::build_all_paths(true).

Hope that helps


Richard

In reply to Richard Oelmann

Re: Category creation using trigger in mysql

by haru harsha -

Hi,


Iam getting course categories when i purge all the caches. But without purging, iam not getting these categories , when data is added to database through trigger.

Iam getting new course_category option in left side navigation panel where course tree is displayed.

when i went through its related files   , in there  caching clearning function was written ,



In reply to haru harsha

Re: Category creation using trigger in mysql

by haru harsha -

Hi 


Finally i got solution,

i have added this line code

   Moodle/lib/Coursecatlib.php : line 204

in constructor

    Code added: cache_helper::purge_all();