Creating a chat using SQL

Creating a chat using SQL

by Guilherme Estevão -
Number of replies: 3

Guys I am developing a method (JAVA) where I create a chat room just by entering values ​​in the database and moodle to make use Hibernate persistence en

What is being done:

1st I have to insert some values ​​in the table "mdl_chat" prenchendo fields (id, course, name, intro, introformat, timemodified and chattime). This table stores information more specific this module (chat) as name, course, hours of chat and etc..

2nd one should fill the table "mdl_course_modules" with (id, course, module, instance, section, added) This table is a bit more generic as it is stored all modules (forums, wikis, questionnaires, etc.), more the main objective of it is information on what topic, and this course module is stored.

3rd and finally I persist the table "mdl_context" with (id, contextlevel, instanceid, path, depth) the focus of this table is basically tells moodle determonado the path to a module:

What is missing:

I have done tests to see what tables are filled in the bank to be inserted into a module in moodle and cheguri the 3 tables mentioned, when I run my script all the information go to the bank through methods "setNomeDoCampo (parameter)" in the same way that go when some activity is added manually (activate by clicking dition and then click Add an activity or resource) but moodle does not list on the screen of the module course activities (chat) that was persisted with my code obviously only lists created manually .

I wish someone would help me with this problem iserir one chat using sql commands.

I thank the help

Average of ratings: -
In reply to Guilherme Estevão

Re: Creating a chat using SQL

by Jitendra Gaur -

Hi,

To insert/create chat activity directly from database you need to insert into following tables -

course_id = (course id where you want to create a chat activity )
chat_id = (inserted id of chat table)
module_id (inserted id of course_modules table)

INSERT INTO `mdl_chat` SET course = course_id, name = 'test1', intro = 'intro test1'
INSERT INTO `mdl_course_modules` SET course = course_id, module = (SELECT id FROM `mdl_modules` WHERE name = 'chat') ,instance = chat_id , visible = 1, showavailability = 1
INSERT INTO `mdl_course_sections` SET course = course_id, section = 1, sequence = module_id

and reset the section cache in course table

UPDATE `mdl_course` SET `sectioncache` = NULL WHERE id=course_id;

Thanks & Regards,

Jitendra Gaur

In reply to Jitendra Gaur

Re: Creating a chat using SQL

by Guilherme Estevão -

Thank you for your help, especially the part where I have to clear the cache of the course, it was very helpful to me

Thanks Jitendra Gaur