Ошибка загрузки в Moodle при использовании матричной среды

Ошибка загрузки в Moodle при использовании матричной среды

Я пытаюсь загрузить тест в Moodle в первый раз и генерирую свои файлы с помощью пакета {Moodle}. Проблема в том, что загруженный файл не распознает среду матрицы и отображает код вместо формы матрицы. Есть ли решение для этого?

\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}

решение1

Theруководстводля moodle.sty(страница 10) упоминает, что только четыре среды распознаются и преобразуются в html: center, enumerate, itemizeи tikzpicture. Все остальные среды, такие как matrix, поэтому не могут быть использованы. Цитата (выделено мной):

Имейте в виду, что moodle.sty не умеет конвертировать любые другие команды TEX или LATEX в HTML. Если используются другие последовательности, они могут быть принято дословнов XML-файл или может привести к непредсказуемым результатам.

Однако в пределах tikzpictureвы можете использовать код LaTeX внутри node, что позволяет вам использовать matrixсреду. Матрицы будут преобразованы в изображения Moodle и сохранены в кодировке base64 в .xmlфайле, аналогично включению .pngфайлов, например.

Обратите внимание, что для этого может потребоваться \tikzexternalizeявный вызов в исходном коде вашего теста. Также shell-escapeтребуется (как и с изображениями).

МВЭ:

\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}

Часть полученного XML:

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

решение2

Лучшим решением, по-видимому, будет заменить его matrixна arrayтот, который предлагает Moodleруководство, следующее:

\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}

Важная заметка: опубликованная в настоящее время moodleверсия пакета 0.5 устарела и имеет ошибку, которая не обрабатывает \\. Вам необходимо загрузить последнюю версию сздесь. Инструкции по установкездесь.

Связанный контент