diff options
author | Norbert Preining <norbert@preining.info> | 2021-02-08 03:01:14 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-02-08 03:01:14 +0000 |
commit | 314f2cf58d8c42409e06e1c52de09b77d6e5fe09 (patch) | |
tree | aed06f32ad00ff26fb839b9fd650b51b2443a3fb /macros/latex/contrib/moodle | |
parent | e068841d2fc2976d094b382e4dd5e4d6df455506 (diff) |
CTAN sync 202102080301
Diffstat (limited to 'macros/latex/contrib/moodle')
-rw-r--r-- | macros/latex/contrib/moodle/README.md | 6 | ||||
-rw-r--r-- | macros/latex/contrib/moodle/moodle.dtx | 827 | ||||
-rw-r--r-- | macros/latex/contrib/moodle/moodle.pdf | bin | 241634 -> 260933 bytes |
3 files changed, 593 insertions, 240 deletions
diff --git a/macros/latex/contrib/moodle/README.md b/macros/latex/contrib/moodle/README.md index 83eb22b4bf..30e1b4a976 100644 --- a/macros/latex/contrib/moodle/README.md +++ b/macros/latex/contrib/moodle/README.md @@ -10,7 +10,7 @@ part of all distributions of LaTeX version 2005/12/01 or later. Original contents (2016): [Anders O.F. Hendrickson](/author/hendrickson) ([contact](mailto:anders.o.f.hendricksonATgmail.com)) -2019-2021: [Matthieu Guerquin-Kern](author/guerquin-kern) ([contact](mailto:guerquin-kernATcrans.org)) +2019-2021: [Matthieu Guerquin-Kern](/author/guerquin-kern) ([contact](mailto:guerquin-kernATcrans.org)) # Contents @@ -19,6 +19,9 @@ This work, under version number 0.8, consists of the files [`moodle.ins`](/tex-archive/macros/latex/contrib/moodle/moodle.ins), and the derived documentation file [`moodle.pdf`](/tex-archive/macros/latex/contrib/moodle/moodle.pdf). +The derived file `moodle.sty` can be downloaded from [here](https://www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/moodle/moodle.sty?view=co). +Details on how to generate derived files from the sources are given in Section "Building" at the end of this document. + A TDS archive [moodle.tds.zip](http://mirrors.ctan.org/install/macros/latex/contrib/moodle.tds.zip) is also available to be conveniently expanded in your local texmf directory. It contains the derived file `moodle.sty` and a set of test files. @@ -65,3 +68,4 @@ The documentation file `moodle.pdf` can be generated by running twice the comman ```bash lualatex -shell-escape moodle.dtx ``` +(n.b. the requirements in the previous section) diff --git a/macros/latex/contrib/moodle/moodle.dtx b/macros/latex/contrib/moodle/moodle.dtx index 17a7b125b4..9e932fb576 100644 --- a/macros/latex/contrib/moodle/moodle.dtx +++ b/macros/latex/contrib/moodle/moodle.dtx @@ -17,7 +17,7 @@ % The Current Maintainer of this work is Matthieu Guerquin-Kern. % % This work consists of the files moodle.dtx and moodle.ins -% and the derived files moodle.sty and getitems.sty. +% and the derived file moodle.sty. % % \fi % @@ -28,7 +28,7 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{moodle} %<*package> - [2021/01/04 v0.8 Moodle quiz XML generation] + [2021/02/07 v0.9 Moodle quiz XML generation] %</package> % %<*driver> @@ -44,7 +44,8 @@ \setmainfont[Mapping=tex-text]{Linux Libertine O} \fi %\usepackage{moodle}[2020/07/09] -\usepackage{amssymb,metalogo,multirow,threeparttable,booktabs,hyperref,tikz,minted,changelog} +\usepackage{amssymb,metalogo,multirow,threeparttable,booktabs} +\usepackage{hyperref,tikz,minted,changelog} \usetikzlibrary{arrows,positioning,decorations.text} %\usemintedstyle{Wombat} \EnableCrossrefs @@ -58,7 +59,7 @@ %</driver> % \fi % -% \CheckSum{7442} ^^A Comment \OnlyDescription above to adjust +% \CheckSum{7729} ^^A Comment \OnlyDescription above to adjust % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -89,9 +90,9 @@ % \author{Anders Hendrickson\footnote{original author of the package (\texttt{v0.5}), inactive.}\\ % \texttt{anders.o.f.hendrickson AT gmail.com} \and % Matthieu Guerquin-Kern\footnote{current maintainer, author of the updates (\texttt{v0.6} -% to \texttt{v0.8}), partially funded by \href{https://www.ensea.fr/en/}{ENSEA Graduate School}, France.}\\ +% to \texttt{v0.9}), partially funded in 2019 by \href{https://www.ensea.fr/en/}{ENSEA Graduate School}, France.}\\ % \href{mailto:guerquin-kern AT crans.org}{guerquin-kern AT crans.org}} -% \date{January 4, 2021} +% \date{February 7, 2021} % % \maketitle % @@ -238,11 +239,15 @@ % \end{figure} % % \section{Usage}\label{sect:usage} -% \subsection{Example Document} -% % The following pages presume the reader already has some familiarity with creating % and editing Moodle quizzes through the web interface. +% Users that are not familiar with Moodle quizzes can learn more in the Moodle +% documentation. For instance, \url{https://docs.moodle.org/310/en/Question_types}. +% % The |xkeyval| package is used to provide a key-value interface. +% +% \subsection{Example Document} +% % Here is a simple example document: % \begin{VerbatimOut}[gobble=1]{minted.doc.out} % \documentclass[12pt]{article} @@ -318,7 +323,7 @@ % file. This stamp contains information gathered about the TeX engine, % the operating system used and the package version. For instance: % \begin{quote}\small -% |<!-- This file was generated on 2020-11-30 by LuaLaTeX -->|\\ +% |<!-- This file was generated on 2021-01-07 by LuaLaTeX -->|\\ % |<!-- running on Linux with the package moodle |\texttt{\fileversion}| -->| % \end{quote} % The package option @@ -454,28 +459,34 @@ % may also be given by setting the |feedback| key \emph{at the individual answer}. % % \DescribeMacro{tags} -% The |tags| key sets a keyword for the question that will be taken into account by Moodle for -% filtering purposes or classification of questions inside the question bank. It is possible -% for instance to build a quiz with questions cherry-picked among the set of questions holding -% a particular tag. +% The |tags| key sets a list of keywords for the question that will be taken into account +% by Moodle for filtering purposes or classification of questions inside the question bank. +% It is possible for instance to build a quiz with questions cherry-picked among the set of +% questions holding a particular tag. % For example, one might set % \begin{center} % |tags={easy}| % \end{center} -% The desired tag should be included in braces. +% The desired tag should be specified in between braces. Multiple tags can be set as a +% comma-separated list: +% \begin{center} +% |tags={tag1,tag2,{ leading whitespace},{including, comma}}| +% \end{center} % -% Tags can be assigned at two levels. If the |tags| key is set at the quiz level, -% then that tags will be assigned by default to each question of the quiz. +% Tags can be assigned at two levels. If the |tags| key is set at the quiz level, +% then that tag list will serve as a default for each question of the quiz. % Question-specific tags can be assigned by setting the |tags| key \emph{at the question level}. -% Since only single tag is supported, the tag a the question-level overrides eventual tags -% specified at the quiz-level. +% The question-level |tags| key overrides eventual quiz-level tags. +% +% Users willing to specify a same tag for all questions of the quiz could +% also rely on Moodle's category mechanism. % -% \subsection{Question Types} +% \subsection{\href{https://docs.moodle.org/en/Question_types}{Question Types}} % % We next discuss the various question types supported by \textsf{moodle} % and the options that may be set. % -%\subsubsection{True/False} +%\subsubsection{\href{https://docs.moodle.org/en/True/False_question_type}{True/False}} % % \DescribeMacro{truefalse} % The syntax for a True/False question is as follows: @@ -502,7 +513,7 @@ % % With the True/False question type, the |penalty| key has no effect. % -% \subsubsection{Multiple Choice} +% \subsubsection{\href{https://docs.moodle.org/310/Multiple_Choice_question_type}{Multiple Choice}} % % \DescribeMacro{multi} % The syntax for a classic multiple choice question, @@ -593,7 +604,22 @@ % Note that, in this example, negative fractions are set for wrong choices. This % prevents students selecting all options to obtain a good grade with no merit. % -% \subsubsection{Numerical} +% \DescribeMacro{allornothing} +% There also exists a \href{https://moodle.org/plugins/qtype_multichoiceset} +% {``All-or-Nothing Multiple Choice''} plugin for Moodle that introduces a +% question type similar to a multiple choice with multiple correct answers, +% with the specificity that the points are given if and only if the student +% selects all correct answers. This kind of question is set up using the +% |allornothing| key. +% The recommended way for designating correct answers is with |\item*|. If instead +% the |fraction| is used, \textsf{moodle} moodle will consider that non-negative +% fractions ($>0$) designate correct answers and negative fractions ($\leq 0$) +% designate incorrect choices. +% The option |allornothing| supersedes the options |multiple| and |single|. +% To the best of our knowledge, Moodle does not offer the all-or-nothing behavior +% for multiple choice questions embedded inside a cloze question. +% +% \subsubsection{\href{https://docs.moodle.org/en/Numerical_question_type}{Numerical}} % % A numerical question in Moodle requires the student % to input a real number in decimal form. @@ -647,7 +673,7 @@ % % Units, unit-handling and multipliers are currently unsupported. % -% \subsubsection{Short Answer} +% \subsubsection{\href{https://docs.moodle.org/en/Short-Answer_question_type}{Short Answer}} % A short answer question resembles a numerical question: the student is to fill % in a text box with a missing word or phrase. % \begin{quote} @@ -694,7 +720,7 @@ % \item any non empty answer will match the pattern |*| (wildcard alone). % \end{itemize} % -% \subsubsection{Essay}\label{subsubsect:essay} +% \subsubsection{\href{https://docs.moodle.org/en/Essay_question_type}{Essay}}\label{subsubsect:essay} % Instructors may ask essay questions on a Moodle quiz, % although Moodle's software is not up to the task of grading them! % Instead each essay question answer must be graded manually by the @@ -737,6 +763,12 @@ % % \DescribeMacro{response field lines} % The key |response field lines| controls the height of the input box. +% For Moodle, the admissible values are: 5, 10, 15, 20, 25, 30, 35, and 40. +% If the value set is not admissible, \textsf{moodle} will approximate the value: +% \begin{itemize} +% \item with either 5 or 40 if the value set was out of range, or +% \item with the next multiple of 5 otherwise. +% \end{itemize} % The default is |response field lines=15|. % % \DescribeMacro{attachments allowed} @@ -752,7 +784,7 @@ % will edit and/or type over, with the key |template=|\marg{template}. % The \meta{template} should be enclosed in braces. % -% \subsubsection{Matching} +% \subsubsection{\href{https://docs.moodle.org/en/Matching_question_type}{Matching}} % % A matching question offers a series of subquestions % and a set of possible answers from which to choose. @@ -784,7 +816,8 @@ % \DescribeMacro{drag and drop}\DescribeMacro{dd} % The standard matching question offered by Moodle corresponds to % a dropdown box for choosing the answer to each question. -% There also exists a ``drag and drop matching'' plugin for Moodle that +% There also exists a \href{https://docs.moodle.org/310/en/Drag_and_drop_matching_question_type} +% {``drag and drop matching''} plugin for Moodle that % shows all questions in one column, % all answers in a second column, and allows students to drag the correct % answer to the question using a mouse. @@ -793,7 +826,8 @@ % If you choose the standard format, then due to the limitations of % dropdown boxes, no \LaTeX\ or HTML code can be used in the answers. % -% \subsubsection{Cloze Questions and Subquestions} +% \subsubsection{\href{https://docs.moodle.org/en/Embedded_Answers_(Cloze)_question_type} +% {Cloze Questions and Subquestions}} % % A ``cloze question'' has one or more subquestions embedded within a passage of text. % For example, you might ask students to fill in several missing words within @@ -852,7 +886,7 @@ % Within a cloze question, the short answer question can be made case sensitive. % This option, disabled by default, is selected with |case sensitive| or |usecase|. % -%\subsubsection{Description} +%\subsubsection{\href{https://docs.moodle.org/en/Description_question_type}{Description}} % % The Moodle description type is not really a question. It is more like a label. % One can set a |feedback| that the student gets when reviewing the submission. @@ -878,51 +912,51 @@ % \caption{Options offered at the question and answer levels for each question type.} % \label{tab:key-options} % \small -% \begin{tabular}{*{14}{l}} +% \begin{tabular}{*{15}{l}} % \toprule -% & \multicolumn{10}{l}{Question} & \multicolumn{3}{l}{Answer}\\ -% \cmidrule(lr){2-11}\cmidrule(lr){12-14} +% & \multicolumn{11}{l}{Question} & \multicolumn{3}{l}{Answer}\\ +% \cmidrule(lr){2-12}\cmidrule(lr){13-15} % Question type & \rotatebox{90}{points} & % \rotatebox{90}{penalty} & \rotatebox{90}{feedback} & \rotatebox{90}{tags} & % \rotatebox{90}{shuffle} & \rotatebox{90}{numbering} & \rotatebox{90}{multiple} & -% \rotatebox{90}{usecase} & \rotatebox{90}{tolerance} &\rotatebox{90}{dd} & -% \rotatebox{90}{fraction} & \rotatebox{90}{feedback} & +% \rotatebox{90}{allornothing} &\rotatebox{90}{usecase} & \rotatebox{90}{tolerance} & +% \rotatebox{90}{dd} & \rotatebox{90}{fraction} & \rotatebox{90}{feedback} & % \rotatebox{90}{tolerance}\\\cmidrule(lr){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3} % \cmidrule(lr){4-4}\cmidrule(lr){5-5}\cmidrule(lr){6-6}\cmidrule(lr){7-7} % \cmidrule(lr){8-8}\cmidrule(lr){9-9}\cmidrule(lr){10-10}\cmidrule(lr){11-11} -% \cmidrule(lr){12-12}\cmidrule(lr){13-13}\cmidrule(lr){14-14} +% \cmidrule(lr){12-12}\cmidrule(lr){13-13}\cmidrule(lr){14-14}\cmidrule(lr){15-15} % \href{https://docs.moodle.org/35/en/Multiple_Choice_question_type} % {Multichoice} & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & -% $\bullet$ & $\bullet$ & $\bullet$ & & & & $\bullet$ & $\bullet$ \\ +% $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & & $\bullet$ & $\bullet$ \\ % \href{https://docs.moodle.org/35/en/Numerical_question_type}{Numerical} -% & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & +% & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & & % & & $\bullet$ & & $\bullet$ & $\bullet$ & $\bullet$ \\ % \href{https://docs.moodle.org/35/en/Short-Answer_question_type}{Short -% Answer} & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & +% Answer} & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & & % & $\bullet$ & & & $\bullet$ & $\bullet$ \\ % \href{https://docs.moodle.org/35/en/Matching_question_type}{Matching} -% & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & +% & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & % & & & $\bullet$ & $\bullet$ & \\ % \href{https://docs.moodle.org/35/en/True/False_question_type} -% {True/False} & $\bullet$ & & $\bullet$ & $\bullet$ & & & +% {True/False} & $\bullet$ & & $\bullet$ & $\bullet$ & & & & % & & & & & $\bullet$ \\ % \href{https://docs.moodle.org/35/en/Description_question_type} -% {Description} & & & $\bullet$ & $\bullet$ & & & +% {Description} & & & $\bullet$ & $\bullet$ & & & & % & & & & & \\ % ^^A\href{https://docs.moodle.org/35/en/Essay_question_type}{Essay} & \\\hline% % \href{https://docs.moodle.org/35/en/Embedded_Answers_(Cloze)_question_type}{Cloze} -% & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & & & +% & & $\bullet$ & $\bullet$ & $\bullet$ & & & & % & & & & & \\\cmidrule(lr){1-1} -% \hspace{1em}Numerical & $\bullet$ & & & & & & +% \hspace{1em}Numerical & $\bullet$ & & & & & & & % & &$\bullet$ & & $\bullet$ & $\bullet$ & $\bullet$ \\ -% \hspace{1em}Short Answer & $\bullet$ & & & & & & +% \hspace{1em}Short Answer & $\bullet$ & & & & & & & % & $\bullet$ & & & $\bullet$ & $\bullet$ \\ -% \hspace{1em}Multi (regular) & $\bullet$ & & & & $\bullet$ & & $\bullet$ +% \hspace{1em}Multi (inline) & $\bullet$ & & & & $\bullet$ & & & % & & & & $\bullet$ & $\bullet$ \\ % \hspace{1em}Multi (horizontal)& $\bullet$ & & & & $\bullet$ & & $\bullet$ -% & & & & $\bullet$ & $\bullet$ \\ -% \hspace{1em}Multi (vertical)& $\bullet$ & & & & $\bullet$ & & -% & & & & $\bullet$ & $\bullet$ \\ +% & & & & & $\bullet$ & $\bullet$ \\ +% \hspace{1em}Multi (vertical)& $\bullet$ & & & & $\bullet$ & & $\bullet$ +% & & & & & $\bullet$ & $\bullet$ \\ % \bottomrule % \end{tabular} % \end{table} @@ -945,7 +979,7 @@ % \toprule % \multicolumn{2}{l}{Macros} & Commands & Environnments \\ % \cmidrule(lr){1-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4} -% |~| & |\#| &|\emph{}| & |\begin{center}|\\ +% |\%| & |\#| &|\emph{}| & |\begin{center}|\\ % |\$| & |\&| &|\textbf{}| & |\begin{enumerate}|\\ % |\\| & |\par| &|\textit{}| & |\begin{itemize}|\\ % |\&| & |\S| & |\texttt{}| & |\begin{tikzpicture}|\\ @@ -956,7 +990,7 @@ % |\euro| & |\texteuro| & |\fup{}| & \\ % |\TeX| & |\LaTeX|& |\textsubscript{}| & \\ % |\_| & |\textbackslash| & |\url{}| & \\ -% & & |\href{}{}| & \\ +% |~| & & |\href{}{}| & \\ % & & |\tikz[]{}| & \\ % & & |\includegraphics[]{}| & \\ % & & |\verbatiminput{}| & \\ @@ -967,22 +1001,40 @@ % \bottomrule % \end{tabular} % \end{table} -% Single and double quotation marks, french quotation marks, inverted exclamation and -% question marks, and the diacritical -% commands |\^|, |\'|, |\`|, |\"|, |\~|, |\c|, |\H|, |\u| and |\v| are also handled, -% as are the characters |\aa|, |\ae|, |\l|, |\oe|, |\o|, |\ss|, and their -% capitalizations. See Tables~\ref{tab:diacritical}, \ref{tab:ligatures}, and -% \ref{tab:other} for more details. +% Single and double quotation marks (with german variants), french quotation marks, +% inverted exclamation and question marks, and the diacritical +% commands |\^|, |\'|, |\`|, |\"|, |\~|, |\c|, |\H|, |\k|, |\u| and |\v| are +% also handled, as are the characters |\aa|, |\ae|, |\l|, |\oe|, +% |\o|, |\ss|, and their capitalizations. See Tables~\ref{tab:diacritical}, +% \ref{tab:ligatures}, and \ref{tab:other} for more details. % % In addition, |<| and |>| will be converted to |<| and |>| \emph{within math mode only}. % If they should be typed outside of math mode, they will be passed as typed to % the HTML, and probably interpreted by students' browsers as HTML tags % or other unpredicated results. +% A doubled dash will be converted to en-dash |–| \emph{outside math mode}. % % Be aware that \emph{\textsf{moodle} does not know how to convert any % other \TeX\ or \LaTeX\ commands to HTML.} % If other sequences are used, they may be passed verbatim to the XML file % or may cause unpredicted results. +% +% \DescribeMacro{\htmlonly}The |\htmlonly|\oarg{Content for traditional output} +% \marg{HTML content} command is to be used inside question environments (text, +% answers, or feedback). It lets you pass directly code to the XML file while being +% ignored for the traditional output (PDF). The HTML content passed as an argument +% is subject to no particular processing and users should not expect to be able to +% pass dangerous characters like |\|, |%|, or |#|. An optional argument allows to +% pass contents to be processed for the traditional output. This argument is +% ignored for the XML output. +% For instance, one can write code like this in a question environment +% \begin{quote} +% |\htmlonly[\fbox{PDF contents}]{|\\ +% |<div style="border: 1px solid green; display: inline-block;">|\\ +% \rule{10em}{0pt}|HTML contents</div>|\\ +% |}| +% \end{quote} +% % \DescribeMacro{\htmlregister}The |\htmlregister| command lets you specify % the macros that must be expanded in the XML file. It works only when no % optional argument is used. @@ -996,9 +1048,8 @@ % Again, this works only if the macros are defined \emph{without} optional % argument. % -% If you think of another \LaTeX\ command that should be changed to an HTML equivalent, -% please contact the maintainer at \url{guerquin-kern AT crans.org} -% so that it may be added to a future revision of the package. +% If you think of another \LaTeX\ command that should be changed to an HTML +% equivalent, please have a look at Section~\ref{sec:dev}. % % \section{Graphics} % The \textsf{moodle} package can handle two kinds of graphics seamlessly. @@ -1042,6 +1093,10 @@ %^^A \marg{native extension}\marg{command line for conversion}. % % \subsection{\TikZ\ Pictures} +% \TikZ\ is a user-friendly syntax layer for PGF, the macro \LaTeX\ package for creating +% graphics. Users that are not familiar with TikZ\ can learn more here: +% \url{https://ctan.org/pkg/pgf}. +% % When \TikZ\ is loaded and used to define pictures, \textsf{moodle} invokes % the |external| \TikZ\ library, so that each |tikzpicture| environment is compiled % to a freestanding PDF file. @@ -1112,9 +1167,10 @@ % environment or trust the files handled at the system-level, you may want to disable this % over-zelous security policy. For example, % \href{https://stackoverflow.com/a/52661288/14608059}{see this}. -% \item Users of the |circuitikz| package must enclose their circuits' \TikZ\ code in the -% |tikzpicture| environment instead of |circuitikz|. That is required, -% as of \TikZ\ 2.1, by the |external| library. +% \item Users of the |circuitikz| package (\url{https://www.ctan.org/pkg/circuitikz}) must +% enclose their circuits' \TikZ\ code in the |tikzpicture| environment instead of +% the historical |circuitikz| environment. That is required, as of \TikZ\ 2.1, +% by the |external| library. % \end{itemize} % % \subsection{Package Option \texttt{svg}}\label{subsec:svg} @@ -1169,6 +1225,10 @@ % specified language. % \end{enumerate} % The \textsf{moodle} package handles these three commands to pass the code in the output XML. +% With |\inputminted|, an external Python tool, \textsc{pygmentize}, performs syntax analysis and +% its HTML formatter is used to populate the XML. With the other commands, the contents of the +% file is passed as-is to the XML. A drawback of this approach, is that characters |<|, |>|, +% |&|, |'|, and |"| are likely to mislead the web browser rendering the question on Moodle. % % With |\VerbatimInput| and |\inputminted|, the options that are taken care of for XML % generation are listed in Table~\ref{tab:verbatim-options}. Using |\fvset|\marg{key=value,...}, @@ -1209,6 +1269,53 @@ % \textsf{filecontents} package or \LaTeX\ kernel itself since 2019) or |VerbatimOut| % (from the \textsf{fancyvrb} and \textsf{fvextra} packages). % +% Here is an example: +% \begin{VerbatimOut}[gobble=2]{minted.doc.out} +% \documentclass[12pt,a4paper]{article} +% \usepackage[section]{moodle} +% \usepackage{minted} +% \begin{document} +% \begin{quiz}[tags={minted}]{LaTeX Quiz} +% \begin{filecontents*}{excerpt.tex} +% % !TeX encoding = UTF-8 +% % !TeX spellcheck = en_US +% % !TEX TS-program = lualatex +% \documentclass{article} +% \usepackage[nostamp]{moodle} +% \ifPDFTeX % FOR LATEX and PDFLATEX +% \usepackage[utf8]{inputenc} % necessary +% \usepackage[T1]{fontenc} % necessary +% \else % assuming XELATEX or LUALATEX +% \usepackage{fontspec} +% \fi +% \end{filecontents*} +% \begin{numerical}[tolerance=0]{Loading a Class} +% Consider the following \LaTeX\ code excerpt.\\ +% \inputminted[numbers=left]{latex}{excerpt.tex} +% On which line is the class loaded? +% \item[feedback={ +% yes! \inputminted[highlightlines={4}]{latex}{excerpt.tex} +% } ] 4 +% \item[feedback={No. On line 3, there is only a comment.}, +% fraction=0] 3 +% \item[feedback={No. On line 5, the package \texttt{moodle} is loaded.}, +% fraction=0] 5 +% \end{numerical} +% \begin{multi}[single]{IDE} +% Consider the following \LaTeX\ code excerpt.\\ +% \inputminted[numbers=left]{latex}{excerpt.tex} +% Which \TeX\ engine will be used by the IDE for compilation. +% \item[feedback={Have a closer look at line 3}] \texttt{tex} +% \item[feedback={Have a closer look at line 3}] \texttt{latex} +% \item[feedback={Have a closer look at line 3}] \texttt{pdflatex} +% \item[feedback={Have a closer look at line 3}] \texttt{xelatex} +% \item* \texttt{lualatex} +% \end{multi} +% \end{quiz} +% \end{document} +% \end{VerbatimOut} +% \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out} +% % When code decorated with left-side line numbers is placed in question items, the output PDF could % show a collision between numbers of the item and the first line. To avoid this, |\LVerbatimInput| or % |\BVerbatimInput| can be used. Instead, when \textsf{minted} is used, the ``left-right'' mode can be @@ -1217,8 +1324,8 @@ % |\RecustomVerbatimEnvironment{Verbatim}{LVerbatim}{}| % \end{quote} % -% When using utilies from \textsf{fancyvrb}, \textsf{fvextra}, or \textsf{minted}, \textsf{moodle} sets -% framing options for the display of code in the output PDF: +% When using utilities from \textsf{fancyvrb}, \textsf{fvextra}, or \textsf{minted}, \textsf{moodle} +% sets framing options for the display of code in the output PDF: % \begin{quote} % |\fvset{frame=lines,label={[Beginning of code]End of code},|\\ % | framesep=3mm,numbersep=9pt}| @@ -1233,11 +1340,11 @@ % the same prototype. % % We suggest to apply a specific tag to these questions. After import in Moodle, when creating -% a quizz, this tag can be selected to narrow down a random selection of question. +% a quizz, this tag can be selected to narrow down a random selection of questions. % This would mimic the behavior of calculated questions while bringing the flexibility of your % favorite scripting language. % -% Here are two examples inspired from the work of A. Wohns. The first one relies on the +% Here are two examples inspired from the work of A. Vohns. The first one relies on the % native Lua capabilities of \LuaLaTeX. % \begin{VerbatimOut}[gobble=1]{minted.doc.out} % \begin{quiz}[tags={calculated}]{Example Quiz} @@ -1313,9 +1420,8 @@ % These two codes yield the same XML content. % % \section{Known Limitations and Call for Bug Reports} -% Table~\ref{tab:support-limitations} lists some different features supported, limitations, and +% Table~\ref{tab:support-limitations} lists some features supported, limitations, and % bugs. -% %\begin{table}[tbp] %\centering %\begin{threeparttable}[b] @@ -1347,7 +1453,7 @@ %yes & $\varnothing$& $\varnothing$ \\\cmidrule(lr){1-1} %\hspace{1em}Numerical & yes & no\tnote{1} & yes \\ %\hspace{1em}Short Answer & yes & no\tnote{1} & yes\tnote{7} \\ -%\hspace{1em}Multi (regular) & yes & no\tnote{2} & yes\tnote{7} \\ +%\hspace{1em}Multi (inline) & yes & no\tnote{2} & yes\tnote{7} \\ %\hspace{1em}Multi (horizontal) & yes & yes & yes \\ %\hspace{1em}Multi (vertical) & yes & yes & yes \\\bottomrule %\end{tabular} @@ -1373,10 +1479,8 @@ %\end{tablenotes} %\end{threeparttable} %\end{table} -% % Tables~\ref{tab:diacritical}, \ref{tab:ligatures}, and \ref{tab:other} describe the current -% support for some special characters, accents and other diacritical marks. -% +% state of support special characters, accents and other diacritical marks. %\begin{table}[tbp] % \centering % \caption{Support for diacritical marks @@ -1414,6 +1518,11 @@ % \H{o} & \H{O} & \verb|\H{o}| & \verb|\H{O}| & Unicode and \LaTeX & \LaTeX\ only\\ % \H{u} & \H{U} & \verb|\H{u}| & \verb|\H{U}| & Unicode and \LaTeX & \LaTeX\ only\\ % \"y & \"Y & \verb|\"y| & \verb|\"Y| & Unicode and \LaTeX & \LaTeX only\\ +% \k{a} & \k{A} & \verb|\k{a}| & \verb|\k{A}| & Unicode and \LaTeX & \LaTeX\ only\\ +% \k{e} & \k{E} & \verb|\k{e}| & \verb|\k{E}| & Unicode and \LaTeX & \LaTeX\ only\\ +% \k{i} & \k{I} & \verb|\k{i}| & \verb|\k{I}| & Unicode and \LaTeX & \LaTeX\ only\\ +% \k{o} & \k{O} & \verb|\k{o}| & \verb|\k{O}| & Unicode and \LaTeX & \LaTeX\ only\\ +% \k{u} & \k{U} & \verb|\k{u}| & \verb|\k{U}| & Unicode and \LaTeX & \LaTeX\ only\\ % \u{a} & \u{A} & \verb|\u{a}| & \verb|\u{A}| & Unicode and \LaTeX & \LaTeX\ only\\ % \u{e} & \u{E} & \verb|\u{e}| & \verb|\u{E}| & Unicode and \LaTeX & \LaTeX\ only\\ % \u{g} & \u{G} & \verb|\u{g}| & \verb|\u{G}| & Unicode and \LaTeX & \LaTeX\ only\\ @@ -1431,10 +1540,11 @@ % \bottomrule % \end{tabular} % \begin{tablenotes} -% \item[1] \XeLaTeX\ renders correctly |\u{i}|, that is, without a superscript dot. -% Instead, with (pdf)\LaTeX\ the rendering of |\u{i}| is flawed by the -% superposition of the superscript dot and the breve diacritical mark. -% Both engines render |\u{\i}| as expected. +% \item[1] The rendering of |\u{i}| is flawed in (pdf)\LaTeX's traditional output. +% ^^A \XeLaTeX\ renders correctly |\u{i}|, that is, without a superscript dot. +% ^^A Instead, with (pdf)\LaTeX\ the rendering of |\u{i}| is flawed by the +% ^^A superposition of the superscript dot and the breve diacritical mark. +% ^^A Both engines render |\u{\i}| as expected. % \end{tablenotes} % \end{threeparttable} % \end{table} @@ -1487,11 +1597,13 @@ % \bottomrule % \end{tabular} % \begin{tablenotes} -% \item[1] the package |babel| loaded with option |french| defines |\og| and |\fg| for -% the same symbols. These are also supported by \textsf{moodle}. +% \item[1] for the same symbols the package |babel| defines |\flqq| and |\frqq|, and +% if loaded with option |french| defines |\og| and |\fg|. These commands +% are also supported by \textsf{moodle}. % \end{tablenotes} % \end{threeparttable} % \end{table} +% % Some features of Moodle quizzes have not yet been implemented in \textsf{moodle}. % Here is a non-exhaustive list. % \begin{itemize} @@ -1500,12 +1612,11 @@ %^^A \item Calculated questions; that is, automatically generated numerical questions %^^A using randomly chosen numbers. % \item Hints -% \item Multiple keywords (tags) for questions +% \item Units handling in numerical questions % \end{itemize} % The authors have used this package together with a limited number of colleagues % for a few semesters of teaching. If other users adopt this package, we fully expect them -% to find bugs. \emph{Please} send all bugs you find to \url{guerquin-kern@crans.org}, -% so that we can fix them for subsequent versions. +% to find bugs. If you run into a problem, please have a look at Section~\ref{sec:dev}. % % \section{Compatibility} % This package has been originally written for and tested with the implementation of @@ -1516,8 +1627,8 @@ % % As the ultimate purpose of this package is the generation of XML files, % future versions of \textsf{moodle} will attempt to maintain backwards -% compatability with earlier versions regarding the XML output, apart from -% bug fixes. +% compatibility with earlier versions regarding the XML output, apart from +% bug fixes. % Backwards compatibility of the PDF output is not yet guaranteed, however, % in case the author or users discover better ways for the PDF to display % the underlying XML data to be proofread. @@ -1539,12 +1650,71 @@ % but turn ``MathJax'' \emph{on}. This forces \TeX\ code to be rendered by MathJax % instead of Moodle, producing much higher-quality results. % +% \clearpage +% \section{Package Development}\label{sec:dev} +% This package is developed as a collaborative project, currently hosted +% on the Gitlab server instance \url{https://framagit.org/mattgk/moodle}. +% The project's activity can be monitored there: reported issues, last +% modifications, \dots +% +% Contributions, either bug reports or fixes, are welcome. Users willing to +% help can either sign-in with an existing \textsf{GitHub}, \textsf{Gitlab.com}, or +% \textsf{Bitbucket} account or register a new account. +% +% Of course, getting in touch with the package maintainer by +% \href{mailto:guerquin-kernATcrans.org}{email} works as well. +% +% When experiencing a problem and before reporting it, please check whether +% or not something similar has already been filed as an issue +% \href{https://framagit.org/mattgk/moodle/-/issues?scope=all&state=all}{here}. +% If the problem appears to be new, please report it by following these steps: +% \begin{enumerate} +% \item Prepare a \emph{minimal} working example, i.e. a |.tex| file shunk down +% to the strict minimum (loaded packages, code, \dots) while still showing the +% faulty behavior upon compilation. +% \item Gather and send the |*.tex|, |*.log| and |*-moodle.xml| files together +% with an explanation about +% \begin{itemize} +% \item your working environment (\TeX\ engine and distribution, operating +% system, \dots), +% \item the faulty behavior, and +% \item what you expected instead. +% \end{itemize} +% \end{enumerate} +% % ^^A\clearpage % \changes{v0.5}{2016/01/05}{Initial version} % \changes{v0.6}{2019/02/18}{Bux-fixing release} % \changes{v0.7}{2020/07/09}{Feature extensions} % \changes{v0.8}{2021/01/04}{Bug fixes and feature extensions} +% \changes{v0.9}{2021/02/07}{Bug fixes and feature extensions} % \begin{changelog}[title={Version History},author={Matthieu Guerquin-Kern}] +% \begin{version}[version=0.9,date=2021-02-07] +% \added +% \item Support for \href{https://docs.moodle.org/310/en/All_or_nothing_multiple_choice_question_type} +% {all-or-nothing multiple choice} questions. +% \item Support for the ogonek diacritical mark via |\k|\marg{\dots}. +% \item Warn user of the \texttt{babel} package set for a German-related language +% that using the character |"| will not play well with \textsf{moodle}. +% \item Support for \textsf{babel} commands related to German quotes. +% \item Support for en-dash (--) outside of math mode. +% \item Support for |\%| in conversion to HTML. +% \item Command |\htmlonly[]{}| to pass HTML contents directly to the XML file. +% \changed +% \item An error is issued when a graphics conversion step fails. +% \item Irrelevant points are no longer written at the cloze question level in PDF and XML. +% \item The total number of marks is shown in the PDF at the end of each quiz. +% \item The |tags| key can now be used to specify a comma-separated list of tags. +% \fixed +% \item Answer text of shortanswer questions is converted to HTML. +% \item Paragraph breaks in multi and essay items no longer break compilation. +% \item Question text in Essays was not shown in PDF file. +% \item Commands |\textsc|, |\underline|, |\url|, and |\href| yielded HTML code with +% inadequate double quotation marks. +% \item Broken base64-encoding pipeline for images under Windows (thanks to Andreas Vohns). +% \item Repeated single right quotation marks no longer merged in math mode +% (thanks to Alberto Albano). +% \end{version} % \begin{version}[version=0.8,date=2021-01-04] % \added % \item Support for inclusion of GIF pictures. @@ -1598,15 +1768,15 @@ % \item Irrelevant \texttt{penalty} tag in cloze subquestions. % \fixed % \item Non-integer fractions can now be specified in cloze subquestions. -% \item Signifiantly squeeze PNG images size by skipping ancillary data. +% \item Significantly squeeze PNG images size by skipping ancillary data. % \item Enumerate or itemize environment can now be nested in question items. % \item Several pictures can be included in a question without being mixed % in the XML file. -% \item management and rendering of fraction in questions. -% \item Correctly handling a \LaTeX\ starting the last item of a question. +% \item Management and rendering of fraction in questions. +% \item Correctly handling a \LaTeX\ command starting the last item of a question. % \item Closing braces escaped in cloze subquestions. This allows \LaTeX\ % equations or images to be included. -% \item Image inclusion with MacOS. +% \item Image inclusion with macOS. % \end{version} % \begin{version}[version=0.6b,date=2019-11-27] % \added @@ -1626,7 +1796,7 @@ % \item General feedbacks can now contain backslashes. % \item Several quizzes can now be defined in a single source file, each % specifying a category for Moodle's question bank. -% \item Correct encoding information in now written in XML depending on +% \item Correct encoding information is now written in XML depending on % the \LaTeX\ compiler used. % \end{version} % \begin{version}[version=0.6a,date=2019-06-21] @@ -1634,7 +1804,7 @@ % \item \XeLaTeX\ is now recommended when using UTF8-encoded sources (support % of accents). % \item Feedbacks are now displayed in the PDF file produced. -% \item The \texttt{optipng} utility is used (and required) to reduce the size +% \item The \texttt{optipng} utility is used to reduce the size % of images embedded in the XML file. % \item Question options and settings are now displayed in the PDF file % \item Supporting more \LaTeX\ macros for symbols and accents (mostly @@ -1642,7 +1812,7 @@ % \item Introduce shuffle options in cloze-multi subquestions. % \item Package option \texttt{final}. % \changed -% \item In draft mode, \TikZ\ externalization in no longer triggered. +% \item In draft mode, \TikZ\ externalization is no longer triggered. % \fixed % \item In the different question types, the feedback fields are now converted % for HTML allowing \LaTeX\ equation and images. @@ -1694,16 +1864,23 @@ \RequirePackage{xkeyval} %For key-handling \RequirePackage{amssymb} %For \checkmark symbol %\RequirePackage{trimspaces} %To remove extra spaces from strings (loaded by environ) -\RequirePackage{etex} %Expansion control, detokenization, etc. -\RequirePackage{etoolbox}%List management -\RequirePackage{xpatch} %To patch commands easily in HTML mode -\RequirePackage{array} %For formatting tables in the LaTeX mode of Clozes -\RequirePackage{ifplatform} % To choose Ghostscript commands \@ifpackageloaded{iftex}{}{\RequirePackage{iftex}} % iftex already required by recent versions of ifplatform. Needed to know: % 1) whether we can convert output from PDF to PNG (ifpdf), % 2) when output pdf is latin1-encoded (ifpdf) % 3) when output xml is utf8-encoded (if?tex) +\@ifundefined{ifeTeX}{% version of 'iftex' prior to November 2019. + \RequirePackage{etex}{} +}{ + \ifeTeX\else + \RequirePackage{etex}{} % Recent (2015+) TeX engines should be e-TeX. + %This is needed for expansion control, detokenization, etc. + \fi +} +\RequirePackage{etoolbox}%List management +\RequirePackage{xpatch} %To patch commands easily in HTML mode +\RequirePackage{array} %For formatting tables in the LaTeX mode of Clozes +\RequirePackage{ifplatform} % To choose Ghostscript commands \@ifundefined{ifpdf}{\RequirePackage{ifpdf}}{}% old iftex would not define the conditional \RequirePackage{shellesc} %Luatex-compatible way of getting system access \RequirePackage{fancybox} %For fancy LaTeX tags @@ -1802,7 +1979,7 @@ \fi \writetomoodle{<!-- \moodle@stamp -->}% \def\moodle@stamp{running on \platformname}% - \g@addto@macro{\moodle@stamp}{ with the package moodle v0.8 }% + \g@addto@macro{\moodle@stamp}{ with the package moodle v0.9 }% \writetomoodle{<!-- \moodle@stamp -->}% \fi \immediate\write\moodle@outfile{}% @@ -1867,13 +2044,14 @@ }{}% }}% \newcommand*\@enumeratename{enumerate}% +\newdimen\moodle@totalmarks \moodle@totalmarks=0pt% \newenvironment{quiz}[2][]{% \setkeys{moodle}{#1}% \gdef\setcategory##1{% % At first call (end of \begin{quiz}) enumerate is not started yet \ifx\@currenvir\@enumeratename % In case no question is defined between two calls of \setcategory - \def\@noitemerr{\@latex@warning{Empty question list}}% + \def\@noitemerr{}%\@latex@warning{Empty question list} \end{enumerate}% \fi \gdef\moodle@currentcategory{##1}% @@ -1894,7 +2072,7 @@ \begin{enumerate}% }% \gdef\setsubcategory##1{% - \def\@noitemerr{\@latex@warning{Empty question list}}% + \def\@noitemerr{}%\@latex@warning{Empty question list} \end{enumerate}% \moodle@write@category@xml{\moodle@currentcategory/##1}% \ifmoodle@section @@ -1915,6 +2093,7 @@ \setcategory{#2}% }{% \end{enumerate}% + \emph{Total of marks: \strip@pt\moodle@totalmarks}% \let\setcategory\relax \let\setsubcategory\relax }% @@ -2053,21 +2232,29 @@ }% }% -\def\generate@moodle@write@tags#1{% - % #1 = NAME for \moodle@writeNAME - % #3 = what, exactly, to write - \xa\gdef\csname moodle@writetags\endcsname{% - %\xa\xa\xdef\xa\xa\ds\xa\xa{Encountered '\string #1'}\show\ds - \xa\xdef\xa\test@iii\xa{\moodle@tags}% - \ifx\test@iii\@moodle@empty\relax\else - \xa\converttohtmlmacro\xa\moodle@htmltowrite\xa{\moodle@tags}% - \writetomoodle[2]{ <tags>}% +\def\moodle@writetags{% + \xa\xdef\xa\test@iii\xa{\moodle@tags}% + \ifx\test@iii\@moodle@empty\relax\else + \writetomoodle[2]{ <tags>}% + \renewcommand*{\do}[1]{% + \def\moodle@tagtext{##1}% + \xa\converttohtmlmacro\xa\moodle@htmltowrite\xa{\moodle@tagtext}% \writetomoodle[4]{ <tag><text><![CDATA[\moodle@htmltowrite]]></text></tag>}% - \writetomoodle[2]{ </tags>}% - \fi - }% + } + \xa\docsvlist\xa{\moodle@tags}% + \writetomoodle[2]{ </tags>}% + \fi +}% +\newif\ifmoodle@firsttag +\moodle@firsttagtrue +\def\moodle@latex@writetags{% + \xa\xdef\xa\test@iii\xa{\moodle@tags}% + \ifx\test@iii\@moodle@empty\relax\else + \hfill tags: % + \renewcommand*{\do}[1]{\ifmoodle@firsttag\moodle@firsttagfalse\else, \fi\texttt{##1}}% + \xa\docsvlist\xa{\test@iii}% + \fi }% - % \end{macrocode} % \subsubsection{Keys for all question types} % \begin{macrocode} @@ -2142,9 +2329,7 @@ %which defines a "tag" (i.e., keyword) for the question. %Key calls like [tags={random}] set \moodle@tags. \define@cmdkey{moodle}[moodle@]{tags}[]{}% - \generate@moodle@write@tags{\csname moodle@tags\endcsname}% - \moodleset{tags}% -% TODO: handle multiple 'tags' for one question + \moodleset{tags={}}% % \end{macrocode} % \subsubsection{Keys for all answers} @@ -2175,6 +2360,11 @@ \generate@moodle@write@code*{shuffle}<shuffleanswers>{\ifmoodle@shuffle 1\else 0\fi}% \moodleset{shuffle=true}% +%% ALLORNOTHING -- for multichoice with multiple answers where all the points are given +% if and only if all the correct answers are selected. + \define@boolkey{moodle}[moodle@]{allornothing}[true]{}% + \moodleset{allornothing=false}% + %% TODO: CORRECTFEEDBACK %% TODO: PARTIALLYCORRECTFEEDBACK %% TODO: INCORRECTFEEDBACK @@ -2491,6 +2681,7 @@ \NewEnviron{#1}[2][]{% \bgroup \setkeys{moodle}{##1,questionname={##2}}% + \global\advance\moodle@totalmarks by \csname moodle@default grade\endcsname pt \expandafter\gatheritems\xa{\BODY}% \let\moodle@questionheader=\gatheredheader %First, the LaTeX processing @@ -2498,10 +2689,7 @@ \ifmoodle@handout \moodle@makelatextag@qtype{#1} \else - \xa\xdef\xa\test@iii\xa{\moodle@tags}% - \ifx\test@iii\@moodle@empty\relax\else - \hfill tags: \texttt{\moodle@tags} - \fi + \moodle@latex@writetags \par \noindent \moodle@makelatextag@qtype{#1} @@ -2540,41 +2728,41 @@ % Description blocks can be empty. In this case, nothing is done. % % \begin{macrocode} -\let\description\relax% remove the meaning of existing \description and \enddescription -\let\enddescription\relax -\NewEnviron{description}[2][]{% - \bgroup - \setkeys{moodle}{#1,questionname={#2}}% - \let\moodle@questiontext=\BODY - \trim@spaces@in\moodle@questiontext - \ifx\moodle@questiontext\@empty\relax\else% - %First, the LaTeX processing. - \item \textbf{\moodle@questionname} - \ifmoodle@handout\else - \xa\xdef\xa\test@iii\xa{\moodle@tags}% - \ifx\test@iii\@moodle@empty\relax\else - \hfill tags: \texttt{\moodle@tags}% +\AfterEndPreamble{% in case something like \usepackage[french]{babel} is loaded + \let\description\relax% remove the meaning of existing \description and \enddescription + \let\enddescription\relax + + \NewEnviron{description}[2][]{% + \bgroup + \setkeys{moodle}{#1,questionname={#2}}% + \let\moodle@questiontext=\BODY + \trim@spaces@in\moodle@questiontext + \ifx\moodle@questiontext\@empty\relax\else% + %First, the LaTeX processing. + \item \textbf{\moodle@questionname} + \ifmoodle@handout\else + \moodle@latex@writetags + \par + \noindent \fi - \par + \moodle@makelatextag@qtype{description}\par \noindent - \fi - \moodle@makelatextag@qtype{description}\par - \noindent - \moodle@questiontext\par - \ifmoodle@handout\else - \ifx\moodle@feedback\@empty\relax\else - \fbox{\parbox{\linewidth}{\emph{\moodle@feedback}}}% + \moodle@questiontext\par + \ifmoodle@handout\else + \ifx\moodle@feedback\@empty\relax\else + \fbox{\parbox{\linewidth}{\emph{\moodle@feedback}}}% + \fi \fi + %Now, writing information to memory. + \@moodle@ifgeneratexml{% + \writetomoodle{<question type="description">}% + \moodle@writecommondata + \moodle@writetags% + \writetomoodle{</question>}% + }{}% \fi - %Now, writing information to memory. - \@moodle@ifgeneratexml{% - \writetomoodle{<question type="description">}% - \moodle@writecommondata - \moodle@writetags% - \writetomoodle{</question>}% - }{}% - \fi - \egroup + \egroup + }% }% % \end{macrocode} % @@ -2587,7 +2775,6 @@ % Moodle cannot automatically grade an essay, % but if the user puts \item's in, we can list them in an itemize as notes. \par\noindent \emph{Notes for grader:} - \moodle@questionheader \ifnum\c@numgathereditems>0\relax \begin{itemize} \setlength\itemsep{0pt}\setlength\parskip{0pt}% \loopthroughitemswithcommand{\moodle@print@essay@answer}% @@ -2601,6 +2788,8 @@ \NewEnviron{essay}[2][]{% \bgroup \setkeys{moodle}{#1,questionname={#2}}% + \global\advance\moodle@totalmarks by \csname moodle@default grade\endcsname pt + \moodle@checkresponsefieldlines \expandafter\gatheritems\expandafter{\BODY}% \let\moodle@questionheader=\gatheredheader %First, the LaTeX processing. @@ -2608,10 +2797,7 @@ \ifmoodle@handout \moodle@makelatextag@qtype{essay} \else - \xa\xdef\xa\test@iii\xa{\moodle@tags}% - \ifx\test@iii\@moodle@empty\relax\else - \hfill tags: \texttt{\moodle@tags} - \fi + \moodle@latex@writetags \par \noindent \moodle@makelatextag@qtype{essay} @@ -2621,7 +2807,9 @@ \fi \par \noindent - \ifx\moodle@responsetemplate\@empty\relax\else% + \moodle@questionheader + \long\def\@lempty{}% + \ifx\moodle@responsetemplate\@lempty\else \par\noindent \emph{Template:} \par\fbox{\parbox{\linewidth}{\moodle@responsetemplate}}\par \fi @@ -2660,6 +2848,31 @@ \egroup }% +\def\moodle@checkresponsefieldlines{% + \newcount\a\a=\number\csname moodle@response field lines\endcsname + \newcount\b\b=5% + \ifnum\the\a>40% if the value was more than 40 + \a=40% + \fi + \ifnum\the\a<5% if the value was less than 5 + \a=5% + \fi + \divide\a by\b% integer division by 5 + \multiply\a by\b% multiply by 5 + \ifnum\a=\csname moodle@response field lines\endcsname% equality holds if we had 5, 10, 15, 20, 25, 30, or 40 + \else + \ifnum\csname moodle@response field lines\endcsname>5% + \ifnum\csname moodle@response field lines\endcsname<40% + \advance\a by\b% approximate with the next multiple of 5 + \fi + \fi + \PackageWarning{moodle}{"response field lines" admits only multiples of 5 between 5 and 40 + (You tried to set \csname moodle@response field lines\endcsname). The value + \the\a\space will be used.}% + \setkeys{moodle}{response field lines=\the\a}% + \fi +}% + %%%% TODO %%%% To make essay work will be tough. %%%% Every line from \ifnum\c@numgathereditems=0\relax through its \else and \fi, @@ -2704,12 +2917,12 @@ \moodle@writeattachmentsrequired% }% -\def\moodle@print@essay@answer#1{% +\long\def\moodle@print@essay@answer#1{% \item #1% }% -\def\moodle@savegraderinfo#1{% +\long\def\moodle@savegraderinfo#1{% %\def\ds{#1}\show\ds \bgroup \moodle@savegraderinfo@int#1\moodle@answer@rdelim @@ -2720,7 +2933,7 @@ \setkeys{moodle}{fraction=0,#1}% \moodle@savegraderinfo@int@int% }% -\def\moodle@savegraderinfo@int@int#1\moodle@answer@rdelim{% +\long\def\moodle@savegraderinfo@int@int#1\moodle@answer@rdelim{% \def\moodle@answertext{#1} \xa\converttohtmlmacro\xa\moodle@answertext@html\xa{\moodle@answertext}% %\trim@spaces@in\moodle@answertext @@ -2830,7 +3043,8 @@ \trim@spaces@in\moodle@answertext \moodle@checkfraction \addto@xml[2]{\moodle@answers@xml}{<answer fraction="\moodle@fraction" format="plain_text">}% - \addto@xml[4]{\moodle@answers@xml}{ <text>\moodle@answertext</text>}% + \xa\converttohtmlmacro\xa\moodle@answertext@html\xa{\moodle@answertext}% + \addto@xml[4]{\moodle@answers@xml}{ <text>\moodle@answertext@html</text>}% \ifx\moodle@feedback\@empty\relax\else \trim@spaces@in\moodle@feedback \xa\converttohtmlmacro\xa\moodle@feedback@html\xa{\moodle@feedback}% @@ -2956,10 +3170,19 @@ % LATEX PROCESSING \def\moodle@makelatextag@multi{% - \ifmoodle@multiple - \moodle@makelatextagbox{Multiple}\relax% + \ifmoodle@allornothing + \ifx\endmulti\endclozemulti + \PackageError{moodle}{Unsupported option "allornothing" for a multichoice subquestion} + {Please set "allornothing=false"}% + \else + \moodle@makelatextagbox{All-or-nothing}% + \fi \else - \moodle@makelatextagbox{Single}\relax% + \ifmoodle@multiple + \moodle@makelatextagbox{Multiple}% + \else + \moodle@makelatextagbox{Single}% + \fi \fi \ifmoodle@handout\else \ifmoodle@shuffle @@ -2969,6 +3192,9 @@ } \def\moodle@multi@latexprocessing{% + \ifmoodle@allornothing + \moodle@singletrue + \fi \moodle@countcorrectanswers% \ifmoodle@handout\NewList{answerlist}\fi \begin{enumerate}\moodle@obeynumberingstyle% @@ -2990,7 +3216,7 @@ \fi \fi } - \def\moodle@print@multichoice@answer#1{% + \long\def\moodle@print@multichoice@answer#1{% \let\moodle@feedback=\@empty% \moodle@print@multichoice@answer@int#1 \@rdelim% }% @@ -2999,7 +3225,7 @@ \setkeys{moodle}{#1}% \moodle@print@multichoice@answer@int@int% }% - \def\moodle@print@multichoice@answer@int@int#1#2\@rdelim{% + \long\def\moodle@print@multichoice@answer@int@int#1#2\@rdelim{% \def\test@i{#1}% \def\test@ii{#2}% \def\moodle@answertext{\item }% @@ -3020,11 +3246,11 @@ \ifx\moodle@fraction\@empty\relax% \setkeys{moodle}{fraction=0}% \fi + \moodle@checkfraction \ifx\moodle@fraction\@hundred% \trim@spaces@in\moodle@answertext% \g@addto@macro\moodle@answertext{$~\checkmark$}% \else - \moodle@checkfraction \ifdim0pt=\moodle@fraction pt\relax\else% \g@addto@macro\moodle@answertext{$~(\moodle@fraction\%)$}% \fi @@ -3101,7 +3327,7 @@ \fi \gdef\moodle@autosanctions{\strip@pt\moodle@pointsperincorrect}% } - \def\moodle@countcorrectanswers@a#1{% + \long\def\moodle@countcorrectanswers@a#1{% %The grouping is to keep key answer-specific key changes local. \bgroup \moodle@countcorrectanswers@b#1\moodle@answer@rdelim @@ -3114,7 +3340,7 @@ \moodle@countcorrectanswers@c% %\fi }% - \def\moodle@countcorrectanswers@c#1#2\moodle@answer@rdelim{% + \long\def\moodle@countcorrectanswers@c#1#2\moodle@answer@rdelim{% \def\test@i{#1}% \ifx\test@i\@star \stepcounter{moodle@numcorrectanswers}% @@ -3150,7 +3376,15 @@ \fi \fi } - \def\moodle@checkfraction{% + \def\moodle@checkfraction{% + \ifmoodle@allornothing + \ifnum\moodle@fraction>0% + \setkeys{moodle}{fraction=100}% + \fi + \ifnum\moodle@fraction<0% + \setkeys{moodle}{fraction=0}% + \fi + \else %\def\test@i{#1}% \setlength{\test@fraction}{\moodle@fraction pt}% % take the absolute value @@ -3168,11 +3402,12 @@ \else \setkeys{moodle}{fraction=\test@fractionmatched}% \fi - } + \fi + } % TODO: Put these macros in same order as other sections'. % SAVING ANSWERS TO MEMORY -\def\savemultianswer#1{% +\long\def\savemultianswer#1{% \bgroup \savemultianswer@int#1 \moodle@answer@rdelim \passvalueaftergroup{\moodle@answers@xml}% @@ -3181,9 +3416,12 @@ \newcommand\savemultianswer@int[1][]{% \let\moodle@fraction\@empty% \setkeys{moodle}{#1}% + \ifmoodle@allornothing + \moodle@singletrue + \fi \savemultianswer@int@int% }% - \def\savemultianswer@int@int#1#2\moodle@answer@rdelim{% + \long\def\savemultianswer@int@int#1#2\moodle@answer@rdelim{% \def\test@i{#1}% \ifx\test@i\@star \ifmoodle@single @@ -3218,9 +3456,12 @@ % WRITING QUESTION TO XML FILE \gdef\writemultiquestion{% - \writetomoodle{<question type="multichoice">}% + + \writetomoodle{<question type="multichoice\ifmoodle@allornothing set\fi">}% \moodle@writecommondata% - \moodle@writesingle% + \ifmoodle@allornothing\else + \moodle@writesingle% + \fi \moodle@writeshuffle% \moodle@writeanswernumbering% }% @@ -3241,6 +3482,7 @@ \NewEnviron{truefalse}[2][]{% \bgroup \setkeys{moodle}{#1,questionname={#2}}% + \global\advance\moodle@totalmarks by \csname moodle@default grade\endcsname pt \expandafter\gatheritems\xa{\BODY}% \let\moodle@questionheader=\gatheredheader %First, the LaTeX processing @@ -3248,10 +3490,7 @@ \ifmoodle@handout \moodle@makelatextag@qtype{truefalse} \else - \xa\xdef\xa\test@iii\xa{\moodle@tags}% - \ifx\test@iii\@moodle@empty\relax\else - \hfill tags: \texttt{\moodle@tags} - \fi + \moodle@latex@writetags \par \noindent \moodle@makelatextag@qtype{truefalse} @@ -3494,10 +3733,10 @@ \setcounter{moodle@numcorrectanswers}{0}% Here this counter is for "questions" (items on the left column) \loopthroughitemswithcommand{\moodle@print@matching@answer}% \ifnum\c@numgathereditems<3% - \PackageWarning{moodle}{Moodle expects at least three "answers" with matching type} + \PackageWarning{moodle}{Moodle expects at least three "answers" with matching type}% \fi \ifnum\c@moodle@numcorrectanswers<2% - \PackageWarning{moodle}{Moodle expects at least two "questions" with the matching type} + \PackageWarning{moodle}{Moodle expects at least two "questions" with the matching type}% \fi \ifmoodle@handout \ifmoodle@shuffle @@ -3645,14 +3884,10 @@ \ifmoodle@handout \moodle@makelatextag@qtype{cloze} \else - \xa\xdef\xa\test@iii\xa{\moodle@tags}% - \ifx\test@iii\@moodle@empty\relax\else - \hfill tags: \texttt{\moodle@tags} - \fi + \moodle@latex@writetags \par \noindent \moodle@makelatextag@qtype{cloze} - \moodle@makelatextag@value{default grade}{\moodle@marks{\csname moodle@default grade\endcsname}} \moodle@makelatextag@value{penalty}{penalty} \fi \par @@ -3685,7 +3920,11 @@ % WRITING QUESTION TO XML FILE \gdef\writeclozequestion{% \writetomoodle{<question type="cloze">}% - \moodle@writecommondata% + \moodle@writequestionname% + \moodle@writequestiontext% + \moodle@writegeneralfeedback% + \moodle@writepenalty% + \moodle@writehidden% \moodle@writetags% \writetomoodle{</question>}% }% @@ -3746,6 +3985,7 @@ \def\endclozemulti@code{\htmlize@patchendenvironment}% \else %LaTeX version + \global\advance\moodle@totalmarks by \csname moodle@default grade\endcsname pt \moodle@questionheader% %Any introductory text just continues to be typeset. \par \noindent @@ -3800,7 +4040,7 @@ }[\endclozemulti@code]% -\def\moodle@print@clozemultichoice@answer#1{% +\long\def\moodle@print@clozemultichoice@answer#1{% \let\moodle@feedback=\@empty \moodle@print@clozemultichoice@answer@int#1 \@rdelim% }% @@ -3808,7 +4048,7 @@ \setkeys{moodle}{fraction=0,#1}% \moodle@print@clozemultichoice@answer@int@int% }% -\def\moodle@print@clozemultichoice@answer@int@int#1#2\@rdelim{% +\long\def\moodle@print@clozemultichoice@answer@int@int#1#2\@rdelim{% \def\moodle@answertext{}% % Case 0: "(answer) \\ \hline" % Case 1: "\item (answer)" @@ -3867,7 +4107,7 @@ \fi }% -\def\saveclozemultichoiceanswer#1{% +\long\def\saveclozemultichoiceanswer#1{% \bgroup \saveclozemultichoiceanswer@int#1 \moodle@answer@rdelim \egroup @@ -3876,7 +4116,7 @@ \setkeys{moodle}{fraction=0,#1}% \saveclozemultichoiceanswer@int@int% }% -\def\saveclozemultichoiceanswer@int@int#1#2\moodle@answer@rdelim{% +\long\def\saveclozemultichoiceanswer@int@int#1#2\moodle@answer@rdelim{% \def\test@i{#1}% \ifgatherbeginningofloop\else \xa\gdef\xa\clozemulti@coding\xa{\clozemulti@coding\clozetilde}% separator between answers @@ -3929,6 +4169,7 @@ \def\endclozenumerical@code{\htmlize@patchendenvironment}% \else %LaTeX version + \global\advance\moodle@totalmarks by \csname moodle@default grade\endcsname pt \moodle@questionheader% %Any introductory text just continues to be typeset. \par \noindent @@ -4058,6 +4299,7 @@ \def\endclozeshortanswer@code{\htmlize@patchendenvironment}% \else %LaTeX version + \global\advance\moodle@totalmarks by \csname moodle@default grade\endcsname pt \moodle@questionheader% %Any introductory text just continues to be typeset. \par \noindent @@ -4358,6 +4600,7 @@ \def\@lt{<}% \def\@gt{>}% +\def\@dash{-}% \long\def\htmlize@recursive@i#1#2#3\htmlize@rdelim@i{% % #1#2#3 is a sequence of tokens. All should be categories 11 (letter) or 12 (other). @@ -4568,11 +4811,12 @@ \fi% \ifx\test@ii\@lsinglequote% \else \ifx\test@i\@rsinglequote% - \ifx\test@ii\@rsinglequote% - %Double right quote - \g@addto@macro\htmlize@output{\otherampersand rdquo;}% + \ifx\test@ii\@rsinglequote% Double right quote + %AAedit 2021.01.06: in math mode, you should write 2 single right quotes, for second derivatives + \moodle@ifmathmode{\g@addto@macro\htmlize@output{\otherampersand rsquo;\otherampersand rsquo;}}% + {\g@addto@macro\htmlize@output{\otherampersand rdquo;}}% \def\htmlize@next@i{\htmlize@recursive@i#3\htmlize@rdelim@i}% - \else + \else% Single right quote \g@addto@macro\htmlize@output{\otherampersand rsquo;}% \def\htmlize@next@i{\htmlize@recursive@i#2#3\htmlize@rdelim@i}% \fi% \ifx\test@ii\@rsinglequote% @@ -4591,9 +4835,20 @@ {\g@addto@macro\htmlize@output{>}}% \def\htmlize@next@i{\htmlize@recursive@i#2#3\htmlize@rdelim@i}% \else - % Default case: write first token to output, call self on remaining tokens. - \g@addto@macro\htmlize@output{#1}% - \def\htmlize@next@i{\htmlize@recursive@i#2#3\htmlize@rdelim@i}% + \ifx\test@i\@dash + \ifx\test@ii\@dash% en-dash (--) + \moodle@ifmathmode{\g@addto@macro\htmlize@output{--}}% + {\g@addto@macro\htmlize@output{\otherampersand ndash;}}% + \def\htmlize@next@i{\htmlize@recursive@i#3\htmlize@rdelim@i}% + \else + \g@addto@macro\htmlize@output{-}% + \def\htmlize@next@i{\htmlize@recursive@i#2#3\htmlize@rdelim@i}% + \fi + \else + % Default case: write first token to output, call self on remaining tokens. + \g@addto@macro\htmlize@output{#1}% + \def\htmlize@next@i{\htmlize@recursive@i#2#3\htmlize@rdelim@i}% + \fi% \ifx\test@i\@dash \fi% \ifx\test@i\@gt \fi% \ifx\test@i\@lt \fi% \ifx\test@i\@doublequote @@ -4927,6 +5182,7 @@ \htmlize@record@action{\endclozemode}% \htmlize@record@action{\relax}% +\html@action@def\%{\g@addto@macro\htmlize@output{\otherpercent}}% \html@action@def\#{\g@addto@macro\htmlize@output{\otherhash}}% \html@action@def\&{\g@addto@macro\htmlize@output{\otherampersand}}% \html@action@def\\{\moodle@ifmathmode{\g@addto@macro\htmlize@output{\otherbackslash\otherbackslash}}% @@ -4971,6 +5227,9 @@ \html@action@def\${% \g@addto@macro\htmlize@output{\otherdollar}% }% +\html@action@def\@dquote{% + \g@addto@macro\htmlize@output{"}% + }% \html@action@def\clozetilde{% \xa\g@addto@macro\xa\htmlize@output\xa{\othertilde}% }% @@ -5138,25 +5397,48 @@ {\g@addto@macro\htmlize@output{\otherampersand#1caron\othersemicol}}% {\xa\g@addto@macro\htmlize@output\xa{\string\v#1}}% }% + +% Ogonek diacritics +{\catcode`|=3\relax + \gdef\htmlize@ogonek{A|E|I|U|a|e|i|u|}} +\html@action@def\k#1{% + \ifinlist{#1}{\htmlize@ogonek}% + {\g@addto@macro\htmlize@output{\otherampersand#1ogon\othersemicol}}% + { + \bgroup + \def\test@i{#1}% + \ifx\test@i\@O + \def\toadd{\otherampersand\otherhash490\othersemicol}% + \else + \ifx\test@i\@o + \def\toadd{\otherampersand\otherhash491\othersemicol}% + \else + \def\toadd{\otherbackslash\otherlbrace#1\otherrbrace}% + \fi + \fi + \xa\g@addto@macro\xa\htmlize@output\xa{\toadd}% + \egroup + }% +}% % \end{macrocode} % % \subsubsection{Command sequences for Expansion} % % \begin{macrocode} -\html@def\underline#1{<SPAN STYLE=\&\#34;text-decoration: underline;\&\#34;>#1</SPAN>} +\html@def\underline#1{<SPAN STYLE=\@dquote text-decoration: underline;\@dquote>#1</SPAN>}% \html@def\emph#1{<EM>#1</EM>}% \html@def\textit#1{<I>#1</I>}% \html@def\textbf#1{<B>#1</B>}% \html@def\texttt#1{<CODE>#1</CODE>}% -\html@def\textsc#1{<SPAN STYLE=\&\#34;font-variant: small-caps;\&\#34;>#1</SPAN>} -\html@def\url#1{<A href=\&\#34;#1\&\#34;>#1</A>}% -\html@def\href#1#2{<A href=\&\#34;#1\&\#34;>#2</A>}% +\html@def\textsc#1{<SPAN STYLE=\@dquote font-variant: small-caps;\@dquote>#1</SPAN>}% +\html@def\url#1{<A href=\@dquote #1\@dquote>#1</A>}% +\html@def\href#1#2{<A href=\@dquote #1\@dquote>#2</A>}% \html@def\textsuperscript#1{<SUP>#1</SUP>}% \html@def\up#1{<SUP>#1</SUP>}% \html@def\fup#1{<SUP>#1</SUP>}% \html@def\textsubscript#1{<SUB>#1</SUB>}% \html@def\blank{____________}% -\html@def\par{</P><P>}% +\html@def\par{<BR/>}% \html@def\aa{\å}% \html@def\AA{\Å}% \html@def\ae{\æ}% @@ -5176,6 +5458,15 @@ \html@def\guillemotleft{\«\&\#8239;}% \html@def\fg{\&\#8239;\»}% \html@def\guillemotright{\&\#8239;\»}% +\html@def\glqq{\„}% +\html@def\grqq{\“}% +\html@def\glq{\‚}% +\html@def\grq{\‘}% +\html@def\flqq{\«\&\#8239;}% +\html@def\frqq{\&\#8239;\»}% +\html@def\flq{\‹}% +\html@def\frq{\›}% +\html@def\dq{\"}% \html@def\,{\&\#8239;}% \html@def\thinspace{\&\#8239;}% \html@def\textbackslash{\&\#92;}% @@ -5191,7 +5482,21 @@ \htmlize@record@action\displaymathrightdelim % \end{macrocode} -% +% +% \subsubsection{Passing Code to XML Only} +% Users may want to include pieces of HTML code to the XML file only. +% When producing the traditional output, the optional argument, empty +% by default, is used. +% \begin{macrocode} +\newcommand\htmlonly[2][]{#1}% +% \end{macrocode} +% When producing the XML file, the mandatory argument is passed as-is. +% \begin{macrocode} +\html@action@newcommand{htmlonly}[2][]{% + \g@addto@macro\htmlize@output{#2}% +}% +% \end{macrocode} +% % \subsection{Graphics via {\ttfamily\string\includegraphics}} % % \subsubsection{Finding Media Files} @@ -5206,6 +5511,14 @@ % are set with the basename, including path, and extension, respectively. % % \begin{macrocode} +\AtEndPreamble{% + \@ifpackageloaded{graphics}{% + \@ifpackagelater{graphics}{2019/10/08}{}{% + \PackageError{moodle}{`moodle' is made to interact with the `graphics' + package not older than 2019/10/08.}% + }% + }{}% +}% \def\moodle@media@find#1{% \ifx\detokenize\@undefined\else \edef\Gin@extensions{\detokenize\expandafter{\Gin@extensions}}% @@ -5382,7 +5695,10 @@ % While the picture will be animated after Moodle import, it will not be in the PDF % output, whatever the viewer is. \DeclareGraphicsAlien{.gif}{.png}{\htmlize@imagemagick@convert\otherspace '\SourceFile[0]' \OutputFile}% - }{}% + }{ + \newcommand\includegraphics[2][]{\PackageError{moodle}{"\string\includegraphics" is not defined}% + {Add "\string\usepackage{graphicx}" to you preamble.}}{}%}% + }% }% % \end{macrocode} % \subsubsection{Graphics key-handling} @@ -5434,25 +5750,30 @@ \SVGtoPDF\otherspace '\SourceFile' -o '\OutputFile' 2>/dev/null}% }% \fi - -\ifmoodle@tikz -\AfterEndPreamble{% - %\htmlize@record@expand{\embedaspict}% - \let\oldincludegraphics=\includegraphics - % patching includegraphics to trigger externalization - \renewcommand{\includegraphics}[2][]{% - %\message{moodle.sty: Processing \string\includegraphics[#1]{#2} for HTML^^J}% - \tikz{\node[inner sep=0pt]{\oldincludegraphics[#1]{#2}};}% - }% - % externalized images must be included with the regular command - \pgfkeys{/pgf/images/include external/.code={\oldincludegraphics{#1}}}% - \html@action@newcommand{includegraphics}[2][]{% - \message{moodle.sty: Processing \string\includegraphics[#1]{#2} ^^J} - \global\advance\numpicturesread by 1\relax - \edef\htmlize@imagetag{<IMG SRC="data:\TikzExportMIME;base64,\csname picbaselxiv@\the\numpicturesread\endcsname">}% - \xa\g@addto@macro\xa\htmlize@output\xa{\htmlize@imagetag}% +\def\moodle@checkconversionsuccess#1#2{% + \IfFileExists{#1}{}{% + \PackageError{moodle}{#2 failed}% + {If the XML file is not of importance to you: use package option "draft"}% }% }% +\ifmoodle@tikz + \AfterEndPreamble{% + %\htmlize@record@expand{\embedaspict}% + \let\oldincludegraphics=\includegraphics + % patching includegraphics to trigger externalization + \renewcommand{\includegraphics}[2][]{% + %\message{moodle.sty: Processing \string\includegraphics[#1]{#2} for HTML^^J}% + \tikz{\node[inner sep=0pt]{\oldincludegraphics[#1]{#2}};}% + }% + % externalized images must be included with the regular command + \pgfkeys{/pgf/images/include external/.code={\oldincludegraphics{#1}}}% + \html@action@newcommand{includegraphics}[2][]{% + \message{moodle.sty: Processing \string\includegraphics[#1]{#2} ^^J} + \global\advance\numpicturesread by 1\relax + \edef\htmlize@imagetag{<IMG SRC="data:\TikzExportMIME;base64,\csname picbaselxiv@\the\numpicturesread\endcsname">}% + \xa\g@addto@macro\xa\htmlize@output\xa{\htmlize@imagetag}% + }% + }% \else \html@action@newcommand{includegraphics}[2][]{% \bgroup% The grouping is to localize the changes caused by \setkeys. @@ -5502,6 +5823,7 @@ \edef\cmdline{\PDFtoSVG\otherspace "\moodle@media@base\moodle@media@ext" -o "\moodle@media@base\moodle@media@ext@current" 2>/dev/null}% \message{moodle.sty: Converting '#2' to SVG...^^J}% \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@media@base\moodle@media@ext@current}{PDFtoSVG conversion}% %Next, optimize inline \ifwindows\else \edef\cmdline{\optiSVG < "\moodle@media@base\moodle@media@ext@current" > @@ -5509,6 +5831,7 @@ "\moodle@media@base\moodle@media@ext@current"}% \message{moodle.sty: Optimizing '\moodle@media@base\moodle@media@ext@current'...^^J}% \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@media@base\moodle@media@ext@current}{SVG optimization}% \fi \else% call ImageMagick \def\moodle@media@ext@current{.png}% @@ -5516,10 +5839,12 @@ \edef\cmdline{\htmlize@imagemagick@convert\otherspace "\moodle@media@base\moodle@media@ext" -resize \moodle@graphics@geometry\otherspace "\moodle@media@base\moodle@media@ext@current"}% \message{moodle.sty: Converting '#2' to PNG...^^J}% \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@media@base\moodle@media@ext@current}{ImageMagick conversion}% %Next, optimize inline \edef\cmdline{\optipng\otherspace "\moodle@media@base\moodle@media@ext@current"}% \message{moodle.sty: Optimizing '\moodle@media@base\moodle@media@ext@current'...^^J}% \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@media@base\moodle@media@ext@current}{PNG optimization}% \fi \fi %Next, convert the file to base64 encoding @@ -5546,27 +5871,25 @@ % \end{macrocode} % This macro is in charge of throwing a system call to convert local files to base64. % \begin{macrocode} +\def\ConvertToBaseLXIV#1#2{% + \message{moodle.sty: Converting '#1#2' to base64...^^J}% + \ConvertToBaseLXIV@int{#1}{#2} + \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{#1.enc}{Base64 conversion}% +}% \ifwindows - \def\ConvertToBaseLXIV#1#2{% - \def\cmdline{\baselxiv\otherspace -encode "#1#2"\otherspace tmp.b64 && findstr /vbc:"---" tmp.b64 > "#1" && del tmp.b64"}% - \message{moodle.sty: Converting '#1#2' to base64...^^J}% - \xa\ShellEscape\xa{\cmdline}% - % Starting from Windows 7, CertUtil is included by default. There should be no windows XP still running - }% + \def\ConvertToBaseLXIV@int#1#2{% + \def\cmdline{\baselxiv\otherspace -encode "#1#2"\otherspace tmp.b64 && findstr /vbc:"---" tmp.b64 > "#1.enc" && del tmp.b64}% + }% Starting from Windows 7, CertUtil is included by default. There should be no windows XP still running \else \ifmacosx - \def\ConvertToBaseLXIV#1#2{% + \def\ConvertToBaseLXIV@int#1#2{% \def\cmdline{\baselxiv\otherspace -b 64 -i "#1#2"\otherspace -o "#1.enc"}% - \message{moodle.sty: Converting '#1#2' to base64...^^J}% - \xa\ShellEscape\xa{\cmdline}% }% \else % Linux, Cygwin - \def\ConvertToBaseLXIV#1#2{% + \def\ConvertToBaseLXIV@int#1#2{% \def\cmdline{\baselxiv\otherspace "#1#2"\otherspace > "#1.enc"}% - \message{moodle.sty: Converting '#1#2' to base64...^^J}% - \xa\ShellEscape\xa{\cmdline}% - }% - % base64 is part of coreutils, add "-w 64" to get exactly the previous behavior % + }% base64 is part of coreutils, add "-w 64" to get exactly the previous behavior % \fi \fi % \end{macrocode} @@ -5621,32 +5944,44 @@ \ifpdfoutput% tex engines defaulting to PDF output (pdflatex, xelatex, lualatex) \def\ExportTikz{ \message{moodle.sty: Converting picture '\moodle@basename.pdf' to SVG...^^J}% \edef\cmdline{\PDFtoSVG\otherspace "\moodle@basename.pdf" -o "\moodle@basename\TikzExportExtension" 2>/dev/null}% - \xa\ShellEscape\xa{\cmdline}}% + \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@basename\TikzExportExtension}{PDFtoSVG conversion}% + }% \else % latex \def\ExportTikz{ \message{moodle.sty: Converting picture '\moodle@basename.ps' to SVG...^^J}% \edef\cmdline{\PDFtoSVG\otherspace "\moodle@basename.ps" -o "\moodle@basename\TikzExportExtension" 2>/dev/null}% - \xa\ShellEscape\xa{\cmdline}}% + \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@basename\TikzExportExtension}{PStoSVG conversion}% + }% \fi \def\OptimizeExport{ \message{moodle.sty: Optimizing '\moodle@basename.svg'...^^J}% \edef\cmdline{\optiSVG\otherspace < "\moodle@basename\TikzExportExtension" > "\moodle@basename.tmp.svg" && mv "\moodle@basename.tmp.svg" "\moodle@basename\TikzExportExtension" }% - \xa\ShellEscape\xa{\cmdline}}% + \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@basename\TikzExportExtension}{SVG optimization}% + }% \else \def\TikzExportExtension{.png}% \def\TikzExportMIME{image/png}% \ifpdfoutput% tex engines defaulting to PDF output (pdflatex, xelatex, lualatex) \def\ExportTikz{ \message{moodle.sty: Converting picture '\moodle@basename.pdf' to PNG...^^J}% \edef\gscmdline{\gs\otherspace -sOutputFile=\moodle@basename\TikzExportExtension\otherspace -r150 \moodle@basename.pdf}% - \xa\ShellEscape\xa{\gscmdline}}% + \xa\ShellEscape\xa{\gscmdline}% + \moodle@checkconversionsuccess{\moodle@basename\TikzExportExtension}{Ghostscript conversion}% + }% \else % latex \def\ExportTikz{ \message{moodle.sty: Converting picture '\moodle@basename.ps' to PNG...^^J}% \edef\gscmdline{\gs\otherspace -sOutputFile=\moodle@basename\TikzExportExtension\otherspace -r150 \\moodle@basename.ps}% - \xa\ShellEscape\xa{\gscmdline}}% + \xa\ShellEscape\xa{\gscmdline}% + \moodle@checkconversionsuccess{\moodle@basename\TikzExportExtension}{Ghostscript conversion}% + }% \fi \def\OptimizeExport{ \message{moodle.sty: Optimizing '\moodle@basename.png'...^^J}% \edef\cmdline{\optipng\otherspace \moodle@basename\TikzExportExtension}% - \xa\ShellEscape\xa{\cmdline}}% + \xa\ShellEscape\xa{\cmdline}% + \moodle@checkconversionsuccess{\moodle@basename\TikzExportExtension}{PNG optimization}% + }% \fi \let\moodle@oldtikzpicture=\tikzpicture %The following code lets us run things *before* the normal \begin{tikzpicture}. @@ -5678,6 +6013,7 @@ \ExportTikz \OptimizeExport \ConvertToBaseLXIV{\moodle@basename}{\TikzExportExtension}% + \IfFileExists{\moodle@basename.enc}{}{\PackageError{moodle}{Conversion failed}{Check your base64 conversion utiliy}}% \message{moodle.sty: Reading base64 file '\tikzexternalrealjob-tikztemp-\the\numconvertedpictures.enc'...^^J}% \savebaselxivdata \message{moodle.sty: base64 data saved.^^J}% @@ -6182,6 +6518,19 @@ % related to autospacing when using |pdfLaTeX|. We shall warn them. % \begin{macrocode} \AtBeginDocument{% + \def\moodle@babel@german@warn{\PackageWarning{moodle}{Be careful when using moodle + and German-related babel package options. The symbol " is made active and your umlauts + will confuse moodle. You can either 1) compile with xelatex/lualatex with UTF-8 coded + characters or 2) avoid the babel option.} + } + \@ifpackagewith{babel}{german}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{austrian}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{swissgerman}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{swissgerman.toss}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{ngerman}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{naustrian}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{nswissgerman}{\moodle@babel@german@warn}{\relax}% + \@ifpackagewith{babel}{nswissgerman.toss}{\moodle@babel@german@warn}{\relax}% \ifPDFTeX % pdflatex or latex \@ifpackagewith{babel}{french}{% \PackageWarning{moodle}{Be careful when using LaTeX, moodle, and the babel package with option 'french'. Autospacing produces in undesired symbols in the XML. You can either 1) compile with xelatex/lualatex or 2) add '\NoAutoSpacing' after '\begin{quiz}'.}% diff --git a/macros/latex/contrib/moodle/moodle.pdf b/macros/latex/contrib/moodle/moodle.pdf Binary files differindex 1c047103cd..47a4c2ecca 100644 --- a/macros/latex/contrib/moodle/moodle.pdf +++ b/macros/latex/contrib/moodle/moodle.pdf |