
我正在使用“moodle”套件透過 Latex 建立 Moodle XML 測驗。一般來說,它工作得很好,但我遇到了問題。如果您不熟悉該包,我可以使用環境數值來建立數值答案,如下所示:
\begin{numerical}
What is 2+2?
\item[tolerance=0.5] 4
\end{numerical}
這一切都運作良好,該套件會產生一個 PDF 和一個 XML 文件,可以將其上傳到我的 Moodle 網站。但如果我使用帶有科學記數法的值,我就會遇到問題,例如
\begin{numerical}
What is the charge on an electron?
\item[tolerance=1e-20] 1.602e-19
\end{numerical}
在本例中,它抱怨“e”是非法的測量單位,並使用“pt”代替。我沒有得到太多的運氣搜索,我不認為這是一個廣泛使用的包或它正在積極開發中。這可能是個包裝問題,還是有特定的格式可以為這樣的乳膠參數輸入科學記數法數字?這可能嗎!我嘗試過大寫和小寫“e”
答案1
該moodle
套件嘗試確定容差是否設定為 0,以便$\pm$ (tolerance)
在 PDF 中顯示 a。為此,包因為它內部依賴 TeX 的尺寸
您可以透過刪除此測試來解決問題。在序言中,載入moodle
包後,添加以下程式碼:
\makeatletter
\def\moodle@print@numerical@answer@int@int#1\@rdelim{%
\edef\moodle@numericalprint@tolerance{\noexpand\pm\moodle@tolerance}%
\ifx\moodle@fraction\@hundred
\item $#1\moodle@numericalprint@tolerance\quad\checkmark$%
\else
\item $#1\moodle@numericalprint@tolerance$\quad (\moodle@fraction\%)%
\fi
}%
\def\moodle@print@clozenumerical@answer@int@int#1\@rdelim{%
\ifx\moodle@fraction\@hundred
\def\moodle@clozenumericalprint@fraction{$\checkmark$}%
\else
\edef\moodle@clozenumericalprint@fraction{(\moodle@fraction\%)}%
\fi
\edef\moodle@clozenumericalprint@tolerance{\noexpand\pm\moodle@tolerance}%
\xdef\moodle@clozenumericalprint@line{$#1\moodle@clozenumericalprint@tolerance$
& \moodle@clozenumericalprint@fraction}%
\xa\g@addto@macro\xa\cloze@numerical@table@text\xa{\moodle@clozenumericalprint@line
\\}%
}%
\makeatother
編譯和Moodle導入都會成功。