possible bug in the Cloze question type

possible bug in the Cloze question type

by Daniel McCloy -
Number of replies: 9
Moodle 1.9.8

Every time I go to edit an existing Cloze question, it shows up as "moodle auto-format" on the edit page, rather than what I saved it as (typically "HTML format"). Can anyone else confirm / replicate this, before I add it to the bug tracker?
Average of ratings: -
In reply to Daniel McCloy

Re: possible bug in the Cloze question type

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

1.- Are you sure this is moodle 1.9.x? It is a known bug in forthcoming 2.0, being solved right now.

2.- If moodle 1.9.x, then probably you have changed the "When editing text" setting in your user profile. If that is the case, then you should see exactly the same formatting problem in editing any of your moodle course resources or activities, not just Question.

ATB

Joseph

In reply to Joseph Rézeau

Re: possible bug in the Cloze question type

by Daniel McCloy -
Definitely 1.9.x (not 2.x)

I definitely do have the "when editing text" set to "use standard web forms" because I find the moodle rich text editor to be clunky and prefer to write my own HTML. But maybe you misunderstand my problem: I'm not complaining about the presence/absence of the rich text editor. I'm complaining about the "Format" setting that is just below the "Question Text" box. When I write a multichoice question and set the "format" to "HTML format", save it, then come back to edit it again, the Format setting is preserved. When I do the same with a Cloze question, the Format setting is not preserved (always resets to "Moodle autoformat").
In reply to Daniel McCloy

Re: possible bug in the Cloze question type

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
OK, I understand you better now. But I still do not see why this is an issue. If you format your cloze question text with html tags and save it as HTML, even though when you edit it again it appears in the Moodle auto-format (whatever that is, I have no ideasurprise), the HTML tags are there, so your question will be correctly displayed formatted.
So, what is the issue?
Joseph
In reply to Joseph Rézeau

Re: possible bug in the Cloze question type

by Daniel McCloy -
I am shocked to hear you say "I don't see why this is an issue." I admit that it's an annoyance bug, not a work-stopping catastrophic bug, but the system shouldn't change settings that I have explicitly set. The real problem arises not the first time I go to edit a cloze question, but the second time (after having failed to realize/remember that I needed to set the format anew each time). Here is an example of what happens if I go to edit a cloze question and forget to re-specify HTML format. Code that originally looked like this:

<span style="font-family: charis sil,doulos sil,arial unicode ms,lucida grande;">Given the following phonemic inventory:<br /><span style="font-size: 14pt;">[p b t k ɡ ʔ s h i a o]</span><br />What feature(s) pick out the following natural class?<br /><span style="font-size: 14pt;">[p b t k ɡ s i a o]</span></span>

Now looks like this (weird moodle auto-format additions highlighted in red):

<span style="font-family: charis sil,doulos sil,arial unicode ms,lucida grande;">Given the following phonemic inventory:<br /><span style="font-size: 14pt;">[p b t k ɡ ʔ s h i a o]</span><br />What feature(s) pick out the following natural class?<br /><span style="font-size: 14pt;">[</span></span><span style="font-family: charis sil,doulos sil,arial unicode ms,lucida grande;"><span style="font-size: 14pt;">p b t k ɡ s i a o</span></span><span style="font-family: charis sil,doulos sil,arial unicode ms,lucida grande;"><span style="font-size: 14pt;">]</span></span>

This is one of the milder examples; I already fixed some more atrocious ones yesterday. And before you further object that this particular moodle auto-formatting doesn't actually change the appearance of the final HTML output that the user sees, I will testify that has not always been the case. Furthermore, regardless of what the end user sees, it is still an issue with respect to the system's usability for the question author/editor.
In reply to Daniel McCloy

Re: possible bug in the Cloze question type

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

Hi Daniel,

Maybe this is an issue on your moodle installation, but I cannot replicate the problem on my own moodle. If I type your example, save it as HTML, then edit it, it does say that is is using Moodle auto-format, I save again (keeping Moodle auto-format), re-edit, re-save, etc.... nothing changes, I do not get the weird added code you mention in your post.

(by the way, your example is not a complete cloze question, could you please provide the full cloze question text?)

Your problem must come from something else on your Moodle site, maybe a filter, as suggested by Nadav. Or else it might be the formatting engine which is proper to the Cloze question type which does weird things (but again, I cannot replicate this).

And the behavior you are seeing is quite normal. If your user profile is set to "use standard web forms", then you cannot save your edited text as HTML format, simply because you have not been editing it in the HTML editor. So, when you re-edit it, it is shown in Moodle auto-format.

