Erro ao fazer upload para o Moodle ao usar o ambiente matricial

Erro ao fazer upload para o Moodle ao usar o ambiente matricial

Estou tentando enviar um Quiz pela primeira vez para o Moodle e estou gerando meus arquivos utilizando o pacote{Moodle}. O problema é que o arquivo carregado não reconhece o ambiente de matriz e exibe o código em vez do formato de matriz. Existe uma solução para isso.

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm, amssymb, latexsym}
\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols #1}}
\makeatother 
\usepackage{moodle}
   \begin{document}
   \begin{quiz}{Revisiting Linear Algebra}
     \begin{multi}[points=2]{Matrix Form of a Linear System}
       Consider the following system
              \begin{center}
       $
\begin{matrix}[r]
3.0 x_1    &+2.0 x_2     &+2.0  x_3      & -5.0 x_4 & =8 .0   \\
0.6 x_1   &+ 1.5 x_2     &+1.5 x_3       & -5.4 x_4 & =2.7 \\  
1.2 x_1   & -0.3 x_2      & -0.3 x_3      & 2.4 x_4   &  =2.1 , \\  
\end{matrix}
$
   \end{center}


which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
     The $\mathbf{A}$ matrix associated with the  system is:
\item*
 $
\begin{bmatrix}[r]
3.0    &+2.0      &+2.0        & -5.0   \\
0.6    &+ 1.5      &+1.5        & -5.4   \\  
1.2    & -0.3      & -0.3      & 2.4 , \\  
\end{bmatrix}
$
\item $
\begin{bmatrix}[r]
8 .0   \\
2.7 \\  
2.1  \\  
\end{bmatrix}
$  
  \item $
\begin{bmatrix}[r]
x_1 &\\
x_2& \\  
x_3 &\\  
x_4 &\\
\end{bmatrix}
$       
\item  
$
\begin{bmatrix}[r]
3.0    &+2.0      &+2.0        & -5.0 &  8.0 \\
0.6    &+ 1.5     &+1.5       & -5.4  & 2.7 \\  
1.2    & -0.3      & -0.3       & 2.4 , & 2.1\\  
\end{bmatrix}
$       
\end{multi}

     \begin{multi}[points=2]{Matrix Form of a Linear System}
     Consider the following system
              \begin{center}
       $
\begin{matrix}[r]
3.0 x_1    &+2.0 x_2     &+2.0  x_3      & -5.0 x_4 & =8 .0   \\
0.6 x_1   &+ 1.5 x_2     &+1.5 x_3       & -5.4 x_4 & =2.7 \\  
1.2 x_1   & -0.3 x_2      & -0.3 x_3      & 2.4 x_4   &  =2.1 , \\  
\end{matrix}
$
   \end{center}


which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
       The $\mathbf{B}$ matrix associated with the  system is:
\item*
       $
\begin{bmatrix}[r]
8 .0   \\
2.7 \\  
2.1  \\  
\end{bmatrix}
$  
\item[fraction=0] 
 $
\begin{bmatrix}[r]
3.0    &+2.0      &+2.0        & -5.0   \\
0.6    &+ 1.5      &+1.5        & -5.4   \\  
1.2    & -0.3      & -0.3      & 2.4 , \\  
\end{bmatrix}
$
  \item[fraction=0]   
 $
\begin{bmatrix}[r]
x_1 &\\
x_2& \\  
x_3 &\\  
x_4 &\\
\end{bmatrix}
$       
\item[fraction=0]   
 $
\begin{bmatrix}[r]
3.0    &+2.0      &+2.0        & -5.0 &  8.0 \\
0.6    &+ 1.5     &+1.5       & -5.4  & 2.7 \\  
1.2    & -0.3      & -0.3       & 2.4 , & 2.1\\  
\end{bmatrix}
$       
     \end{multi}     

 \end{quiz}
\end{document}

Responder1

Omanualfor moodle.sty(página 10) menciona que apenas quatro ambientes são reconhecidos e convertidos para html: center, enumerate, itemizee tikzpicture. Todos os outros ambientes, como matrix, portanto, não podem ser usados. Citação (ênfase minha):

Esteja ciente de que o moodle.sty não sabe como converter nenhum outro comando TEX ou LATEX para HTML. Se outras sequências forem usadas, elas podem ser passado literalmenteao arquivo XML ou pode causar resultados imprevisíveis.

