Hot Potatoes 6 exercises not working in Moodle

Hot Potatoes 6 exercises not working in Moodle

by Paul Nijbakker -
Number of replies: 14
Hi,

This may be a general problem, but I guess in this forum there will be more HotPot users around.

My problem is this: When I create a Hot Potatoes exercise (htm file) with Hot Potatoes version 6 and add that exercies to Moodle, it stops working, which is a problem since we have many Hotpot exercies linked to study texts for example. When I use the file to create a Hot Potatoes Quiz it works again, but I want the hotpot files to work also when linked to as regular resources. Interesting detail is that Moodle seems to damage the files, for when I download the file from moodle to my PC it does not work anymore even from my hard disk.

So far, the only way to get the Hot Pots to work is to use our old Hot Potatoes version 5 program and redo the exercises and save them for version 5 browsers. These files work in Moodle.

Does anyone have any idea, why the Hot Potatoes 6 exercises (.htm files) do not work in our Moodle (1.6.4, but the problem existed also in 1.6.3)? Note that I am not talking about the Hot Potatoes Quiz module.

Rgrds,
Paul.
Average of ratings: -
In reply to Paul Nijbakker

Re: Hot Potatoes 6 exercises not working in Moodle

by Martin Holmes -
Hi there,

We'll need to see your exercise in context. Could you provide us with a temporary login and instructions for viewing the exercise?

Cheers,
Martin
In reply to Martin Holmes

Re: Hot Potatoes 6 exercises not working in Moodle

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

Hi Paul,

I agree with Martin, we need to see the exercise in context. If you're worried about letting the whole world into your Moodle site, please send access details to Martin, or me, directly.

all the best
Gordon

In reply to Gordon Bateson

Re: Hot Potatoes 6 exercises not working in Moodle

by Paul Nijbakker -
Hi Martin and Gordon,

From what I can tell so far, is that the problem seems to affect only crosswords and jumbled sentence exercises and it is the active elements (e.g. the clues popping up in the crossword or the clickable sentence parts in the mix exercise) that do not show up.

I have attached to this message a crossword before it is uploaded to Moodle (i.e. a working version). In the following post I will attach the same file downloaded from Moodle (i.e. the corrupted version).

Rgrds,
Paul.
In reply to Paul Nijbakker

Re: Hot Potatoes 6 exercises not working in Moodle

by Paul Nijbakker -
The corrupted file is attached.

An optical comparison of the code shows that the corrupted file has different code in the function ShowClue (lines 1117 thru 1145, the changes are in the lines starting with Temp)

Rgrds,
Paul.
In reply to Paul Nijbakker

Re: Hot Potatoes 6 exercises not working in Moodle

by Paul Nijbakker -
For easy comparison, I list the code next to each other:

Function code before upload to Moodle
Function code after upload to Moodle
function ShowClue(ClueNum,x,y){
var Result = '';
var Temp;
var strParams;
var Clue = document.getElementById('Clue_A_' + ClueNum);
if (Clue != null){
Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
Temp = Temp.replace(/\[strClueNum\]/g, AcrossCaption + ' ' + ClueNum);
strParams = 'true,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
Temp = Temp.replace(/\[strParams\]/g, strParams);
Temp = Temp.replace(/\[strBoxId\]/g, 'GA_' + ClueNum + '_' + x + '_' + y);
Temp = Temp.replace(/\[strEditSize\]/g, GetEditSize(true,x,y));
Temp = Temp.replace(/\[strMaxLength\]/g, GetAnswerLength(true,x,y));
Temp = Temp.replace(/\[strClue\]/g, Clue.innerHTML, Temp);
Result += Temp;
}
Clue = document.getElementById('Clue_D_' + ClueNum);
if (Clue != null){
Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
Temp = Temp.replace(/\[strClueNum\]/g, DownCaption + ' ' + ClueNum);
strParams = 'false,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
Temp = Temp.replace(/\[strParams\]/g, strParams);
Temp = Temp.replace(/\[strBoxId\]/g, 'GD_' + ClueNum + '_' + x + '_' + y);
Temp = Temp.replace(/\[strEditSize\]/g, GetAnswerLength(false,x,y));
Temp = Temp.replace(/\[strClue\]/g, Clue.innerHTML, Temp);
Result += Temp;
}
document.getElementById('ClueEntry').innerHTML = Result;
}

