Does quizport support the map tag?

Does quizport support the map tag?

by Neelima Ramesh -
Number of replies: 14
Hi Gordon and everyone!

I was wondering if I can use something like the following code in quizport.

A javascript function that is;

function PlaySound(sfl){
document.getElementById("dummy").innerHTML="<embed src="+sfl+" height=0 width=0 ></embed>";
}

and the html part would have;

<span id="dummy"></span>
<IMG name="play.gif" src="play.gif" id="play" border="0" height=20 width=20 usemap="#audio1" style="cursor:hand;>
<map name="audio1">
<area href="javascript:PlaySound('bit.wav')" shape="default">
</map>

When I tried it in quizport, the sound doesn't play. Only the image appears. I'm not sure if quizport supports the map tag. Or do I have to enable or disable something in moodle settings for this to work? I have already checked the "Allow EMBED and OBJECT tags" option.


Thanks
Neelima
Average of ratings: -
In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Thanks for bringing <map> tags to my attention. I have added <area ... href="" .. > to the list of tags thet QuizPort will search and replace relative urls with absolute urls.

However, even that is not enough to convert urls within javascript within the "href" parameter of an <area> tag. You are expecting too much there wink

Instead, you will have to use some javascript to convert the urls yourself. For example, if you add the following javascript somewhere near the top of your page ...
  • var img = '<img src="myimage.jpg">';
    var wwwroot = img.substr(10, img.length-23);
QuizPort will convert "myimage.jpg" to an absolute URL, and so wwwroot will hold a url pointing to the Moodle data folder containing the quiz. You can preprend "wwwroot" to any urls you use in your javascript:
  • function PlaySound(sfl){
    document.getElementById("dummy").innerHTML="<embed src="+wwwroot+sfl+" height=0 width=0 ></embed>";
    }
  • <area href="javascript:PlaySound(wwwroot+'bit.wav')" shape="default">
Another idea for your area tag is ...
  • <area href="bit.wav" onclick="PlaySound(this.href); return false;" shape="default">
I have not tested the above code, and you might have to change those numbers "10" and "23", but hopefully this is enough to give an idea about how to proceed.

Gordon
Average of ratings: Useful (1)
In reply to Gordon Bateson

Re: Does quizport support the map tag?

by Neelima Ramesh -
Hi Gordon!

It seems like a perfect solution but its still not working for me. I tested it to check what string the variable wwwroot is storing and its storing the correct link. But its still not working.

Could you try it too and check what the problem is?

thanks in advance.

Neelima
In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
How about the onclick solution then?
In reply to Gordon Bateson

Re: Does quizport support the map tag?

by Neelima Ramesh -
well no. I tried the onclick method too and that didn't work either.
There are a lot of places where I'm having to use a function and pass a file name as a parameter to that function. Like we have audio glossing in our exercises as shown in this link;
http://www.ewbooks.info/hotpot/tutorials/hotpotatoes-tutorials/audio-glosses.html

I also have a number of flash players in one page and call a javascript function and pass the value of the mp3 file to the function when i want to play it. Similarly when glossing text with images.

So you see, I really need this to work but I don't understand why this should not work.
In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
How about it you just set the wwwroot variable to something that you know is correct? That would definitely work, wouldn't it?
In reply to Gordon Bateson

Re: Does quizport support the map tag?

by Neelima Ramesh -
You mean, if i give the whole address with the ip? Something like this? "
http://192.168.1.75/moodle/file.php/2/Unit3/Irregular_plurals/"?

This would surely work. But is there no other, more flexible way?
This would again cause major problems when we need to shift our moodle site from one place to another.

I wonder why the method you suggested previously doesn't work though.

In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
> You mean, if i give the whole address with the ip? Something like this?
> http://192.168.1.75/moodle/file.php/2/Unit3/Irregular_plurals/

Yes, that's what I mean.

Earlier you said:

> I tested it to check what string the variable wwwroot is storing
> and its storing the correct link. But its still not working.

