Moodle Grid Format doesn’t render images

If you are using the Moodle course grid format, then you might find it doesn’t render images and instead creates URLs that have @@pluginfile@@ in them. This is a sign that these URLs have not been through the lib/filelib.php file_rewrite_pluginfile_urls() function.

To fix this, you’ll need to edit the file course/format/grid/format.php

Find this section:

if (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible) { ... }

Replace this:

echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);

With this:

$summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $context->id, 'course', 'section', $thissection->id);
echo $summarytext;

Another solution to this would be to use the format_summary_text() function in course/format/renderer.php which basically takes the step above, but I think this would need a bigger code change. However it might be the correct way to fix this issue long term.

Updating Moodle Frontpage Summary through DB

You might have the need to update the Moodle front page summary through the database rather than through the UI. For example you might get an error editing the summary after a clone, or you might want to script the cloning process and change the frontpage text through the database.

Here are the steps:

Update the moodle course sections summary field for the relevant course and summary (you might need to find these first) for your frontpage. The course ID is probably 1 for your frontpage, but you’ll need to confirm this. You can find the section id by looking at the URL that is used to edit the section (e.g. http://localhost/course/editsection.php?id=xxx).

update mdl_course_sections set summary = 'Your text/HTML' where course = x and section = y;

You’ll probably find that even after you purge the moodle cache this doesn’t take effect. You’ll need to also clear your course section cache with the following SQL:

update mdl_course set sectioncache = '' where id = x;