embedding one hotpot in another and moodle 2.3

embedding one hotpot in another and moodle 2.3

by Claude Eilers -
Number of replies: 11

Hi all,

One thing that I have been doing for my Latin class is to create glossed readings with accompanying questions. You can see an example here:

   https://univmail.cis.mcmaster.ca/~eilersc/rosa_w_embedded.htm

The glossed reading is a hotpot created with rottmeier's jgloss; the file name of this file is then entered into the reading of a jquiz. 

I have quite a few of these, and I quite like them as exercises.  

The problem is that something is going amiss in moodle 2.3, where I get the following:

(rosa_gloss.htm is the name of the hotpot with the glossed text)

Any suggestions on how to make this work? or a work around?

(I've included a zip of the hotpots, htmls, and the graphic in case anyone wants to look at them)

Average of ratings: -
In reply to Claude Eilers

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Claude,
I would guess that in the reading section of the JQuiz, you need to enter the full, absolute URL (i.e. starting with "http://") of the JGloss file.
Out of interest, have you ever been able to add this kind of exercise successfully to any previous version of Moodle? In other words, does this problem occur only in Moodle 2.3?
regards
Gordon
In reply to Gordon Bateson

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Claude,
the exercise seems to work fine in my Moodle 2.3 (see screenshot).

Are you sure you uploaded the JGloss file (and the png file) to the same place you put the JQuiz file?

regards
Gordon

Attachment Screen Shot 2012-12-14 at 9.34.41 AM.png
In reply to Gordon Bateson

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Oh, wait a minute. It may depend on the browser. I was using Chrome, and that displayed OK. Firefox (17) also displayed OK.

Could you let me know which version of which browser you were viewing the exercise with?

thanks
Gordon

In reply to Gordon Bateson

Re: embedding one hotpot in another and moodle 2.3

by Claude Eilers -

In answer to an earlier question (probably not relevant any longer), these all work in Moodle 1.8 and 1.9.

It seems that it might be a browser problem.  It works in Chrome, but not Safari.  But it works in Safari in 1.9.

In reply to Claude Eilers

Re: embedding one hotpot in another and moodle 2.3

by Claude Eilers -

It's a little more complicated still. I have two installations, one on MAMP on my laptop, where it seems to work with both Safari and Chrome. And a development server at my university, where it seems to work for neither. (They are set up almost identically with regards to Moodle version and hotpot version.)  Any ideas?

In reply to Claude Eilers

Re: embedding one hotpot in another and moodle 2.3

by Claude Eilers -

Scratch that. It works with both Chrome and Safari on my MAMP. But on my university server, Safari doesn't work at all, but Chrome does partially (the jgloss text shows, but the image within it doesn't)

In reply to Claude Eilers

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

From my own investigation, I am satisfied that the HotPot module is doing its job of converting the relative URL (in the "data" attribute of the "object" tag in the JQuiz reading) to an absolute URL.

I would be interested to come and look at your development server. Could you give me teacher access to that? If you can, please send access details to me by email: gordon at-sign kanazawa hyphen gu dot ac dot jp.

cheers
Gordon

In reply to Gordon Bateson

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Claude,
thanks for letting me have a look at your site.

I think if you enable the "Use slash arguments" setting (Site administration -> Server -> HTTP) the picture will display in the Gloss section of the "12.7b Reading Exercise: On the forgetfulness of old age".

Please try that and let me know if it helps.

cheers
Gordon

In reply to Gordon Bateson

Re: embedding one hotpot in another and moodle 2.3

by Claude Eilers -

I'm afraid that didn't help. The embed still fails.  In addition, it seems to disable the template and prevent other images from displaying. (See attachment)

In reply to Claude Eilers

Re: embedding one hotpot in another and moodle 2.3

by Gordon Bateson -
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)