Porém, dentro de a tikzpicturevocê pode usar código LaTeX dentro de a node, o que permite usar o matrixambiente. As matrizes serão convertidas em imagens pelo Moodle e armazenadas em codificação base64 no .xmlarquivo, semelhante à inclusão .pngde arquivos por exemplo.

Observe que para fazer isso funcionar, pode ser necessário chamar \tikzexternalizeexplicitamente o código-fonte do questionário. Também shell-escapeé obrigatório (o mesmo que com imagens).

MWE:

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm, amssymb, latexsym}
\usepackage{tikz}
\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols #1}}
\makeatother 
\usepackage{moodle}
\usetikzlibrary{external} % set this 
\tikzexternalize          % explicitly

\begin{document}
\begin{quiz}{Revisiting Linear Algebra}
\begin{multi}[points=2]{Matrix Form of a Linear System}
Consider the following system
       
\begin{tikzpicture} % matrix inside of tikzpicture node
\node{
$\begin{matrix}[r]
3.0 x_1    &+2.0 x_2     &+2.0  x_3      & -5.0 x_4 & =8 .0   \\
0.6 x_1   &+ 1.5 x_2     &+1.5 x_3       & -5.4 x_4 & =2.7 \\  
1.2 x_1   & -0.3 x_2      & -0.3 x_3      & 2.4 x_4   &  =2.1 , \\  
\end{matrix}
$};
\end{tikzpicture}

which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
The $\mathbf{A}$ matrix associated with the system is:
\item*
\begin{tikzpicture}
\node{ $
\begin{bmatrix}[r]
3.0    &+2.0      &+2.0        & -5.0   \\
0.6    &+ 1.5      &+1.5        & -5.4   \\  
1.2    & -0.3      & -0.3      & 2.4 , \\  
\end{bmatrix}
$};\end{tikzpicture}
\item\begin{tikzpicture}
\node{ $
\begin{bmatrix}[r]
8 .0   \\
2.7 \\  
2.1  \\  
\end{bmatrix}
$};\end{tikzpicture}  
  \item \begin{tikzpicture}
\node{$
\begin{bmatrix}[r]
x_1 &\\
x_2& \\  
x_3 &\\  
x_4 &\\
\end{bmatrix}
$};\end{tikzpicture}       
\item  
\begin{tikzpicture}
\node{$
\begin{bmatrix}[r]
3.0    &+2.0      &+2.0        & -5.0 &  8.0 \\
0.6    &+ 1.5     &+1.5       & -5.4  & 2.7 \\  
1.2    & -0.3      & -0.3       & 2.4 , & 2.1\\  
\end{bmatrix}
$};\end{tikzpicture}       
\end{multi}
 \end{quiz}
\end{document}

Parte do xml resultante:

<questiontext format="html">
    <text><![CDATA[<p>Consider the following system </P>
<P><IMG SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc4AAACOCAYAAAC4 etc.

Responder2

A solução de melhores práticas parece substituir matrixaquela arrayproposta pelo Moodlemanual, do seguinte modo:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{moodle}
   \begin{document}
   \begin{quiz}{Revisiting Linear Algebra}
    
     \begin{multi}[points=2]{Matrix Form of a Linear System}
       Consider the following system
       \[
        \left[
\begin{array}{ccccc}
3.0 x_1    &+2.0 x_2     &+2.0  x_3      & -5.0 x_4 & =8.0\\
0.6 x_1   &+ 1.5 x_2     &+1.5 x_3       & -5.4 x_4 & =2.7\\  
1.2 x_1   & -0.3 x_2      & -0.3 x_3      & 2.4 x_4   &  =2.1 , \\  
\end{array}\right]
\]
  
which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
     The $\mathbf{A}$ matrix associated with the  system is:   
\item* First answer
\[
 \left[
\begin{array}{cccc}
3.0    &+2.0      &+2.0        & -5.0   \\
0.6    &+ 1.5      &+1.5        & -5.4   \\  
1.2    & -0.3      & -0.3      & 2.4 , \\
\end{array}
\right]
\]
\item Second answer
\end{multi}

 \end{quiz}
\end{document}

Nota importante: a versão 0.5 do pacote atualmente publicado moodleestá desatualizada e possui um bug que não é solucionado \\. Você deve baixar a versão mais recente emaqui. As diretrizes de instalação sãoaqui.

informação relacionada