function ShowClue(ClueNum,x,y){
var Result = '';
var Temp;
var strParams;
var Clue = document.getElementById('Clue_A_' + ClueNum);
if (Clue != null){
Temp = InputStuff.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="ClueNum" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/eeed6d5ffae6f1ca0c5eae7fad653c48.gif" style="vertical-align:middle" /></a>/g, ClueNum);
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strClueNum" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/c9dbe926b8fd3dd81202fb8843b0561d.gif" style="vertical-align:middle" /></a>/g, AcrossCaption + ' ' + ClueNum);
strParams = 'true,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strParams" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/4b40541a44412ff71f379dfcef28a129.gif" style="vertical-align:middle" /></a>/g, strParams);
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strBoxId" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/ce75240ca9a1247d466e17eb4840e35c.gif" style="vertical-align:middle" /></a>/g, 'GA_' + ClueNum + '_' + x + '_' + y);
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strEditSize" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/e452e7abae3456b7dbaeb07ab8d31a8c.gif" style="vertical-align:middle" /></a>/g, GetEditSize(true,x,y));
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strMaxLength" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/089586d7deaa0a59bb7f9d7ddc0b2b0e.gif" style="vertical-align:middle" /></a>/g, GetAnswerLength(true,x,y));
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strClue" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/310b21fe5a3eb2f728bf6b637d4b0610.gif" style="vertical-align:middle" /></a>/g, Clue.innerHTML, Temp);
Result += Temp;
}
Clue = document.getElementById('Clue_D_' + ClueNum);
if (Clue != null){
Temp = InputStuff.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="ClueNum" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/eeed6d5ffae6f1ca0c5eae7fad653c48.gif" style="vertical-align:middle" /></a>/g, ClueNum);
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strClueNum" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/c9dbe926b8fd3dd81202fb8843b0561d.gif" style="vertical-align:middle" /></a>/g, DownCaption + ' ' + ClueNum);
strParams = 'false,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strParams" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/4b40541a44412ff71f379dfcef28a129.gif" style="vertical-align:middle" /></a>/g, strParams);
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strBoxId" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/ce75240ca9a1247d466e17eb4840e35c.gif" style="vertical-align:middle" /></a>/g, 'GD_' + ClueNum + '_' + x + '_' + y);
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strEditSize" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/e452e7abae3456b7dbaeb07ab8d31a8c.gif" style="vertical-align:middle" /></a>/g, GetAnswerLength(false,x,y));
Temp = Temp.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="strClue" alt="" src="http://moodle.tokem.fi/filter/tex/pix.php/310b21fe5a3eb2f728bf6b637d4b0610.gif" style="vertical-align:middle" /></a>/g, Clue.innerHTML, Temp);
Result += Temp;
}
document.getElementById('ClueEntry').innerHTML = Result;
}

Why does Moodle make these changes and how to undo this? The flawed code mentions the Tex filter, could that be the cause? Turning that filter off is not an option for our maths teachers.

Rgrds,
Paul.
In reply to Paul Nijbakker

Re: Hot Potatoes 6 exercises not working in Moodle

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
HI Paul,
thanks for the two versions of the Hot Potatoes HTML file.

I used WinMerge to compare the two files and found that your problems are caused by strings like this:
Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);

being converted to:
Temp = InputStuff.replace(/<a href="http://moodle.tokem.fi/filter/tex/texdebug.php"><img class="texrender" border="0" title="ClueNum" alt="" src="" style="vertical-align:middle" /></a>/g, ClueNum);

This is caused by Moodle's "Tex" filter, which is activated when the file is uploaded to Moodle. It finds the "\[ClueNum\]" string and replaces it with an image.

This is a known problem (MDL-7849), and there is a solution suggested here:

If you really want to leave the "TeX" filter enabled on yor Moodle site, and are not able to implement the fix suggested above, then another workaround would be to upload the Hot Potatoes files via FTP (and not via the Moodle interface)

If that is not clear, please let me know
Gordon
In reply to Gordon Bateson

Re: Hot Potatoes 6 exercises not working in Moodle

by Paul Nijbakker -
Hi Gordon,

Thanks, now I know the cause and that the error is being worked on. I tried out the two hacks that you suggested but, unfortunately, they did not produce the desired result, the code is still modified in exactly the same way.

I will try turning off the Tex filter when I am sure it will not cause mayhem. But I suppose that will not undo the damage already done, and we still have to replace our affected Hot Potatoes exercises (quite many saddead dead).

Rgrds,
Paul.
In reply to Gordon Bateson

Re: Hot Potatoes 6 exercises not working in Moodle

