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

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

Open
luclaurent opened this issue Jun 30, 2020 · 7 comments · Fixed by #56
Open

Comments

@luclaurent
Copy link
Collaborator

luclaurent commented Jun 30, 2020

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:

<?latexml class="article"?>
<?latexml package="inputenc" options="utf8x"?>
<?latexml package="fontenc" options="T1"?>
<?latexml package="amsmath"?>
<?latexml package="array"?>
<?latexml package="automultiplechoice" options="francais,bloc,correc"?>
<?latexml package="multicol"?>
<?latexml package="subfig"?>
<?latexml package="graphics"?>
<?latexml graphicspath="/Users/luclaurent/Documents/1PRO/Enseignement/CNAM/HTT_MEC121/ExamensPartiels/2019_Examen2/figures"?>
<?latexml RelaxNGSchema="LaTeXML"?>
<quiz>
  
  
  <question type="category"><category><text>$course$/amc/dynaS3</text></category></question>
  <question type="multichoice"><single>true</single><name><text>accS3S0tttt</text></name><questiontext format="html"><text><![CDATA[
      
        <p>À 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}\)
    :</p>
        
          
    $$\begin{equation}
           \overrightarrow{\Gamma_{({G_{3}},S_{3}/R_{0}})}
    \end{equation}$$
    
        
        
        
        
        
      
    ]]></text></questiontext><answer format="html" fraction="-50.0"><text><![CDATA[
           \((\ddot{\lambda}-\lambda\dot{\theta}_{1}^{2})\overrightarrow{x_{1}}+(\lambda%
\ddot{\theta}_{1}+2\dot{\lambda}\dot{\theta}_{1})\overrightarrow{y_{1}}\)
    ]]></text><fraction>-50.0</fraction></answer><answer format="html" fraction="-50.0"><text><![CDATA[
           \(\ddot{\lambda}\overrightarrow{x_{1}}+\lambda\ddot{\theta}_{1}\overrightarrow{y%
_{1}}\)
    ]]></text><fraction>-50.0</fraction></answer><answer format="html" fraction="100.0"><text><![CDATA[
           \(\ddot{\lambda}\overrightarrow{x_{1}}\)
    ]]></text><fraction>100.0</fraction></answer><answer format="html" fraction="-50.0"><text><![CDATA[
           \(\ddot{\lambda}\overrightarrow{x_{1}}+(\lambda\ddot{\theta}_{1}+\dot{\lambda}%
\dot{\theta}_{1})\overrightarrow{y_{1}}\)
    ]]></text><fraction>-50.0</fraction></answer><defaultgrade>1.0</defaultgrade><shuffleanswers>true</shuffleanswers><answernumbering>abc</answernumbering></question>
  <question type="multichoice"><single>true</single><name><text>momentdynamiqueS3S0G3tttt</text></name><questiontext format="html"><text><![CDATA[
      
        <p>Exprimer 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\)
    :</p>
        
          
    $$\begin{equation}
           \overrightarrow{\delta_{(O,S_{3}/R_{0})}}
    \end{equation}$$
    
        
        
        
        
        
      
    ]]></text></questiontext><answer format="html" fraction="-50.0"><text><![CDATA[
           \(A_{3}(\dot{\omega}_{x}\overrightarrow{x_{1}}+\omega_{x}\dot{\theta}_{1}%
\overrightarrow{y_{1}})+[(C_{3}+m_{3}\lambda^{2})\ddot{\theta}_{1}+2m_{3}\dot{%
\lambda}\lambda\dot{\theta}_{1}]\overrightarrow{z_{0}}\)
    ]]></text><fraction>-50.0</fraction></answer><answer format="html" fraction="-50.0"><text><![CDATA[
           \(C_{3}\ddot{\theta}_{1}\overrightarrow{z_{0}}\)
    ]]></text><fraction>-50.0</fraction></answer><answer format="html" fraction="100.0"><text><![CDATA[
           \(A_{3}\dot{\omega}_{x}\overrightarrow{x_{1}}+C_{3}\ddot{\theta}_{1}%
\overrightarrow{z_{0}}\)
    ]]></text><fraction>100.0</fraction></answer><answer format="html" fraction="-50.0"><text><![CDATA[
           \(A_{3}(\dot{\omega}_{x}\overrightarrow{x_{1}}+\omega_{x}\dot{\theta}_{1}%
\overrightarrow{y_{1}})+(C_{3}+m_{3}\lambda^{2})\ddot{\theta}_{1}%
\overrightarrow{z_{0}}\)
    ]]></text><fraction>-50.0</fraction></answer><defaultgrade>1.0</defaultgrade><shuffleanswers>true</shuffleanswers><answernumbering>abc</answernumbering></question>
</quiz>

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:

  • latexml add some % in the long equations that is not necessary.
  • my Moodle server uses a WYSIWYG editor that could alterate the result provided by amc2moodle
@nennigb
Copy link
Owner

nennigb commented Jul 1, 2020

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

  • in xslt during the equation processing, I will have a look to see how to do that
  • in python for the whole file (easier!), maybe in convert.py after xml = open(os.path.join(wdir, filein), 'r')

What do you think ? May this pattern have collision ?

@luclaurent
Copy link
Collaborator Author

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

@luclaurent
Copy link
Collaborator Author

luclaurent commented Nov 17, 2020

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

nennigb commented Nov 23, 2020

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

@luclaurent
Copy link
Collaborator Author

Yes but not this week.

@luclaurent
Copy link
Collaborator Author

Add new test process!!

@luclaurent luclaurent pinned this issue Dec 16, 2022
@luclaurent
Copy link
Collaborator Author

Follow brucemiller/LaTeXML#2024 and maybe adapt to future LateXML release.

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

Successfully merging a pull request may close this issue.

2 participants