maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
140 stars 148 forks source link

Spaces sometimes display as ?? #832

Open mkraska opened 2 years ago

mkraska commented 2 years ago

I have learned that CAS text conveyed to Maxima is not unicode proof, such that I have to replace äöüß° and the like by html codes.

Yet even given that, spaces should not be problematic.

In the attached question, the spaces between validation and feedback fail to display correctly. If replaced by non-breaking space, the issue is resolved, but that would be a really annoying workaround.

<p>\(c_{0c}=\) [[input:S_cc]] [[validation:S_cc]]&nbsp;[[feedback:cc]]</p>
<p>Bestimmen Sie die Eigenkreisfrequenz des Systems.</p>
<p>\(\omega=\) [[input:S_om]] [[validation:S_om]] [[feedback:om]]</p>
<p>Welche Weg- und Beschleunigungsamplitude erreicht der Kasten bei Unwuchterregung (Radius \(r={@ru@},\) Masse \(m_u={@mu@},\) Drehzahl \(n={@nd*min@}\;\mathrm{min^{-1}}\))?</p>
<p>\(x_\max=\) [[input:S_xmax]] [[validation:S_xmax]] [[feedback:xmax]]</p>
<p>\(\ddot x_\max=\) [[input:S_amax]] [[validation:S_amax]] [[feedback:amax]]</p>

image

quiz-T-B5-MB-TM3-TM3 12 01 [DE] excited vibrations excenter-20220807-0935.zip

aharjula commented 2 years ago

Gotta wonder just how you do those non-breaking spaces? If you do those as entities, then there should not be any issues but if you are using Unicode for those spaces, then the same issue you have with umlauts etc., is causing issues with the spaces as well.

To my knowledge, ASCII does not have a non-breaking space, and any such space is, therefore, a member of some other encoding if not presented as an entity. You should just fix your Maxima installation or its execution settings so that it would execute using Unicode and you would not need to play with entities.

The question marks are probably an artefact of mangled Unicode caused by the PHP side sending Unicode into a Maxima not ready to receive it and expecting Unicode to return from it. Those question marks are probably not actually question marks but instead some characters that have not been defined as Unicode character points or are not present in whatever font you are using.

To fix this, your STACK settings in Moodle need to be tuned so that the Maxima command gets prefixed with an environment adjustment that makes sure that the Maxima process gets executed with the correct locale settings. What the settings are, depends on the locales installed on your server. Any locale with "UTF-8" in its name should work it just needs to be present on that server. What you describe simply lets me believe that you are executing things with a default locale of C or ASCII and those just won't work. Alternatively, your Maxima is older than 5.38, i.e. over five years old and does not support Unicode at all.

As previously instructed, simply set the Maxima command setting as LC_ALL=en_GB.UTF-8 /bin/maxima (with a locale you have, depending on OS LC_LANG might be LANG) and clear the caches and regenerate any images. The test character on the healtcheck page should immediately tell you when the settings are correct.

mkraska commented 2 years ago

I convey the maxima instructions to our admin, let's see whether he this time can fix it. As long as this isn't done, I promise to not report any unicode related issues.

I use a plain text editor (marklar), so inserting non-breaking space is done by inserting the text &nbsp; just with the keyboard. When I have replaced all my JSXGraph stuff by external links I probably can go back to the standard editor.

I assume that the editor produces just ascii text, so I was surprised by the problems with spaces.