In such a case, I suggest you experiment by setting the wwwroot manually until you find something that works. If you get that far, you should be able to fix the automatic setting of wwwroot yourself.

good luck!
Gordon


In reply to Gordon Bateson

Re: Does quizport support the map tag?

by Neelima Ramesh -
Hi Gordon,

You said earlier that you've added <area ... href="" .. > to the list of tags. Could you tell me where I'll find the latest version of the quizport that you have altered so I can implement the <map> tag?

Thanks.
Neelima
In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Neelima,
I think it is in "mod/quizport/output/class.php".
Have a look around line 848.

But you can't put a URL in a <map> tag, can you?
http://www.w3schools.com/TAGS/tag_map.asp

Gordon
In reply to Gordon Bateson

Re: Does quizport support the map tag?

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

Oops, I think I misunderstood your previous message.

On first reading, I thought you wanted to "implement the <map>" tag yourself.

But after reading the message again, I think that perhaps you wanted to know where you can download the latest version of QuizPort from. Is that right?

FYI, you can download the latest version of QuizPort from:

  • moodle.org -> Downloads -> Modules and Plugins

The drop down menu at the top of this page will take you right there wink
Gordon

In reply to Gordon Bateson

Re: Does quizport support the map tag?

by Neelima Ramesh -
yes. that's what I meant.

Thanks. I'll take it from there. smile
In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Neelima Ramesh -
Hi Gordon.

Sorry to bother you with this problem again.

There is something weird here. I'm not sure what's happening.

This is the same PlaySound function that i mentioned in the 1st post here. The html is the same. Like you suggested, i added a variable (wwwroot) to give an absolute path for quizport to find the file. Some thing like this;

var wwwroot="http://192.168.1.75/moodle/file.php/4/pronunciation_upload/";
function PlaySound(sfl){
document.getElementById("dummy").innerHTML="<embed src="+wwwroot+sfl+" height=0 width=0 ></embed>";
}

I was trying to figure out how to make this more flexible when I was faced with another problem.

For a flash player with an object tag this worked fine. But when I use the embed and map tag, there was no sound coming.
When I checked the source code in the browser, I found the code like this;

var wwwroot="http://192.168.1.75/moodle/file.php/4/pronunciation_upload/";
function PlaySound(sfl){
document.getElementById("dummy").innerHTML="<embed src="http://192.168.1.75/moodle/file.php/4/pronunciation_upload/+wwwroot+sfl+" height=0 width=0 ></embed>";
}

Notice the portion in blue. This is the path to the folder in which the file exists. Any idea why this is happening?

PS. This must be obvious, but this happens even when I don't use the variable wwwroot at all in my code.

Neelima
In reply to Neelima Ramesh

Re: Does quizport support the map tag?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
The blue code is inserted by the QuizPort module, because it recognizes the <embed> tag and does its best to convert in relative urls within the tag to absolute urls.

If you don't want that you should rewrite the javascript expression thus:
  • innerHTML="<em" + "bed src="+wwwroot+sfl+" height=0 width=0 ></em" + "bed>";
But it seems to me that you want the url to be converted don't you? Therefore, I would leave the <embed> tag as it is and and instead remove the wwwroot from this particular expression:
  • innerHTML='<embed src="'+sfl+'" height=0 width=0 ></embed>';
What does the embed tag get converted to now?

Gordon
In reply to Gordon Bateson

Re: Does quizport support the map tag?

by Neelima Ramesh -
Hey Gordon!

This works! big grin

only its
innerHTML='<embed src='
"+sfl+"' height=0 width=0 ></embed>';

But i still have this doubt. Like you said, this code;
innerHTML="<em" + "bed src="+wwwroot+swf+" height=0 width=0 ></em
" + "bed>";

or even
innerHTML='<embed src=+"+sfl+" height=0 width=0 ></embed>';

stop quizport from converting relative urls to absolute urls.

So if i use the variable wwwroot along with the above, it should work right? But it doesn't.

Any idea why?

Neelima