Multilang, old bug is back

Multilang, old bug is back

by Michiel Open Forest -
Number of replies: 13

https://moodle.org/mod/forum/discuss.php?d=117868#p524770

This bug is back! Multilang tags are broken/ignored in the questionnaire

The patch mentioned here has been removed: https://moodle.org/mod/forum/post.php?forum=469

Current code of locallib.php:

    // Look for named modalities.
    $contents->text = $content;
    // DEV JR from version 2.5, a double colon :: must be used here instead of $
    if ($pos = strpos($content, '::')) {
        $contents->text = substr($content, $pos + 2);
        $contents->modname = substr($content, 0, $pos);
    }
    return $contents;

Average of ratings: -
In reply to Michiel Open Forest

Re: Multilang, old bug is back

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

What version of questionnaire are you seeing the problem in?

Can you provide a new link to the patch you mentioned? The link you posted isn't valid.

mike

In reply to Mike Churchward

Re: Multilang, old bug is back

by Michiel Open Forest -

Apologies. Correct link: https://tracker.moodle.org/browse/CONTRIB-1128

# head releasenotes.txt
Release Notes

Version 2.7.0 (Build - 2014070400) BETA (github only)



In reply to Michiel Open Forest

Re: Multilang, old bug is back

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Since you are using a BETA version, you should upgrade to the latest 2.7 stable release first.

I don't see anything in there that looks wrong though.

mike

In reply to Mike Churchward

Re: Multilang, old bug is back

by Michiel Open Forest -

Here is a screenprint. Question title shows the <span> tags; the question text hides the tags but shows the two languages.

Multilang works fine in Moodle except for the Questionnaire.
I am using Moodle 2.8.1+ (Build: 20141224). According to the Moodle changelog there are no recent changes related to questionnaire/multilang.
http://git.moodle.org/gw?p=moodle.git;a=log;h=refs/heads/MOODLE_28_STABLE;opt=--no-merges

In reply to Michiel Open Forest

Re: Multilang, old bug is back

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

You should also upgrade your questionnaire instance to the latest Moodle 2.8 release.

From your screen capture, its unclear where the HTML tags are coming from. What specific part of the questionnaire did you put those tags in?

mike

In reply to Mike Churchward

Re: Multilang, old bug is back

by Michiel Open Forest -

Hi Mike,

Re questionnaire: I use the latest version (2.8.0 (Build - 2014112000) (2014111000)); downloaded from https://moodle.org/plugins/download.php/7544/mod_questionnaire_moodle28_2014111000.zip

I redownloaded/rechecked today; releasenotes.txt in that zip contains the text: Version 2.7.0 (Build - 2014070400) BETA (github only). Anyway, I am using the most recent version.

Screenprints attached show where I added the span tags.

  • Title (in advanced settings): <span> tags show up in the output.
  • Additional info (in advanced settings) is displayed properly.
  • Question text (in questions): <span> tags are removed but both languages are shown.

Input:



Output:

In reply to Michiel Open Forest

Re: Multilang, old bug is back

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Thanks. Can you post the full text you have put into those boxes? I's like to test it locally with what you are using.

mike

In reply to Mike Churchward

Re: Multilang, old bug is back

by Michiel Open Forest -

Questionnaire:

Title: <span lang="EN" class="multilang">Exercise 1</span><span lang="NL" class="multilang">Oefening 1</span>

Description: <span class="multilang" lang="EN">
The following exercise requires you to write in your notebook (or for modern folks, just fill out the online form!). Make sure you have the time and space to do this without distractions. This exercise aims at identifying your top interfering thoughts, feelings, emotions and behaviours. These will be explored in more detail in future sessions.
</span>
<span class="multilang" lang="NL">
In de volgende oefening maak je notities in je notitieblok (of je kunt natuurlijk het online formulier invullen!). Zorg ervoor dat je de tijd en de ruimte hebt om dat zonder afleiding te doen. Deze oefening is gericht op het identificeren van je belangrijkste storende gedachten, gevoelens, emoties en gedragingen. Deze zullen in toekomstige sessies in meer detail worden onderzocht.
</span>

Question text: <span class="multilang" lang="en">
<p>Write for three to seven minutes on the following topic:
</p><p>
Describe the impact of ADHD on your life. What are the main difficulties you have experienced as a result of ADHD? What are some of the messages you tell yourself about you and your ADHD-related actions? How do you feel when things turn out badly? How does your ADHD impact on you and others?
</p>
</span>
<span class="multilang" lang="nl">
<p>Schrijf gedurende drie tot zeven minuten over het volgende onderwerp:
</p><p>
Beschrijf de impact van ADHD op jouw leven. Wat zijn de belangrijkste problemen die je hebt ervaren als gevolg van ADHD? Wat zijn enkele van de dingen die je jezelf vertelt over jou en je ADHD-gerelateerde acties? Hoe voel je je als dingen slecht uitpakken? Hoe heeft jouw ADHD invloed op jou en anderen?
</p>
</span>
In reply to Michiel Open Forest

Re: Multilang, old bug is back

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Thanks. There seems to be two issues at play with what you have above...

First one, is that I don't think the questionnaire "title" field has ever been coded for filters. I'll have to look back and see if there were known issues surrounding that. If you thing it did work once, let me know what version.

The second one seems to be the way you have your text. If I take out the "<p>" and "</p>" tags from your essay question, then the filter works as expected. I'm not sure if that's expected behavior for the mult-lang filter, or if there is a different function to call for text with more formatting.

mike

In reply to Mike Churchward

Re: Multilang, old bug is back

by Michiel Open Forest -
Hi Mike,
Thank you for your debugging.
  1. This was my first try with the questionnaire. Afaik standard Moodle behaviour is to filter for multilang in titles too. It does work in other plugins.
  2. multilang should have no problems with the <p> tags; e.g., I use them in pages without issues.

Michiel


In reply to Michiel Open Forest

Re: Multilang, old bug is back

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

It looks like the display functions in questionnaire have never been brought up to date with the current renderer methods. As far as standard Moodle behavior titles, the multilanguage filter does work on the module title, just not the extra questionnaire title. And from what I can tell, never has. It will also have to be rewritten with the new display functions.

This will unfortunately require a large refactor.

If you want to hack your code in the meantime, here are some changes you can do:

In "/mod/questionnaire/questionnaire.class.php::print_survey_start", line 814, change:

echo '<h3 class="surveyTitle">'.s($this->survey->title).'</h3>';

to

echo '<h3 class="surveyTitle">'.format_text($this->survey->title, FORMAT_HTML).'</h3>';


In "/mod/questionnaire/questionnaire.class.php::questionstart_survey_display", line 931, change:

        echo format_text(file_rewrite_pluginfile_urls($this->content, 'pluginfile.php',
            $this->context->id, 'mod_questionnaire', 'question', $this->id), FORMAT_HTML);

to

        $options = array('noclean' => true, 'para' => true, 'filter' => true, 'context' => $this->context, 'overflowdiv' => true);
        echo format_text(file_rewrite_pluginfile_urls($this->content, 'pluginfile.php',
            $this->context->id, 'mod_questionnaire', 'question', $this->id), FORMAT_HTML, $options);

mike

In reply to Mike Churchward

Re: Multilang, old bug is back

by Michiel Open Forest -
Thank you for the update. Glad we found the culprit (and it was not me using legacy or beta versions smile )