<strong>1.A)</strong> Givet denna talföljd: 2 4 6 8 ...
<br />
<br />{1:NUMERICAL:=20:0#Det var RÄTT! Svaret för Aritmetisk serie fås med första termen + 9*differensen 2+9*(4-2)=20~%0%Det verkar inte vara rätt. Svaret för Aritmetisk serie fås med första termen + 9*differensen. Prova igen!}
<br />
but all that turns up is
<strong>1.A)</strong> Givet denna talföljd:
I'm using Moodle 1.6.1 2006050510
Hi Jeff,
See my bug report #6068. You may want to use my suggested bug fix. In file question\type\multianswer\questiontype.php, towards the end, comment out this line:
// $text = html_entity_decode($text);
Joseph
PS We are still waiting for someone to explain the use of that html_entity_decode() call, other than causing the mentioned bug.
I'll contact the adm and see if it will work "at home".
I won't need any Christmas presents if you keep this up! Thank you!
It is a character encoding issue. That function is not UTF-8 aware. In particular, html_entity_decode(' '); gives you a string one byte long, and that byte is 0xa0. That is not a valid UTF-8 string, so later, when Moodle tries to treat the string as UTF-8, it gets as far as that character, and stops.
So, in the modern Unicode world, html_entity_decode is evil and should be avoided at all costs.
Unfortunately, the Cloze question type uses it a lot. Ho hum.
I have about 300 cloze questions built in Moodle 1.5. And after I upgrade to 1.6. This problem comes out! " " strings come from the 1.6 new HTML editor because in HTMLarea a new plugin "get-html.js" exists. In Moodle 1.5, you will get a normal blank space if you press "SPACE" key. But in Moodle 1.6, you will get some " ". Besides, the new plugin in HTMLarea will append a <br> tag between two paragraphs, which will cause an empty space line. If I disable "get-html.js", everything goes fine as in Moodle 1.5.
Alexander
and it says that
Description
string html_entity_decode ( string string [, int quote_style [, string charset]] )and has
Table 2. Supported charsets
Charset | Aliases | Description |
---|---|---|
ISO-8859-1 | ISO8859-1 | Western European, Latin-1 |
ISO-8859-15 | ISO8859-15 | Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1(ISO-8859-1). |
UTF-8 | ASCII compatible multi-byte 8-bit Unicode. |
So maybe we could just add the optional [, string charset]].
Since Moodle is now using UFT-8 everywhere, there should be no need to encode and decode entitites all ove the place. We should be able to make the code simpler and more reliable.
That is precisely what I would like to know: why can't we strip all (3) calls to html_entity_decode() in file question\type\multianswer\questiontype.php as suggested in my bug #6068 fix? What might potential adverse effects be? Does anyone know?
Joseph
Joseph
You mention that there are 3 calls. Should all 3 be taken away?
I'm still having some strange things happening with feedback for alternative answers, intervals.
This code:
<strong>1.A)</strong> Givet denna talföljd: 2 4 6 8 ...
<br />a) Bestäm det tionde elementet i talföljden.
<br />b) Beräkna summan av de tjugofem första elementen i talföljden.
<br />{1:NUMERICAL:=650:0#Det var RÄTT! Svaret för Aritmetisk serie fås med 25*(2+50/2) = 650~%05%50:0#Det var inte sökta svaret (summan) men ett steg på vägen, nämligen värdet av 25:e termen. Nu behöver du bara ta antalet termer * medelvärdet av 1sta och 25:e termen.<br> <b>Prova igen!</b>~%0%10000.01:10000#Det verkar inte vara rätt. Summan för en aritmetisk serie kan fås med (antalet termer)*(medelvärdet av 1sta och n:te termen)<br> <b>Prova igen!</b>}
<br /> orig:
<br />
<br />{1:NUMERICAL:=20:0#Det var RÄTT! Svaret för Aritmetisk serie fås med första termen + 9*differensen<br> 2+9*(4-2)~%0%10000.01:10000#Det verkar inte vara rätt. <br>n:te termen för Aritmetisk serie fås med första termen + (n-1)*differensen. <b>Prova igen!</b>}
<br />b) Beräkna summan av de tjugofem första elementen i talföljden.
<br />{1:NUMERICAL:=650:0#Det var RÄTT! Svaret för Aritmetisk serie fås med 25*(2+50/2) = 650~%05%50:0#Det var inte sökta svaret (summan) men ett steg på vägen, nämligen värdet av 25:e termen. Nu behöver du bara ta antalet termer * medelvärdet av 1sta och 25:e termen.<br> <b>Prova igen!</b>~%0%10000.01:10000#Det verkar inte vara rätt. Summan för en aritmetisk serie kan fås med (antalet termer)*(medelvärdet av 1sta och n:te termen)<br> <b>Prova igen!</b>}
<br />
<br />
should in the last box give special feedback for "50" but gives the "general" (my hack for 0,01 to 20000) feedback. The middle box should give the general feedback for "50" but gave nothing. I tried copying the code for the last box above the (previous) first box (which made it middle box). Now the last box gives right feedback for "50" and general feedback for "500" and right feedback for 650. But the same code pasted in higher up doesn't give the proper feedback for "50" (but gives the general feedback for it too)
But the general feedback for the middle box doesn't work, though (I think) it is constructed the same as the last box.
I know the combination of Swedish and Math and Layout hardly makes this easy to analyze, but if anyone has a suggestion, I'm "all ears".
That's for sure!
Sorry I can't help you at all on this one, my Swedish being non-existent and I never ever use the NUMERICAL type of question either.
Joseph
You can download my regexp question type from the Modules and plugins download area. I've just made it compatible with Moodle 1.6.1+.
Please read carefully the readme.txt instructions before installing.
Enjoy!
Joseph