marcusgreen / moodle-qtype_gapfill

Fill in the blanks question type with very easy to learn syntax
6 stars 20 forks source link

Markdown Not Working / Forced Linebreak Before Input #89

Open HelloLudger opened 2 years ago

HelloLudger commented 2 years ago

Describe the bug A forced linebreak breaks markdown. This makes tables and good looking questions impossible.

To Reproduce

## GapFill Test
Name three numbers between 1 and 10.

---

This ist an [inline] test.

 #        |  Answer
--------- | ------------------------------------
 prove    | that the table should be working 
 a)       | [2|3|4|5|6|7|8|9] 
 b)       | [2|3|4|5|6|7|8|9] 
 c)       | [2|3|4|5|6|7|8|9]

And set questiontext format to markdown.

Expected behavior No line break before inputs and therefor functioning tables.

Screenshots

image

This problem seems to be exclusive to markdown. Unformatted text looks like this:

image

Other:

Question as Moodle-XML (renamed to TXT): MarkdownNotWorking.txt

HelloLudger commented 2 years ago

Problem seems to be, that they are not wrapped in a <p> tag:

image
marcusgreen commented 2 years ago

Thank you for the feedback, can you confirm that your second message indicates it is still not working as you expect. I have never taken account of or used the question type with Markdown, though I probably should. You can see here some examples that illustrate what I have tried with it. https://github.com/marcusgreen/moodle-qtype_gapfill/blob/master/examples/en/gapfill_examples.xml Let me know your thoughts.

HelloLudger commented 2 years ago

Yes, I can confirm that it's still not working. The problem is: the question text [A|B|C] sometext is converted to

<input ..../>
<p>sometext<p/>

but it should become

<p><input ..../> sometext<p/>

Since you're not doing the markdown conversion, it might be the order in which you're calling the text-conversation? Do you call it for the input and the rest of text in the line separately?

HelloLudger commented 2 years ago

A solution seems to be to change line 83-92 in https://github.com/marcusgreen/moodle-qtype_gapfill/blob/5aa766b49a733475ef42d20f83ba8396bec7e169/renderer.php from

        foreach ($question->textfragments as $place => $fragment) {
            if ($place > 0) {
                $questiontext .= $this->embedded_element($qa, $place, $options, $markedgaps);
            }
            // Format the non entry field parts of the question text.
            // This will also ensure images get displayed.
            $questiontext .= $question->format_text($fragment, $question->questiontextformat,
                $qa, 'question', 'questiontext', $question->id);

        }

to

        foreach ($question->textfragments as $place => $fragment) {
            if ($place > 0) {
                $questiontext .= $this->embedded_element($qa, $place, $options, $markedgaps);
            }
            $questiontext .= $fragment;
        }
        // Format the non entry field parts of the question text.
        // This will also ensure images get displayed.
        $questiontext = $question->format_text($questiontext, $question->questiontextformat,
            $qa, 'question', 'questiontext', $question->id);

Not sure about possible sideeffects.

HelloLudger commented 2 years ago

Seems to work:

image
marcusgreen commented 2 years ago

Hi Ludger, I have been going over the outstanding issues and I noticed I have not addressed this. It is still on my ToDo list to investigate.