Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Virginia Mario -
Number of replies: 11

Hi!

I have made some jcloze exercises and some of them contain a link to a word doc or an html file (created with MOZILLA). When I uploaded the quizzes (and the files linked of course), these files won't open. Is this a server problem?. The type of message that appear is ERROR 404. Can anybody help me?

Thanks!!!!!!!!!!!!!!

Average of ratings: -
In reply to Virginia Mario

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Martin Holmes -
First of all, could you tell us what the links look like in the HotPot exercise? Most likely, this is caused by the relative locations of the exercise and the files on Moodle being different from the relative locations on your hard drive.
In reply to Martin Holmes

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Virginia Mario -

Thanks for your answer. The zip file contains one of the exercises I'm trying to make with its link. I have uploaded the SAME zip file onto my MOODLE website but the word doc won't open.

Thanks a lot.

Virginia

In reply to Virginia Mario

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Martin Holmes -
I can't find any trace in the HotPot exercise of a link to your doc file. It seems as though you haven't added any link at all!

Cheers,
Martin
In reply to Martin Holmes

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Same for me,
Joseph
In reply to Joseph Rézeau

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Virginia Mario -

Sorry guys, I attached the wrong file. I've been trying different ways and I still can't see what the problems is. I have done similar hotpot exercises with links attached in them and they worked fine on the SAME platform and now....sad

Anyway, I'm enclosing the correct file this time, sorry about the mistake.

Gracias!

Virginia

In reply to Virginia Mario

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Martin Holmes -
Hi there,

There is one error in the HTML code in the exercise:

Error Line 1513 column 1091: element "B" undefined.
...></input></span> <br /><br /><br /><B>Now that you have finished the exercise
You have used the element named above in your document, but the document type you are using does not define an element

All tags are lower case in XHTML. That might be enough to trip up IE. That said, the link works for me in IE locally.

There are two possible issues:

1. Linking using "window.open". It's possible that this is not seen as a link by Moodle. Try using a regular link (<a href="...) instead, and see if that works.

2. Linking to a Word file. The combination of Word files and IE is so dangerous these days that I would personally never click on a link to a word file in a web page. Try saving the Word file as something else -- text or HTML, perhaps.

Cheers,
Martin


In reply to Martin Holmes

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Virginia Mario -

Thanks a lot Martin!!

I just want to add, for the record, that another way of solving the problem (at least in our case) was simply this:

-When you prepare the hot pot and you link a file, simply DO NOT TICK the box that says "Open this file in a new Window" and the file opens without any problems on moodle.

Hope it helps others.

See u around

Virginia

In reply to Virginia Mario

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Virginia,
well done you found the solution! I was just going to say the same thing but in a more long-winded way. Since I prepared it, I'll post it in anyway.

all the best
Gordon



This cause of the problem is that the link to the Word document is specified as a relative link.

In addition, the link is set up to open in a new window using Javascript, specifically the window.open() method.

To make the link work as required, you can either:
  • Method 1. change the link to an absolute URL
  • Method 2. do not use Javascript in the link
Details of how to make the above alterations appear below.

Method 1. change the link to an absolute URL
  1. login to Moodle and go to the main page of the course with this HotPot
  2. go to the Files area of the course and locate the Word document
  3. copy the URL of the Word document (=right click on the file name and choose "Copy Link Location")
  4. use this absolute (=full) URL in the link in the HotPot activity
Method 2. do not use Javascript in the link

change this:
<a style="cursor: pointer; text-decoration: underline;"
onclick="window.open('Tastingadjectives1list.doc');return false;">here</a>

to this:
<a style="cursor: pointer; text-decoration: underline;"
href="Tastingadjectives1list.doc" target="_blank">here</a>


I may change the HotPot module to search for these kind relative links (i.e. used in the "window.open()" method) and replace them with absolute links. Thanks for reporting the problem!
In reply to Gordon Bateson

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Virginia,

I have modified the HotPot module in Moodle 1.6, 1.7, 1.8 and the HEAD branch of the Moodle CVS depository (which one day will become Moodle 1.9), so that relative URLs in links using "window.open()" will be automatically changed to absolute URLs and so will work as expected.

In other words, your original Hot Potatoes quiz will now work if you use the new HotPot module.

You can download the new HotPot module from the Moodle downloads page. It can take up to 24 hours for the changes I submit to show up in the downloads, so I suggest you download the new module tomorrow.

thanks again!
Gordon
In reply to Gordon Bateson

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

by Martin Holmes -
Hi there,

I think it's worth explaining why links in HotPot are usually done with window.open() rather than straightforward anchor tags. Once you navigate away from a Hot Potatoes page, all the data is lost -- all the answers you gave and the score you've achieved -- because it's just stored in JavaScript and is destroyed when the window location is changed. That can be a bad thing, if, say, a student has worked for 20 minutes on an exercise and still hasn't finished. So if you're adding links, it's often a good idea to make them open in a new window, leaving the exercise window unchanged, unless they're only visible right at the end of the exercise.

Cheers,
Martin
In reply to Martin Holmes

Re: Links to files done in Hot Pot won't open when exercise is uploaded to Moodle.

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

Yes, I agree with Martin. Where possible, links away from a Hot Potatoes quiz should open in a new window, and you can use relative URLs now with "window.open()" and be sure that everything will work as expected.

best regards
Gordon