by Martin Holmes -
Hi Gordon,

What triggers this action by the Tex filter? Is there anything we could change in the HotPot files that might avoid it?

Cheers,
Martin
In reply to Martin Holmes

Re: Hot Potatoes 6 exercises not working in Moodle

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Martin,
when a file is uploaded to Moodle, it is passed through the Moodle filters before being written to the hard disk. The filters are basically search-and-replace scripts.

The TeX filter is used to make pretty mathematical formulas like this:
\[\sqrt[n]{\frac{x^n-y^n}{1+u^{2n}}}\] displays as : \[\sqrt[n]{\frac{x^n-y^n}{1+u^{2n}}}\]

The TeX filter searches for any of the following
  • <tex> TeX expression </tex>
  • [tex] TeX expression [/tex]
  • $$ TeX expression $$
  • \[ TeX expression \]
The last of these matches the \[ClueNum\] in JCross and JMix.

The maintainers of the TeX filter have so far not responded to requests for modifications which would allow Hot Potatoes quizzes to pass unaltered through the "TeX" filter.

Would it be possible to modify the Hot Potatoes "source" templates so that the backslash + left square bracket are broken up?

Jcross6.js_

  • OLD: Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
  • NEW: Temp = InputStuff.replace(new RegExp('\\'+'[ClueNum\\]', 'g'), ClueNum)
There are 13 situations similar to the above.

Jmix6.js_

  • OLD: TempRow = TempRow.replace(/\[SegmentNumber\]/g, Segments[i][1]);
  • NEW: TempRow = TempRow.replace(new RegExp('\\'+[SegmentNumber\\]', 'g'), Segments[i][1]);
There is one other situation similar to the above.

It is not so pretty is it sad

One other idea is for everyone to go and vote for action on, and add comments to the MDL-7849 issue. Make a (polite) noise smile

cheers
Gordon
In reply to Gordon Bateson

Re: Hot Potatoes 6 exercises not working in Moodle

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Paul (and other avid HotPot users!)

if you would like to change the "TeX" filter, please could you go and vote for action on MDL-7849 requesting that the "TeX" filter be switched off for Hot Potatoes quizzes.

thanks
Gordon
In reply to Gordon Bateson

Re: Hot Potatoes 6 exercises not working in Moodle

by Marc Paré -
Hi Gordon:

This issue seems pretty important. Would it be better to open a new discussion in this forum so that all can be made aware of this? It just seems like it may be too buried in this discussion for people to actually vote on the bug request. We should all be aware that this is a pretty important issue to deal with and that the vote matters or is Martin Dougiamas a frequent enough visitor to this forum to notice the implications of this issue?

We would also all need to register to Moodle Tracker to vote for this. (Which I have done.)

Marc


In reply to Marc Paré

Re: Hot Potatoes 6 exercises not working in Moodle

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

thanks for making those very valid points. For my part, I shall try to talk to MD directly and ask him the most effective way forward.

cheers
Gordon
In reply to Gordon Bateson

Re: Hot Potatoes 6 exercises not working in Moodle

by Glenys Hanson -
Hello,

I don't know if this is relevant, but I've made a lot of JMix and JCross exercises which work fine in Moodle 1.6.4+

JMix
http://moodle.univ-fcomte.fr/mod/hotpot/view.php?id=11909
Enrolment key: Rennes

JCross
http://moodle.univ-fcomte.fr/mod/hotpot/view.php?id=16853
Enrolment key: exos (but it may not work because even though I've allowed visitors, it's a meta course and somehow refuses visitors of its own volition).

Cheers,
Glenys

In reply to Glenys Hanson

Re: Hot Potatoes 6 exercises not working in Moodle

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Glenys,
a JCross or JMix will only break if ALL the following conditions apply:
  • you upload the JCross/JMix Hot Potates quiz via Moodle's file upload screens
  • the TeX filter is enabled on your Moodle site when you upload the quiz
  • you upload the "html" version of the Hot Potates quiz
This means that if ANY of the following conditions apply then your HotPot will work fine
  • you use FTP to upload the JCross/JMix Hot Potatoes quiz file to Moodle
  • the TeX filter is NOT enabled on your site when you upload the Hot Potatoes quiz
  • you run your JCross/ JMix HotPots from the XML file (jcw/jmx)
I would guess that your HotPots are working because the TeX filter is disabled on your site. (It is disabled by default when you install Moodle)

Hope that's clear smile

Thanks for letting us look at your site! Great stuff! approve

best regards
Gordon