embedding one hotpot in another and moodle 2.3

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
Number of replies: 1
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

I see. Well thanks for trying. If you can work out how to get your server to handle slash arguments you can fix all your embedded JGloss activities at once. That is definitely the most recommended solution.

Otherwise, you will need to at the following JavaScript into the <head> part of all your JGloss activities:

<script type="text/javascript">
//<![CDATA[
function fix_image_src() {

    if (window.location.href.indexOf('file.php?file=') < 0) {
        return true;
    }

    var old_base = window.location.href;
    old_base = old_base.substr(0, old_base.indexOf('?'));
    old_base = old_base.substr(0, old_base.lastIndexOf('/'));

    var new_base = window.location.href;
    new_base = new_base.substr(0, new_base.lastIndexOf('/'));

    var img = document.getElementsByTagName('img');
    if (img) {
        for (var i=0; i<img.length; i++) {
            if (img[i].src.substr(0, new_base.length)==new_base) {
                continue;
            }
            if (img[i].src.substr(0, old_base.length)==old_base) {
                img[i].src = new_base + img[i].src.substr(old_base.length);
            }
        }
    }
}
if (window.addEventListener) {
    window.addEventListener('load', fix_image_src, false);
} else if (window.attachEvent) {
    window.attachEvent('onload', fix_image_src);
} else {
    // window['onload'] = fix_image_src;
}
//]]>
</script>

What this javascript does is to find all the <img> tags and change the "src" attribute of each one so that is has the correct path relative to the URL of the JGloss file.

As a sample of where to put the code, I have added it to the following file on your Moodle site:

  • Course: Latin 1Z03-1ZZ3 - Beginners Intensive Latin I & II
  • HotPot: 12.7b Reading Exercise: On the forgetfulness of old age
  • File: rosa_gloss.htm

In a standard Moodle 2.x site such as the one you have, there is no way to "search-and_replace" for text strings in the files that are stored in the Moodle database. I'm afraid you will have to alter each one by hand.

Perhaps this site was recently updated from a Moodle 1.9 site? Do you have a backup of the 1.9 databsae and 1.9 moodledata directory? Yes? In which case, you could modify the files in the old moodledata folder and update the whole site again to Moodle 2.x.

One further point, I found that you will need to set the "Media filter" setting for all the HotPots to "none". If the "media filter" is anything other than "none", then the HotPot module will remove the <object> tag that embeds the JGloss and replace it with a link to the JGloss page, along with text that says "Warning: rosa_gloss.htm could not be embedded." I think that explains why you were seeing that message sometimes.

So for a next step, I suggest you try out the new javascript in one of the JGloss files and satisfy yourself that it does the trick. Having inserted the Javascript and uploaded the modified file to the "Source file" are of the relevant HotPot activity, you will probably need to clear your browser cache. Then the image should show.

all the best
Gordon

In reply to Gordon Bateson

Re: embedding one hotpot in another and moodle 2.3

by Claude Eilers -

Thanks so much, Gordon. That's amazingly helpful. That javascript works perfectly.  If anyone else ever needs to do this, the source file that needs to have this added is "jcloze6.ht_"

Merry Christmas!

Average of ratings: Useful (2)