1

It is a rather common practice that teachers prepare multiple versions of a test for the same exam in order to reduce cheating. Can \LaTeX do this? I want to design a math test with a set of parameters that are randomly chosen from a given set to create problems that have same wording but different numbers (something that online homework systems do).

Is such a thing possible with any latex package? Is it possible at all?

A basic example is: Produce 10 pages, each a with a copy of the following question

What is the sum $p+q$?

Where the program chooses and inserts $p$ randomly from the range 20 to 30 and $q$ from 50 to 60.

Maesumi
  • 9,059
  • Yes, something like this should be possible. For comparison, a setup that permutes questions of an exam: https://tex.stackexchange.com/a/422219/117050 – Skillmon Sep 16 '19 at 21:55
  • The only problem is, that you can't output multiple PDFs. TeX can only produce one output file per run, so you'd get one PDF with each version in it and would have to split that PDF yourself (but TeX could write the pages at which you'd have to split to another file). Or you write yourself a Makefile which builds multiple versions and let the Makefile input the definitions of the variable which is to be replaced. – Skillmon Sep 16 '19 at 21:56
  • All in all this question is too broad, in the way it is asked, which is why I voted to close it in its current form. But I can give a definite answer to the question (which is contained in my two earlier comments): Yes, this is possible, but not as multiple PDFs within one TeX run. – Skillmon Sep 16 '19 at 22:05
  • You can choose a random integer from within a range with \int_rand:nn (might want to create a document interface: \usepackage{xparse}\ExplSyntaxOn\NewExpandableDocumentCommand \randint { o m } { \IfValueTF { #1 } { \int_rand:nn { #1 } { #2 } } { \int_rand:n { #2 } } }\ExplSyntaxOff, now you got a macro \randint that takes an optional and a mandatory argument. It returns a random int from #1 to #2 (if #1 wasn't used defaults to 1). So for your $p$ this would be \randint[20]{30}.) – Skillmon Sep 16 '19 at 22:26
  • 1
    Possible duplicate: How to create a random problem in math. I know everything you're asking for can be done with the sagetex package. You can even create an answer key as well at the same time. – DJP Sep 17 '19 at 00:29
  • 1
    I developed my own system combining C++ code and LaTeX. I sort of lost interest due to a complete lack of employment prospects or feedback from other teachers. See http://www.elfsoft2000.com/worksheets/index.htm – John Kormylo Sep 17 '19 at 03:37

0 Answers0