使用 moodle.sty 在 moodle 测验中插入图像

使用 moodle.sty 在 moodle 测验中插入图像

我正在尝试使用 moodle.sty 包,但对图像有疑问。问题是生成的 xml 文件对图像不正确(当我查看 Moodle 中的 html 代码时,我得到的是“”。base64 之后缺少图像,我的 tex 文件如下

提前感谢你的帮助

\documentclass[12pt]{article}
\usepackage{moodle}
\usepackage{graphicx}

\usepackage{xpatch}
\makeatletter
\def\graphicspath#1{\def\Ginput@path{#1}\edef\moodleimgpath{\@firstofone#1}}

\xpatchcmd{\moodle@includegraphics@int@int}%
{\openssl\otherspace enc -base64 -in #2.png -out #2.enc}%
{\openssl\otherspace enc -base64 -in \moodleimgpath#2.png -out #2.enc}%
{\typeout{patch ok}}%
{\typeout{patch failed}}
\makeatother

\graphicspath{{./figures/}}

\begin{document}
\begin{quiz}{My first quiz}


  \begin{multi}[shuffle=true, points=1]{Newton laws - 1}
    blablabla

    \includegraphics[width=6cm]{figac}

  \item* 1
  \item 2
\end{multi}

\end{quiz}

\end{document} 

使用@Rmano 文件我的输出是:

macbook-pro-de-christine:Test latex moodle christine.fauvelle-aymar$ lualatex --shell-escape essai.tex
This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
 system commands enabled.
(./essai.tex
LaTeX2e <2017-04-15>
(using write cache: /Users/christine.fauvelle-aymar/Library/texlive/2017/texmf-
var/luatex-cache/generic)(using read cache: /usr/local/texlive/2017/texmf-var/l
uatex-cache/generic /Users/christine.fauvelle-aymar/Library/texlive/2017/texmf-
var/luatex-cache/generic)sh: all: command not found

luaotfload | main : initialization completed in 0.154 seconds
Babel <3.10> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo(load luc: /Users/
christine.fauvelle-aymar/Library/texlive/2017/texmf-var/luatex-cache/generic/fo
nts/otl/lmroman10-regular.luc)))
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-def/luatex.def
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/local/texlive/2017/texmf-dist/tex/latex/moodle/moodle.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/environ/environ.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/trimspaces/trimspaces.sty))
(/usr/local/texlive/2017/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2017/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2017/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2017/texmf-dist/tex/latex/etex-pkg/etex.sty)
(/usr/local/texlive/2017/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2017/texmf-dist/tex/latex/xpatch/xpatch.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/local/texlive/2017/texmf-dist/tex/latex/l3packages/xparse/xparse.sty))
(/usr/local/texlive/2017/texmf-dist/tex/latex/tools/array.sty)
(/usr/local/texlive/2017/texmf-dist/tex/latex/ifplatform/ifplatform.sty
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/catchfile.sty
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/etexcmds.sty))
uname -s > "essai.w18"

! Package catchfile Error: File `essai.w18' not found.

See the catchfile package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.93     \CatchFileDef\@tempa{\ip@file}{}

? X
 368 words of node memory still in use:
   2 hlist, 1 rule, 1 dir, 3 attribute, 50 glue_spec, 3 attribute_list, 4 if_st
ack, 1 write nodes
   avail lists: 2:5,3:3,4:1,5:1,7:2,9:2

warning  (pdf backend): no pages of output.
Transcript written on essai.log.

答案1

这在很大程度上取决于你使用的平台。我的经验是使用 Linux。基本上

  1. 我不知道你为什么要修改内部命令。我的 Moodle 可以正常工作,包括图像……只要你使用全名(我知道,我知道,不应该这样,但是……)就像\includegraphics{myfig.pdf}

  2. 尽管有补丁可以修复它,但图形必须与主文件位于同一目录中。

  3. 你必须用旗帜来呼叫解释器--shell-escape

  4. lualatex如果您的文本中包含任何重音字符,则效果会更好(嗯,有效,因为没有pdflatex它就不会)。

  5. 我被这个咬了imagemagick过于热心的设置找到它真是一件令人痛苦的事……

我希望这有帮助...

举个例子。我把这个图保存为fullrect.png

在此处输入图片描述

并且此代码在testquiz.tex

% vim: set spelllang=es :
%! TEX program = lualatex
%
\documentclass{article}
\usepackage{graphicx}
\usepackage{moodle}
\moodleset{ppi=200}

\begin{document}
\begin{quiz}{Rectificadores} % Nombre del banco de preguntas

    \begin{multi}{Medida del termopar}

    \includegraphics[width=10cm]{fullrect.png}

    A ver, supon que tienes este circuito arriba.  El valor medio de la tensión a la salida $u_1$ es \dots
        \item*  positivo
        \item  negativo
        \item nulo
    \end{multi}

\end{quiz}

\end{document}

我编译时使用:

lualatex --shell-escape testquiz.tex

testquiz-moodle.xml生成一个文件,其中包含:

在此处输入图片描述

是的,分辨率很低,但我有一个提高分辨率的技巧,如果你需要的话可以问问。

相关内容