If you change your profile from "use standard web forms" to "Use HTML editor" then, when you go to re-edit your question, it will be shown in the HTML editor, and underneath the editor it will say "Format : HTML format ".

I agree that there is something wrong with the interface: when you are editing in a "plain text" window, i.e. not using Moodle's HTML editor, then the Format dropdown list should only display : Moodle auto-format; PLain text and Markdown. HTML format should not be listed simply because you cannot save in HTML format a text which has been not been typed using the HTML editor.

I hope this makes things clearer. If you have some examples of "atrocious" re-formatting of your Cloze questions text, I'll be happy to test them out.

Finally, ... why not use Moodle's friendly HTML editor and avoid all those problems?wink

ATB,

Joseph

In reply to Joseph Rézeau

Re: possible bug in the Cloze question type

by Daniel McCloy -
I already mentioned why I don't use the built-in HTML editor: I find it clunky, meaning essentially that it doesn't save me time. Often I write the HTML for my questions in an external editor (one with syntax highlighting), then paste into moodle. Furthermore, the example given should make clear another reason why the built-in editor is dispreferred: because of the need to display characters in the higher planes of Unicode -- often with odd diacritics that many fonts don't include or don't handle smoothly -- I need to specify fonts that are not part of the default choices in the dropdown box. So I would need to click the "Toggle HTML source" button anyway to write that bit of code myself, so why not just skip that extra click, and hide all the rich text buttons that I never use anyway? That is why in my profile I chose "use standard web forms." But why I should have to justify this is a bit beyond me.

Your reply makes clear to me why this apparent bug occurs: apparently saving a question as HTML format is only allowed if the fancy editor is enabled. This baffles me. Why is it like this? Maybe I don't understand the inner workings of the system, but I see no reason in principle why the absence of the editing tools should prevent the question being saved as HTML.

I will do some further testing next week (we're just at end of term now and I've a lot to do) to see if I can narrow down the precise cause of this rogue code. I'm not sure what you mean by "a filter"... to my knowledge our moodle install is very vanilla, but I'll ask the backend support people to see what they have to say about any customizations that might be causing this.
In reply to Daniel McCloy

Re: possible bug in the Cloze question type

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

Hi Daniel,

"Finally, ... why not use Moodle's friendly HTML editor and avoid all those problems?wink"

That was a joke. Of course you do not have to justify your choice of editor in Moodle.

Now, just to dissipate some misunderstanding.

The Moodle format documentation makes it clear that the Moodle auto-format format can include HTML tags. Normally, it does not do anything less than what you do in HTML code, it tries to do (just a bit) more, by automatically making smileys and URLs. So it should really work for what you are doing, and I see no reason why it would add spurious code. So the question of whether you save your code as HTML code or Moodle auto-format does not matter in the end, because -again- Moodle auto-format can contain HTML code.

Just one thought: have you noticed the "weird moodle auto-format additions" when you type and format text in other parts of your moodle course (I mean other than the Cloze question)? If not, then the culprit would be the Cloze question itself.

Try this:

  • Add a resource -> Compose a Web page
  • copy your sample text into it and save
  • does it display OK?
  • edit it
  • has the code changed?

Which version of Moodle are using : 1.9.?

ATB

Joseph

In reply to Joseph Rézeau

Re: possible bug in the Cloze question type

by Daniel McCloy -
Sorry about the joke. I took it to be another instance of an attitude I've seen more than I'd like on this forum (an attitude I'd characterize as "why do you want to change the tool when it works just fine if you use it the way it was intended to be used?").

Regardless, here are some partial answers to your questions:

1. Last I checked, our install was 1.9.8 (as mentioned in the first post), and I haven't heard back from the techies yet whether they upgraded to 1.9.9 without telling me about it. I can guarantee we're not on 2.x yet, since I made them swear up and down they wouldn't do that without ample forewarning.

2. This problem does occur outside of the Cloze format. Cloze was the first place I noticed it, but in my haste to find an example of the spurious code that I hadn't already scrubbed, I grabbed an example that came from a multichoice question (one with multiple answers allowed, if that matters). That's why the example above doesn't look like a normal Cloze; my mistake.

In pondering this problem further, I wonder if it comes from past uses of the HTML editor (before I gave up on it), rather than from the "Moodle auto-format" setting. I know the HTML editor wreaks havoc with tables, so why not span tags too? As mentioned above I'll have to wait until next week to have time to test this.

Regardless of the eventual source of the spurious code, I think this thread suggests an improvement for the "format" settings. Suggestion:
Treat this text as: {plain text | HTML | markdown}
Auto-convert URLs to links? Y/N (checkbox)
Auto-detect smilies? Y/N (checkbox)
Average of ratings: Useful (1)