nennigb / amc2moodle

amc2moodle, is an automatic tool to convert multiple choice quiz between auto-muliple-choice LaTeX format and moodle XML format.
GNU General Public License v3.0
20 stars 8 forks source link

Trouble with long equation after update in Moodle due to '%' added during processing #27

Open luclaurent opened 4 years ago

luclaurent commented 4 years ago

Considering the following file:

\documentclass{article}
% \usepackage[combine]{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{array}
\usepackage[francais,bloc,correc]{automultiplechoice}
\usepackage{multicol}
\usepackage{subfig}
\usepackage{graphics}
\newcommand{\vect}[1]{\overrightarrow{#1}}

\graphicspath{{figures/}} 

\begin{document}
\element{dynaS3}{
    \begin{question}{accS3S0tttt}%\bareme{\barQmult}
        \`A partir des résultats précédents, donner l'expression dans la base $(\vect{x_1},\vect{y_1},\vect{z_0})$ de l'accélération du point $G_3$ lié à $S_3$ dans son mouvement par rapport à $R_0$:
        \[\vect{\Gamma_{({G_3},S_3/R_0})}\]
        \begin{reponses}
            \mauvaise{$(\ddot{\lambda}-\lambda\dot{\theta}_{1}^{2})\vect{x_{1}}+(\lambda\ddot{\theta}_{1}+2\dot{\lambda}\dot{\theta}_{1})\vect{y_{1}}$}
            \mauvaise{$\ddot{\lambda}\vect{x_{1}}+\lambda\ddot{\theta}_{1}\vect{y_{1}}$}
            \bonne{$\ddot{\lambda}\vect{x_{1}}$}
            \mauvaise{$\ddot{\lambda}\vect{x_{1}}+(\lambda\ddot{\theta}_{1}+\dot{\lambda}\dot{\theta}_{1})\vect{y_{1}}$}
        \end{reponses}
    \end{question}
}

\exemplaire{1}{
    \restituegroupe{dynaS3}
    \AMCcleardoublepage
}

\end{document}

After processing with amc2moodle, the following xml file is built:

``` $course$/amc/dynaS3 trueaccS3S0ttttÀ partir des résultats précédents, donner l’expression dans la base \((\overrightarrow{x_{1}},\overrightarrow{y_{1}},\overrightarrow{z_{0}})\) de l’accélération du point \(G_{3}\) lié à \(S_{3}\) dans son mouvement par rapport à \(R_{0}\) :

$$\begin{equation} \overrightarrow{\Gamma_{({G_{3}},S_{3}/R_{0}})} \end{equation}$$ ]]>
-50.0-50.0100.0-50.01.0trueabc
truemomentdynamiqueS3S0G3ttttExprimer dans la base \((\overrightarrow{x_{1}},\overrightarrow{y_{1}},\overrightarrow{z_{0}})\) , le moment dynamique de \(S_{3}\) dans son mouvement par rapport à \(R_{0}\) exprimé en \(O\) :

$$\begin{equation} \overrightarrow{\delta_{(O,S_{3}/R_{0})}} \end{equation}$$ ]]>
-50.0-50.0100.0-50.01.0trueabc
```

The XML file could be loaded in Moodle. The following question is obtained:

image

But if you update the question or parameters of the question in Moodle (for instance only by clicking on Enregistrer les modifications et continuer (Save and continue), you obtain the following result:

image

As you see some parts of the answers disappear. This trouble seems to be due to two elements:

nennigb commented 4 years ago

I cannot to reproduce your problem on moodle 3.8 (sandbox) neither on our moodle 3.0 server with the default editor. By the way, the % is not suitable here (and the % handling of moodle is strange). This percent is probably added to escape the \n.

I found an hint here : there is a variable called $UNTEX_LINELENGTH that limit the size of token. As far as I understand, it's hard coded. Perhaps, we could just replace %\n by a space. It can be done

What do you think ? May this pattern have collision ?

luclaurent commented 4 years ago

I think the second proposition is better. I am not sure this pattern could have collision but I must try to manually add % in the LaTeX file to check if for instance a comment at the end of a line is removed by latexml or not (if not it could engender some conflicts).

luclaurent commented 3 years ago

Answer from LaTexML's developer: no solution is available in LaTeXML. Best way seems to remove %\n with regex. Collision could appear with intentional adding of %\n (maybe not :-))

nennigb commented 3 years ago

OK. I have the same problem this morning on my quiz ;-) Do you plan do to it ?

luclaurent commented 3 years ago

Yes but not this week.

luclaurent commented 3 years ago

Add new test process!!

luclaurent commented 1 year ago

Follow https://github.com/brucemiller/LaTeXML/pull/2024 and maybe adapt to future LateXML release.