3

I want to generate a quiz for my students to be imported within the moodle platform . The quiz includes some figure.

I tried the moodle package from texlive 2018 but I get the following error when using the tikzpicture environment :

ERROR:
Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "geometry-tikztemp-1" "\def\tikzexternalrealjob{geometry}\input{geometry}"' did NOT result in a usable output file 'geometry-tikztemp-1' (expected one of .pdf:.jpg:.jpeg:.png:).

Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that.

Or maybe the command simply failed? Error messages can be found in 'geometry-tikztemp-1.log'. 

If you continue now, I'll try to typeset the picture.

Here is an example:

 \documentclass{article}
 \usepackage{tikz}
 \usepackage[draft]{moodle}
 \begin{document}
  \begin{quiz}{geometry}
    \begin{multi}{circle}
      is the shape in the figure a circle?

      \begin{tikzpicture}
       \draw (0,0)circle[radius=1cm];
      \end{tikzpicture}

      \item yes
      \item* no
    \end{multi}

  \end{quiz}
\end{document}
2

Not an answer but a workaround if you are in a rush. To be honest, I have hardly ever seen as strong "side-effects" as I see here with moodle. Even trying to do the \savebox after loading this package fails. Hope you find an expert who can fix this.

\documentclass{article}
 \usepackage{tikz}
 \usepackage[draft]{moodle}
 \newsavebox\picbox
\begin{lrbox}{\picbox}%
\begin{tikzpicture}
       \draw (0,0) circle(1cm);
\end{tikzpicture}
\end{lrbox}
 \begin{document}
  \begin{quiz}{geometry}
    \begin{multi}{circle}
      is the shape in the figure a circle?

\usebox\picbox

      \item yes
      \item* no
    \end{multi}

  \end{quiz}
\end{document}

enter image description here

  • 1
    fwiw the error in the original is that \pgfexternal@originalshipout is said to be undefined (at end of expansion of \pgf@externalend. And I see in moodle.sty near end of file that it does rather heavy patching of Tikz, with a \renewenvironment{tikzpicture} at begin document. Thus the issue might need reporting to moodle.sty author. – user4686 Nov 14 '18 at 11:44
  • @jfbu Thanks! Yes, that makes sense, and seems to explain the "side-effects". (If I was the OP, I would consider switching to another package.) – user121799 Nov 14 '18 at 11:48
  • @marmot, is someone aware of another package that helps creating quiz in moodle ? – Hafid Boukhoulda Nov 14 '18 at 21:59
  • @HafidBoukhoulda Someone: probably yes, but unfortunately not me. But you could ask a question, I would also be interested in the result, and asking questions is free. – user121799 Nov 14 '18 at 22:02
  • 1
    @HafidBoukhoulda Between us: this seems to be a bit a dangerous package. Why is it necessary for a package whose purpose is to typeset quizzes to (a) force you to externalize tikzpictures and, what is IMHO even worse, (b) to do \renewenvironment{tikzpicture} ? To me this does not make sense, but of course I cannot rule out that there might be reasons for it. Nor did I verify the findings of jfbu but I fully trust this user, who has a very good reputation (which is not reflected by the score). – user121799 Nov 14 '18 at 22:22
2

As moodle manual says, it invokes \usetikzlibrary{external}, therefore calling --shell-escape option in compilation process is a must and then you will get the following picture.

enter image description here

  • 1
    to compile I have tried the following pdflatex --shell-escape geometry.tex and pdflatex -shell-escape geometry.tex but without any success (the same error) – Hafid Boukhoulda Nov 13 '18 at 20:22
  • I've never gotten externalize to work, either. Try using \tikzexternaldisable. – John Kormylo Nov 13 '18 at 21:08
  • @JohnKormylo I did (very often) get externalize to work and of course the first thing I tried is to compile with -shell-escape. IMHO moodle introduces complications beyond that, which is why I only offered a workaround. I am actually wondering if this answer works for you or anyone else, at least for the OP and me it does not seem to work. – user121799 Nov 13 '18 at 21:36
  • 1
    @HafidBoukhoulda I've tried both of pdflatex and xelatex engine with --shell-escape, getting the same results. pdflatex and xelatex versions of my TeX distro. are: pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018) XeTeX 3.14159265-2.6-0.99999 (TeX Live 2018) I also updated the picture because I'd erased one line in your file and it produced an award result. – javadr Nov 14 '18 at 1:41
  • If @javadr has got a result can we conclude that the issue is not with the moodle package? and what should we investigate further to eliminate the error? Me too I use pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) ! – Hafid Boukhoulda Nov 14 '18 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.