Where are HTML blocks stored?

Where are HTML blocks stored?

Brian Jones -
Кількість відповідей: 3
Hi,

I hope this is an easy one. I just need to know: when a teacher adds an HTML block to their page, where is the HTML actually stored? I thought it would be in the database somewhere, but I can't find it, and I didn't see anything new under $MOODLEHOME/blocks either.

The higher-level view of my problem is this: a teacher has created a custom "links" block, and wants that block to be imported along with the other settings of last semester's class, so I need to find where/how custom HTML blocks are stored so I can write the code to make the import happen as expected. If I've missed something, by all means, flame away! підморгую

brian.
У відповідь на Brian Jones

Re: Where are HTML blocks stored?

Jan Dierckx -
The data for each block (including the HTML block) is serialized, then base64encoded and stored inside the configdata field of the mdl_block_instance table.

That's why it will be hard to write a mysql query to backup/restore a lot of HTML blocks at once.

If you know PHP you can use

unserialize(base64_decode($instance->configdata))

to get at the real values.
У відповідь на Jan Dierckx

Re: Where are HTML blocks stored?

Brian Jones -
Thanks for the information! I wonder if I couldn't do something using SQL to copy the data over, like INSERT FROM, for instance. Also, if all I'm doing is copying the data over, why do I need to decode it at all? I know PHP, but I'd rather have the database do it if I can. I'll report my results, but any thoughts are, of course, welcome.

What would be really wonderful is if the data model enabled a many-to-many relationship between block instances and course instances, but the overall app design doesn't seem to really account for that. Alternatively, associate a user-created block with the *user* instead of the *course*, so that teachers in charge of more than one course can go to their own block toolbox and drop in things without having to recreate them.

Well, that's a topic for another post I guess.
Thanks a bunch!
brian.