An "Export to HTML" functionality for Moodle courses included

An "Export to HTML" functionality for Moodle courses included

by Samuli Karevaara -
Number of replies: 9
Here is a block that allows you to save a Moodle course as a small web site to be used outside of Moodle. It's for Moodle 1.5, haven't tested it with 1.6.

It will only export resources such as html pages and links to files and web pages, activities will be skipped. All of the course files are packed in the export too.

It also exports all of the theme files, icons etc. so you get the course themed web pages "to go".

One caveat though: if you are using the latest 1.5, this block requires one change to the weblib.php file: In function print_header() there is a bit of code that says (around the line 1725)
    if ($headerprinted) {
return;
} else {
$headerprinted = true;
}
This prevents the header to be called twice from the same page. The export "grabs" the header multiple times for one page call, so change this bit to

    if ($headerprinted) {
return;
} else {
// $headerprinted = true;
}
It works "out of the box" for 1.5.3.

I might duplicate the print_header() functionality in the block locallib.php later to work around this.

Instructions: just include the block in your Moodle, add it to the course you want to export, and click "HTML Export" (the only thing in the block smile ). The block generates an exported HTML files in a zip file in In the course backup folder. Download and unpack the zip, and start with the "index.html" in the folder you unpacked the zip to.

If you want to export the course with a different theme, change the theme before clicking "HTML Export".

As far as I know it doesn't delete any files or kill your server, but be careful anyhow smile
Average of ratings: -
In reply to Samuli Karevaara

Re: An "Export to HTML" functionality for Moodle courses included

by Michael Goncharenko -

Hi! That's great work, very thanx!

But there's a small trouble when exporting recources with cyrillic names: file names are not set correctly then. Is it possible to make file names not resource names, but resource IDs, for example?

In reply to Michael Goncharenko

Re: An "Export to HTML" functionality for Moodle courses included

by Samuli Karevaara -
Yes, that's fixable. I'm not at my dev machine right now though so I'll try to remember to post another version later this week.

I does try to convert high-ascii to lower ascii before using the resource name as the file name, but obviously it's not working as expected then. I have to check what's going on...

Be warned that there are probably heaps of other problems too, like with embedded Flash media and so on. I only tested with web pages with pictures, course files and links to them and links to outside web pages.
In reply to Michael Goncharenko

Re: An "Export to HTML" functionality for Moodle courses included

by Samuli Karevaara -
Here is an updated version of the block, I'm calling this one "1.0" smile

Now it works with unmodified Moodle 1.5 (haven't tested with 1.6 yet). Just install it as a block, add to the course you want to "save" as HTML, and click "HTML Export".

Michael, I added an option to use id-based filenames only. No user interface this, but change "$id_names = false" to "$id_names = true" in the beginning of the file "block_html_export_action.php" to switch to numerical file names only. This applies to the files generated from the resources automatically only, all of the attachments are exported "as is".
In reply to Samuli Karevaara

Re: An "Export to HTML" functionality for Moodle courses included

by Abdul-Khaliq Nathekar -

Hi Samuli,

Is this or anything similar available for V2.x?

TIA

Abdul-Khaliq

In reply to Samuli Karevaara

Re: An "Export to HTML" functionality for Moodle courses included

by stefano federici -
This is a very fine and useful job. Thanks a lot.
In reply to stefano federici

Re: An "Export to HTML" functionality for Moodle courses included

by Mirka Langrova -
The last subsribtionis are from 2006, is there any progress or news? I am intersted in exporting Moodle to html, version 1.9.5+. Can anybody give me an advice? Thank you very much.
In reply to Mirka Langrova

Re: An "Export to HTML" functionality for Moodle courses included

by Frank Ralf -
Hi Mirka,

Please have a look at Import and export FAQ for some pointers for what's available for Moodle export.

hth
Frank
In reply to Frank Ralf

Re: An "Export to HTML" functionality for Moodle courses included

by Aaron McEntire -

I'd also give this a bump.  I know it's old but I'd like to know if anyone has updated this for 1.9/2.x or knows of a similar script?

In reply to Aaron McEntire

Re: An "Export to HTML" functionality for Moodle courses included

by Paul Ericson -

I'm trying to get this working in v1.9.5 running on Windows+IIS. I've got the html_export folder in the blocks dir and the permissions are identical to all the other blocks. I've rebooted the whole server. The block doesn't showup in either the Blocks block or ../moodle/admin/blocks.php

Do I need to change all the "/"s into "\"s?

Also, nothing is showing up in C:\Windows\system32\HTTPERR\httperr1.log.

Any thoughts?