Forums » Using AMC (english) »
Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format
Added by Benoit Nennig over 8 years ago
Dear all,
To convert my quiz and those of colleagues, I have started to write a parser to convert AMC latex format into moodle XML quiz format.
The first version can be found here :
https://github.com/nennigb/amc2moodle
Most of LaTeX possibilities are supported (equations, tables, graphics, user defined commands). Examples, installation, usage, dependencies and
the limitations are available in amc2moodle.pdf at the root of the github repository.
It is based on LaTeXML for a first step conversion of the LaTeX file into XML. Then a set of transformation is applied in python and with XSLT stylesheet to conform to moodle XML format. The quiz can then be imported in the moodle question bank using category tags. For the moment it works only on linux.
I hope it will help,
Let me know your impressions.
Regards,
Benoit
Replies (7)
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Benoit Nennig over 4 years ago
Dear all,
The project amc2moodle is still under active development and a new release (v2) (as a python package) is now available on :
https://github.com/nennigb/amc2moodle
do not hesitate to send us your feedback on install, usage or bugs on
https://github.com/nennigb/amc2moodle/issues
Regards,
bn for amc2moodle team
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Pablo UPM over 4 years ago
Hello:
Nice idea. The moodle package is not bad, but with this project, the same question bank could be used both as moodle quizes or within amc.
My university demands that online exams should use moodle, so this is interesting.
But do you plan to allow for parameterized questions with fpeval? This is the main limitation / deal-breaker for the moodle package.
If this is hard to do, I very much prefer the following alternative workflow [1], which also works within moodle and is fully compatible with fpeval and any other latex tricks:
- Generate DOC-sujet and DOC-corrige with AMC, using pdfforms
- Zip the exam statements DOC-sujet
- Create a moodle "folder" activity, which is "active but not visible to students"
- Inform the students that on day D, at the hour H, the url https://yourmoodle/pluginfile.php/XXXXX/mod_folder/content/0/exam_statement_student_id.pdf will contain their exam
- On day D, at the hour H, upload the zip file with all the statements, unzip it => each student can now download their exam statement
- Collect all the solutions with a moodle "task" activity.
- Recover their exams from moodle in one big zip file
- Feed those pdf files to AMC
- Follow the usual procedure in AMC to get a csv file with detailed data: who was asked what, what is they answer if the question was multiple-choice, and what was their grade for each question.
- Optional: use the same procedure so that each student can download the solution to their exam right after the exam is over
- Optional: place a dummy file in the folder activity so that they can test that they can download the exam. The dummy file says: "This is not your exam. Your exam will be available on day D, at the hour H, using the exact url that you just used".
Regards
[1] modified from https://project.auto-multiple-choice.net/boards/2/topics/9769
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Benoit Nennig over 4 years ago
Hi,
I think it should be possible to automatically recast fpeval question into 'Calculated question' (or 'Numerical response') in moodle at least for basic cases. I will have a look to estimate the difficulties.
At first glance, the main problems are :
- fp is not the only package to perform computation
- perhaps some fp functions will not be supported by moodle. In particular storing intermediate variable...
- do we need to help the parser and provide 'hint' in AMC latex file (type of output question, ...)
I suggest you to open an issue on amc2moodle github repos, to continue this discussion and work on a solution (https://github.com/nennigb/amc2moodle/issues)
I put here some possible workarounds :- AMC question with FPeval will in most case correspond to 'moodle calculated question'. Basically
# in moodle gui A Qestion with {a} and [b} variable. answer: {a}*{b}
- modify your latex file with the final moodle syntax or create a specific newcommand. For instance (not a final solution!)
% put the string you want in moodle \newcommand{\x}{x} % create a new command to properly parse the FP command for moodle evaluation \newcommand{\FPadd}[3]{\{=\{#2\}+\{#3\}\}} % or \newcommand{\FPadd}[3]{\{#1\}=\{#2\}+\{#3\}} % Now in uour question use \FPadd{\x}{2}{23.2} % yields : {={2}+{23}} \FPadd{\x}{a}{b} % yields : {={a}+{b}}
It should work for simple non nested expression. Then modify the question type in the XML<question type="calculatedmulti"> instead of <question type="multichoice"> <questiontext format="html"> <text><![CDATA[<p>A Qestion with {a} and [b} variable.</p>]]></text> </questiontext> .... <answer fraction="100"> <text>{={a}+{b}}</text> </answer> </question>
Then in moodle gui, you will need to set the range of each variable (or put it in the XML). - pgf is supported by latexml (will work out of the box with amc2moodle) and allow to performed computation (pgfmath) but you will get only the numerical results and lost the expression
\pgfmathparse{2*23.2} the results is stored in {\pgfmathresult}
The advantage of conversion is, that at the end, you can also mix your quiz with native moodle question, configuring moodle test directly and use easily time limit, derogation, sequential navigation, feedback, limit the dissemination of your exam questions for next year...
Depending the number of question you have, it could be time saving to spent time on conversion, but the workflow you propose seems valid.
Best regards,
Benoit
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Pablo UPM over 4 years ago
Thanks, Benoit:
I have created the github issue:
https://github.com/nennigb/amc2moodle/issues/13
You are right that fp is not the only package to perform computation. Indeed, I have set auto-multiple-choice aside for a while, and have generated my latest exams with sagetex, which is very hard to make compatible with auto-multiple-choice, but provides matrices, symbolic calculus, graphics, and many other things that are useful for math exams, and not found in other packages (moodle, numbas, auto-multiple-choice... I don't know any alternative!).
The first approach that you propose is not promising. I think most people would stop writing questions in AMC if they need to tune them afterwards in moodle.
The second approach is very interesting, since you could design parameterized questions in your latex editor, possibly with inverse search and all the perks, then if you like the result you can export, and if you restrict to the provided commands, you have some guarantees of faithful conversion.
The last approach could also be interesting if you could generate a few variants, and use moodle random groups to assign one variant to each student. BTW, is it possible to upload many quizes at once to moodle?
One possible drawback of the whole approach is that moodle supports only limited latex. A colleague told me "array" does not work, for instance. This means that if the author uses full latex power, the moodle exam could render incorrectly. I guess this can be solved case by case, replacing array by matrix and whatnot :-/ This concern applies too to the other latex-to-moodle projects. I don't know if they have attempted to solve it and how...
Another big advantage of auto-multiple-choice over moodle is the ability to compose an exam with one question form group A, another from group B, etc. Moodle exams are often quite unbalanced, when one student gets some very similar questions, or do not get any question from a certain section of the syllabus. I've heard this is possible in moodle, I don't remember how: have you implemented this in amc2moodle?
BTW, converting moodle quizes into latex could also be useful, for example to recover simple multiple choice questions and add more randomization or create more variants. I guess the moodle parameters appear in the latex file, isn't it? Once they are latex, anything is possible.
Regards
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Benoit Nennig over 4 years ago
Hi,
I agree that the best approach it to remain as close as possible as AMC and Latex syntax (with perhaps some restrictions). I start to work on it.To answer to your last remarks :
- In moodle, you can use the question bank and create category as in AMC. When you create your quiz in moodle, you can pick x question in a specific category exactly as in AMC. amc2moodle create moodle category from AMC \element tag.
- Concerning sagetex, a workaround could be to generate automatically element tag to create with the same latex code (wih for loop), several moodle questions stored in different category in one XML file (never tried but it should work).
- Moodle support html and latex though mathjax. Our conversion process is based on LaTeXML (that support a huge number of latex packages like array) and a rendering step for html text formatting and keep equation in mathjax. Virtually all formatting features supported by LaTeXML or mathjax can be rendered properly in moodle with amc2moodle (perhaps with some additional dev). Now, you can use images, tikz, equation, tabular, code... Things become more tricky when computation are realized in the question...
Note that the mathjax packages can be modified by your moodle admin. array is normally supported. - amc2moodle allows also since v2.1 to convert moodle xml file back into AMC latex format (for some question type). Again, new features could be added if required.
Regards,
Benoit
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Muralito - over 4 years ago
Thanks for this tool.
I will use in the next months in the other way, from moodle 2 amc, to convert some moodle quiz from the covid-19 months, to amc paper exams
By the way, it was not esay to find it.
Now googling for moodle2amc returns only one link to this post.
Luckily duckduckgo links to your github repository...
RE: Creation of a conversion tool to recast AMC LaTeX format into the moodle XML quiz format - Added by Benoit Nennig about 4 years ago
Hi,
The conversion of parametrized questions from AMC-LaTeX to moodle and from moodle to AMC-LaTeX using `fp` is now available for testing. See https://github.com/nennigb/amc2moodle/issues/13 for more details.
Benoit
(1-7/7)