Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown Not Working / Forced Linebreak Before Input #89

Open
HelloLudger opened this issue Aug 20, 2022 · 6 comments
Open

Markdown Not Working / Forced Linebreak Before Input #89

HelloLudger opened this issue Aug 20, 2022 · 6 comments

Comments

@HelloLudger
Copy link

HelloLudger commented Aug 20, 2022

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:

  • OS: Windows 10
  • Browser: Brave v1.42.97
  • Moodle 4.0.1 (Build: 20220509)

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

@HelloLudger
Copy link
Author

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

@marcusgreen
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

HelloLudger commented Aug 20, 2022

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
Copy link
Author

Seems to work:
image

@marcusgreen
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants