marcusgreen / moodle-qtype_wordselect

langHighlight words by clicking e.g. select all nouns in this sentence

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird html output

rschrenk opened this issue · comments

Hello,
This fabulous question type stopped working for us. An investigation showed that phpQuery, that we use to modify the DOM before it is sent to the client, can not process the DOM correctly, when a wordselect-question is shown.

Checking the output of the question I realized that there seem to be an error with the nesting of elements. Many html elements are written as start- and endtag (like you have in
), but I think that they should be nested, here are two examples:

  • </div />

    <input type="checkbox" ...

  • ****

As far as I understand your plugin this should be something produced by your renderer: https://github.com/marcusgreen/moodle-qtype_wordselect/blob/master/renderer.php#L43 In line 52 you open the div, in line 53 you apply filters to the question text and in line 54 you close the div.

Is it possible that Moodle closes the div from line 52 before it prints the output of $question->format_text, and then prints a </div /> when you just want to "close" a div that was never opened?

Kind regards

Ok - I just saw that the version we had installed (2019112200) uses "html_writer::empty_tag" for the output. The new version (that I referred to above) is using "start_tag" and "end_tag". Using the latest masterbranch worked as solution.

My kind of solution :)