Help! About a cloze question

Help! About a cloze question

by Alexander Kuo -
Number of replies: 26
Hi,
      I use Moodle 1.6+ with utf-8 encoding. I can't append a cloze-typed question because everytime I hit the "save changes" button it becomes blank. In fact, the same content of a cloze-typed question works well in my another Moodle 1.5.4 site. Could anyone help me to test it ? or just give me an idea?
The following is the content of question(in HTML format).
*********************************************************************************
<p>There are two kinds of heroes: heroes who shine in the face of great danger, who perform an&nbsp;<u>&nbsp; 21&nbsp;&nbsp;</u> act in a difficult situation, and heroes who live an ordinary life like us, who do their work&nbsp;<u>&nbsp; 22&nbsp; </u>&nbsp; by many of us, but who&nbsp;<u>&nbsp; 23&nbsp;&nbsp;</u>&nbsp;a difference in the lives of others.
  <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Heroes are selfless people who perform extraordinary acts. The mark of heroes is not necessarily the result of their action, but&nbsp;<u>&nbsp; 24&nbsp;&nbsp;</u>&nbsp; they are willing to do for others and for their chosen cause. &nbsp;<u>&nbsp; 25&nbsp;&nbsp;</u> they fail, their determination lives on for others to follow. The glory lies not in the achievement but in the
  <br />sacrifice.
  <br />
  <table cellspacing="1" cellpadding="1" width="100%" border="0"> <tbody>
    <tr>
      <td valign="top" width="4%">
        <p align="right">{2:MULTICHOICE:A#C~B#C~=C~D#C}
        </p>
      </td>
      <td valign="top" width="24%">21. (A) annoying
      </td>
      <td valign="top" width="24%">(B) interfering
      </td>
      <td valign="top" width="24%">(C) amazing
      </td>
      <td valign="top" width="24%">(D) inviting
      </td>
    </tr>
    <tr>
      <td valign="top" width="4%">
        <p align="right">{2:MULTICHOICE:A#D~B#D~C#D~=D}
        </p>
      </td>
      <td valign="top" width="24%">22. (A) noticing
      </td>
      <td valign="top" width="24%">(B) noticeable
      </td>
      <td valign="top" width="24%">(C) noticed
      </td>
      <td valign="top" width="24%">(D) unnoticed
      </td>
    </tr>
    <tr>
      <td valign="top" width="4%">
        <p align="right">{2:MULTICHOICE:=A~B#A~C#A~D#A}
        </p>
      </td>
      <td valign="top" width="24%">23. (A) make
      </td>
      <td valign="top" width="24%">(B) do
      </td>
      <td valign="top" width="24%">(C) tell
      </td>
      <td valign="top" width="24%">(D) count
      </td>
    </tr>
    <tr>
      <td valign="top" width="4%">
        <p align="right">{2:MULTICHOICE:=A~B#A~C#A~D#A}
        </p>
      </td>
      <td valign="top" width="24%">24. (A) what
      </td>
      <td valign="top" width="24%">(B) who
      </td>
      <td valign="top" width="24%">(C) those
      </td>
      <td valign="top" width="24%">(D) where
      </td>
    </tr>
    <tr>
      <td valign="top" width="4%">
        <p align="right">{2:MULTICHOICE:A#B~=B~C#B~D#B}
        </p>
      </td>
      <td valign="top" width="24%">25. (A) Not until
      </td>
      <td valign="top" width="24%">(B) Even if
      </td>
      <td valign="top" width="24%">(C) As if
      </td>
      <td valign="top" width="24%">(D) No sooner than
      </td>
    </tr></tbody>
  </table>
</p>
Average of ratings: -
In reply to Alexander Kuo

Re: Help! About a cloze question

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Alexander,

Apparently, the cloze question in Moodle 1.6 does not like the non-breaking space &nbsp; If you remove all &nbsp; from your code, it works OK.

However, I find the way you present your activity rather strange and not too user-friendly for the students mixed. May I suggest rewriting your code as below. See result in attached screen shots.

There are two kinds of heroes: heroes who shine in the face of great danger, who perform an {2:MULTICHOICE:annoying#amazing~interfering#amazing~=amazing~inviting#amazing}act in a difficult situation, and heroes who live an ordinary life like us, who do their work {2:MULTICHOICE:noticing#unnoticed~noticeable#unnoticed~noticed#unnoticed~=unnoticed} by many of us, but who {2:MULTICHOICE:=make~do#make~tell#make~count#make} a difference in the lives of others.

Heroes are selfless people who perform extraordinary acts. The mark of heroes is not necessarily the result of their action, but {2:MULTICHOICE:=what~who#what~those#what~where#what} they are willing to do for others and for their chosen cause. {2:MULTICHOICE:Not until #Even if~=Even if~As if#Even if~No sooner than#Even if} they fail, their determination lives on for others to follow. The glory lies not in the achievement but in the sacrifice.

Hope this helps,

Joseph

Attachment image-0000.jpg
In reply to Joseph Rézeau

Re: Help! About a cloze question

by Alexander Kuo -
Hi Joseph,
     Thank you so much for your detail reply and suggestion.
     But, we have more than 300 cloze questions built in 1.5.4 and having the non-breaking space "&nbsp;". What can I do to remove them from the database? and if teachers are used to pressing the space button and causing many "&nbsp;", how could I persuade them not to press the space button? In fact, when I told the reason why they got a blank content after they edited a built cloze question, they just asked me a question as follows "Why not having the non-breaking space in Moodle 1.6?"
Alexander.
In reply to Alexander Kuo

Re: Help! About a cloze question

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Alexander,

I have reported the &nbsp; problem (and a solution) as bug #6068. Let's hope Tim Hunt can do something about it soon. In the meantime, if you or your administrator are willing to hack the Moolde code, you can follow my suggestion in the bug report and simply delete or comment out the offending line.

I'm curious to know how your quizz questions are authored by your teachers. When questions are authored in the Moodle quiz cloze interface (in the HTML editor), pressing the space bar inserts a "normal" space, not a non-breaking one.

All the best,

Joseph

In reply to Joseph Rézeau

Re: Help! About a cloze question

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is open source. Scratch your own itch  wink

More seriously, Cloze questions are not a priority for me, because we are not using them here at the OU. And there are plenty of things for me to do that are a higher priority.
In reply to Tim Hunt

Re: Help! About a cloze question

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Of course, OU committed to maintaining the *Moodle* Quiz module (not the OU quiz module).   wink   Hopefully the new bug tracker system will make it easier for the community to set priorities.

In reply to Tim Hunt

Re: Help! About a cloze question

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Apologies if my reply was misinterpreted.

What I meant to say is that I spent a couple of hours trying to understand this part of the CLOZE question type, and I have absolutely no idea what purpose the call to html_entity_decode() is (see bug report). It must have been added for a reason, but CVS history gives no clues. So in the end I had to give up and move on to some more productive work. Until someone can work out what is going on here, I am not going to just make random changes to the code.

If CLOZE questions are really so popular, there must be someone out there with the time, knowledge and incentive to work it out. At the very least, can people who use this question type try manually making that change to the code mentioned in the bug report, and see whether it causes any unexpected side-effects in addition to fixing the bug.

But until there is either an explanation why, or some experimental evidence that shows, the suggested fix works, I am not giong to check it in.
In reply to Tim Hunt

Re: Help! About a cloze question

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yes, Cloze users, please test the changes and post your results on bug 6068. Quiz is complicated, and the code in question is old (Tim took over only very recently).

Perhaps Gustav is around and remembers something about it, too, I've cc'ed him on bug 6068.

I think if we get at least three people saying that the fix is OK then it should be enough to help Tim make that final call on the check-in.
In reply to Joseph Rézeau

Re: Help! About a cloze question

by Alexander Kuo -
Hi Joseph,
     I and my teachers really appreciate your great help! Due to your clear explanation, we try to know how the "html_entity_decode"  function will work. And we find that "html_entity_decode" will work fine in non-UTF8 coding. But it will fail in UTF8 coding with a error message "cannot yet handle MBCS in html_entity_decode()... "
      Now, we decided to follow your suggestion by commenting out the offending line $text = html_entity_decode($text) and it really works well.  
      The non-breaking space "&nbsp" occurs in the start of every paragraph. In the HTML editor, we just press the SPACE button and we get &nbsp. Is there anything wrong with this? 
In reply to Alexander Kuo

Re: Help! About a cloze question

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
A better solution would be to upgrade our server to PHP5. That line must be there for a reason.
In reply to Tim Hunt

Re: Help! About a cloze question

by Alexander Kuo -
Hi Tim,
    Thank for your suggestion. Actually, my PHP version is 5.1.4 with Zend Engine v2.1.0 and eAccelerator v0.9.5-beta2. And the function html_entity_decode() still fails.
     Would you please tell me why the line must be there? for safety? or.....
In reply to Alexander Kuo

Re: Help! About a cloze question

by Jean-Michel Védrine -
Hello,
If the problem is only caused by non-breaking spaces, why don't you put a line:
$text = str_replace("&nbsp;", " ", $text);
just before the line:
$text = html_entity_decode($text);
But what really puzzle me is why now that Moodle use utf-8 the html_entity_decode function is used in a lot of places (not only in quiz mod) without specifying any charset ? Is that right ?
In reply to Joseph Rézeau

Re: Help! About a cloze question

by Alexander Kuo -
Hi,
       It is this afternoon that I find that all my cloze-typed questions DO not have the non-breaking space unless I try to edit it in Moodle 1.6. So, I try to install a new Moodle 1.6 site and find that if I press No space buttons in the front of the paragraph I will get (n-1) &nbsp;. How surprising it is! On the other hand, I try to install a new Moodle 1.5.4 site and find that if I press space buttons in the front of the paragraph I DON'T get the non-breaking space. Judging from the experiments above, I may conclude that the non-breaking space problems might result from the HTML editor rather than multianswer question type. What do you think about this?  
    And now, I am posting this message. When I switch to HTML mode, I really get non-breaking space &nbsp;. Any ideas or comments will be appreciated.                              Alexander.
In reply to Alexander Kuo

Re: Help! About a cloze question

by N Hansen -
I've been having a problem when I open already existing cloze questions from 1.5 and then resave them again in 1.6-but I don't think it is the same issue you are having.

In any case, if you suspect the editor, look at bug 6016 and see if it is somehow related to the file in question there. I had another problem with new code in the editor in 1.6, but I have disabled the file for the time being...unless that is the cause behind my new problem with cloze?
In reply to N Hansen

Re: Help! About a cloze question

by Alexander Kuo -
Yes, the problem is solved. smile
      It is HTML editor that causes the problem as bug 6068. After I disable the line which will lunch "get-html.js" in htmlarea.php, everything becomes fine. All my old cloze questions work, too. And now, when I press space button in front of a paragraph, I don't get any non-breaking space any more.
     Many thanks to all people that have helped me a lot! Alexander.
In reply to Joseph Rézeau

Re: Help! About a cloze question

by Adán Cruz -

Hi, Joseph

I'm completely new to Moodle, so I may be asking something really basic, but here it goes. I'm trying to upload a quiz similar to the one you were discussing here. The problem is only the first question shows up correctly and the rest appear just as the code I used. Here is what I typed:

Complete with should or shouldn’t.
Health Watch
Q: My sister never washes fruit or vegetables. She says it’s good for our bodies to eat a bit of dirt. Is she correct?
A: No, you {1:MULTICHOICE:shouldn't#Sorry; try again ~=should #Excellent! } always wash fruit and vegetables before you eat them, because they may have fertilizers or pesticides on them, and these can be harmful.
Q: I read in a magazine that you {1:MULTICHOICE:shouldn't#Sorry; try again ~=should #Excellent! } take multivitamin pills every day as part of your daily diet. Is that right?
A: No, it  {1:MULTICHOICE:should #Sorry; try again ~=shouldn't #Excellent! } be necessary. If you eat a normal balanced diet, you {1:MULTICHOICE:should#Sorry; try again ~=shouldn't #Excellent! } eat any extra supplements. However, if fresh fruit and vegetables are difficult to find, you {1:MULTICHOICE:shouldn't#Sorry; try again ~=should #Excellent! } take extra vitamin tablets.
Q: I’ve heard somewhere that vegetables are only good for you if you eat them raw. Is that correct?
A: Not quite. Of course you  {1:MULTICHOICE:shouldn't#Sorry; try again ~=should #Excellent! } eat raw vegetables sometimes, but cooked vegetables are fine, too. But remember that you {1:MULTICHOICE:should#Sorry; try again ~=shouldn't #Excellent! } overcook them; you {1:MULTICHOICE:shouldn't#Sorry; try again ~=should #Excellent! } only cool them until they are just tender.

Can you tell me what I'm doing wrong?

Thanks

In reply to Adán Cruz

Re: Help! About a cloze question

by N Hansen -
This is what has been happening to me when I open an already existing question created in 1.5 for editing in 1.6. Unfortunately, I have not found an answer to the problem yet. Any information would me much appreciated as I've had to reconstruct the 2 questions I made the mistake of opening in a very roundabout way-backing up the quiz to another course, and then taking a very similar question and renaming it and then saving it to the original quiz, and changing just the small changes via the database. Creating new questions seems to be out of the question too as I encounter the same problem you are having, although I don't have a need to create new ones at the moment.
In reply to Adán Cruz

Re: Help! About a cloze question

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Adán,

You do not say which version of Moolle you are using. Anyway, using Moodle 1.6, I've just created a Cloze/Embedded question. If I copy your code (with blue background in your post) and paste it into the Question text using the HTML editor, I only get the first 2 sub-questions. So, instead of pasting your code there, on the HTML editor toolbar, I click the Toggle HTML Source button, and past your code in the HTML Source code... and it works fine, as shown on attached screen shot.

Because of the way the Cloze/Embedded works, you have to insert the sub-questions as code. You can use the HTML editor, but you have to be very careful if you copy and paste text from another text editor such as Word, Dreamweaver, etc. My advice is to stick to plain text, and to check that your code is "clean" by using the Toggle HTML Source button.

Hope that helps,

Joseph

Attachment image-0000.jpg
In reply to Joseph Rézeau

Re: Help! About a cloze question

by N Hansen -
  Joseph-My problem is the opposite-I see the second question fine, but not the first. I tried your trick of toggling the editor but it still didn't solve the problem. This very same code worked in 1.5 but doesn't work in 1.6. Here's my code-do you see anything wrong with it?:

<span style="font-family: Gentium; font-size: 1.1em;">
ini </span>{:MULTICHOICE:2-lit.#The correct answer is 3ae-inf.~2ae-gem.#The correct answer is 3ae-inf.~3-lit.#The correct answer is 3ae-inf.~=3ae-inf.~3ae-gem.#The correct answer is 3ae-inf.~4-lit.#The correct answer is 3ae-inf.~4ae-inf.#The correct answer is 3ae-inf.~5-lit.#The correct answer is 3ae-inf.~caus.
2-lit.#The correct answer is 3ae-inf.~caus. 2ae-gem.#The correct answer is 3ae-inf.~caus. 3-lit.#The correct answer is 3ae-inf.~caus. 3ae-inf.#The correct answer is 3ae-inf.~caus. 4-lit.#The correct answer is 3ae-inf.~caus.
4ae-inf.#The correct answer is 3ae-inf.~caus. 5-lit.#The correct answer is 3ae-inf.} fetch, use {:MULTICHOICE:=transitive~intransitive}
In reply to N Hansen

Re: Help! About a cloze question

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Nicole,

I have copied and pasted your code into a cloze/embedded question in my local version of Moodle 1.6 and both sub-questions get displayed OK. No idea why you are having a problem with this code in 1.6. Are you using the very latest stable 1.6+ with regular CVS updates?

BTW I noticed you are using the Gentium font from SILorg, which I find quite nice.

Joseph

Attachment image-0000.jpg
In reply to Joseph Rézeau

Re: Help! About a cloze question

by N Hansen -
Well, it's doing strange things for me. I'll look into the database some more and tell you what is happening there.

By the way, the way to make the Gentium font look really nice is to set it to 1.1em size. It looks OK at normal size, although it looks bad in the html editor initially unless set to 1.1em.
In reply to Joseph Rézeau

It worked!

by Adán Cruz -

Hi Joseph

Thank you very much. I finally figured out how to do what you suggested (as I said I am new to all this.

Now the image you sent me looks very nice (with color and everything) so I tried to give it a little life but I couldn't. I copied the text into a table in the html editor and then I selected a color for the background but it still appears in a white background. Could you help with that?

Thanx in advance

In reply to Joseph Rézeau

Re: Help! About a cloze question

by Alexander Kuo -
Hi Joseph,
    I try it in my site and I get the following result as attachment. I just copy and paste the code into the question text using HTML editor. So the attached image has a blue background. Because I have disabled the new plugin "get-html.js" in htmlarea.php as bug 6106, it works fine. Do you notice the difference between yours and mine? In your image, there is a empty line between two questions, but no any empty line between two questions in mine. Ok, now please check your question text in your HTML editor. There must be no empty line between two questions. We can come to the conclusion that the new plugin "get-html.js" cause the non-breaking space and add a <br/> code in the end of line to display a line.       Alexander.
Attachment cloze.jpg
In reply to Alexander Kuo

Re: Help! About a cloze question

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Alexander,

The colors of my question preview come from the CSS styles defined in my own orangechoc theme. I get the result I posted through using a combination of HTML formatting (kept to a minimum) and my theme. Here is the beginning of the exact code I write into the HTML (source code) for your cloze/embedded question:

<address> Complete with should or shouldn’t. </address>

<h4>Health Watch

</h4><span style="font-weight: bold;">Q</span>: My sister never washes fruit or vegetables. She says it’s good for our bodies to eat a bit of dirt. Is she correct? <span style="font-weight: bold;">A</span>: No, you {1:MULTICHOICE:shouldn't#Sorry; try again ~=should #Excellent! } always wash fruit and vegetables before you eat them, because they may have fertilizers or pesticides on them, and these can be harmful.

Hope that helps,

Joseph