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

Weird behavior in the case of text in element but outside question #58

Closed luclaurent closed 3 years ago

luclaurent commented 3 years ago

Many authors of AMC quizz add text outside questions and automultiplechoice will render it correctly but `amc2moodle' seems to have difficulties to consider it (which can be normal). However in certains cases question(s) could not be imported in Moodle.

The following example does not work.

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais,bloc,correc]{automultiplechoice}

\begin{document}

\element{test}{
  uioygbjkbk, hhHLJmq jkjlkqjs qjlkjqs lk
  aa
  \begin{question}{qtest}
    Loui
    \begin{reponses}
      \mauvaise{ hein}
      \mauvaise{oh}
      \bonne{ah}
      \mauvaise{ouf}
    \end{reponses}
  \end{question}
}
\exemplaire{1}{
  \restituegroupe{test}
}
\end{document}

One solution seems to add a linebreak before the `\begin{question}' command:

  \documentclass{article}
  \usepackage[utf8x]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage[francais,bloc,correc]{automultiplechoice}

  \begin{document}
  \element{test}{
    uioygbjkbk, hhHLJmq jkjlkqjs qjlkjqs lk
    aa

    \begin{question}{qtest}
      Loui
      \begin{reponses}
        \mauvaise{ hein}
        \mauvaise{oh}
        \bonne{ah}
        \mauvaise{ouf}
      \end{reponses}
    \end{question}
  }
  \exemplaire{1}{
    \restituegroupe{test}
  }
  \end{document}

The XML formatter is able to isolate the text before the \begin{question} in a paragraph <p>...</p> and this syntax seems to be accepted by Moodle.

amc2moodle v2.9.0 was used to diagnose this trouble.

luclaurent commented 3 years ago

Notice that we can decide to remove the text before the question if it is preferable but we need to add a warning. A minimal behavior is that the question can be imported in Moodle (with or without the text in the element block).

nennigb commented 3 years ago

I will have a look on that. The problem is that the actual mapping between tex \element and moodle category is too crude. The first argument is mapped into category name and it's fine, the second one contains the questions and everything the user want. For instance, some amc users use \element as common description for all the questions from the block (see https://github.com/nennigb/amc2moodle/issues/20#issuecomment-653435909)

The latexml output for your exemple are

Some possible workarounds/remarks,