Forgive me in advance if this is a dumb question, or too specific to one package. I've been using examdesign to randomize the order of questions, but I also want to randomly generate the content. I've begun using Sweave to generate random numbers in R for some of the questions. However, when I ask for several different versions, it keeps the content the same from one version to the next. In other words, it first creates the random content from R, then it uses that same content across the several versions. What I want it to do is to call the R functions every time it creates a new version. Here's an example:
\documentclass[10pt]{examdesign}
\usepackage{Sweave}
\usepackage{amsmath}
\NumberOfVersions{2}
\begin{document}
\begin{examtop}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{ll}
Name:& \rule{2in}{.4pt}\\
\end{tabular}
\vspace{0.5in}
\begin{center}
\textbf{Introduction to Statistics} \\
\textbf{Practice Exam, Form \Alph{version}} \\
\end{center}
\end{examtop}
\begin{shortanswer}[title={\Large Short Answer (10 pts each)}]
\begin{question}
<<ifst, echo=FALSE>>==
N = round(runif(1, 5, 20))
mu = 75
xbar = round(runif(1, 76, 84))
sig = round(runif(1, 5, 15))
z = round((xbar-mu)/(sig/sqrt(N)), digits=2)
p = round(1-pnorm(z), digits=4)
@
John wants to know whether his students are smarter than the average student.
John has \Sexpr{N} students and their average was \Sexpr{xbar}.
Assuming a population $\mu$ of \Sexpr{mu} and a standard deviation of
\Sexpr{sig}, can we conclude his students are smarter?
\examvspace*{1.5in}
\begin{answer}
\begin{align}
\nonumber Z_{obt} = \frac{\Sexpr{xbar}-\Sexpr{mu}}{\Sexpr{sig}/\sqrt{\Sexpr{N}}} =& \Sexpr{z} \\
\nonumber p_{obt} =& \Sexpr{p}
\end{align}
\end{answer}
\end{question}
\end{shortanswer}
\end{document}
You'll notice that once you sweave it, there will be two versions, but the mean/sd/N will be identical for both versions. How do I get them to generate different random numbers?
`to mark your inline code as I did in my edit. – Kurt Oct 26 '12 at 0:22Sweave? Would apgfmathsolution be acceptable? – Peter Grill Oct 26 '12 at 16:44brewpackage in R might have more capabilities for control of looping. I don't know theexamdesignpackage, so I don't know precisely what the\NumberOfVersions{2}will do, but you could do the multiple versioning within R ... – Ben Bolker Oct 26 '12 at 18:33