# Variations of an exam

I'm using the great exam package to create exams. But sometimes there are many students so I need to create different "versions" - Group A and Group B.

Mainly the differences are only the numbers in questions so the text of questions are similar. Now I do the follow:

• create a command named \finalexam which has the questions with macros (\question[5] What is the result of $\a\cdot\b$)
• create the macros (\def\a{10}, \def\b{20})
• call \finalexam
• change the macros (\def\a{20}, def\b{30})
• call \finalexam

Is there any other (better) solution or a ready-to-use package?

Edit: a simple example

\documentclass{exam}
\usepackage[magyar]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{t1enc}
\usepackage{nicefrac}
\usepackage{siunitx}
\usepackage{multicol}
\pagestyle{empty}
\pointname{ pont}
\pointsinrightmargin
\marginpointname{ pont}
\begin{document}
\newcommand{\doga}{
\centerline{\large V. exam -- \group\ group}
\begin{questions}
\question[5]What is the result of $\a\cdot\b$?
\end{questions}}
%
\newcommand{\group}{A}
\renewcommand{\a}{5}
\renewcommand{\b}{10}
\doga
%
\renewcommand{\group}{B}
\renewcommand{\a}{10}
\renewcommand{\b}{20}
\doga
\end{document}

-
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE which those trying to help cam adapt to yield a better solution for you. –  Peter Grill May 23 '12 at 8:27
Yes, you've right. Updated, thanks. –  uzsolt May 23 '12 at 8:48

Use mailmerge and declare some fields (\mailfields), define the repetitions (\mailrepeat) and define different sets of parameters (\mailentry).

See the documentation for persuasive examples.

Edit: Here's your example with mailmerge:

\documentclass{exam}
\usepackage[magyar]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{t1enc}
\usepackage{nicefrac}
\usepackage{siunitx}
\usepackage{multicol}
\usepackage{mailmerge}
\pagestyle{empty}
\pointname{ pont}
\pointsinrightmargin
\marginpointname{ pont}
\begin{document}
\mailfields{group,a,b}
\mailrepeat{
\centerline{\large V. exam -- \field{group} group}
\begin{questions}
\question[5]What is the result of $\field{a}\cdot\field{b}$?
\end{questions}\clearpage}
\mailentry{A,5,10}
\mailentry{B,10,20}
\end{document}

-
Hm, it seems very good :) I'm waiting more answers. –  uzsolt May 23 '12 at 9:02

This question is the reason for the »variations« feature of exsheets introduced in v0.6. The command \vary is provided which in the default setting has two arguments. The command \variant{<num>} (where <num> is either 1 or 2) will choose if the first or second argument is used.

Here is a use-case example:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[magyar]{babel}

\SetupExSheets{
points/name = pont/ok % this is what translate.google.com tells me...
}

\begin{document}

% \variant{1} % default
\centerline{\large V. exam -- \vary{A}{B} group}
\bigskip

\begin{question}{5}
What is the result of $\vary{5}{10}\cdot\vary{10}{20}$?
\end{question}

\bigskip
\variant{2}
\centerline{\large V. exam -- \vary{A}{B} group}
\bigskip

\begin{question}{5}
What is the result of $\vary{5}{10}\cdot\vary{10}{20}$?
\end{question}

\end{document}


If you wanted more than two variations you could for example issue \SetVariations{3} in the preamble which would cause \vary to have three arguments. <num> in \variant{<num>} now could be 1, 2 or 3.

-
Wow! Very-very impressive :) Next year I'll try it (I hope pupils will be happy :) ) –  uzsolt Dec 23 '12 at 20:04
(In hungarian language we don't use plural in quantities, so we say "5 point" not "5 points", translate: "5 pont", not "5 pontok") –  uzsolt Dec 23 '12 at 20:07
@uzsolt I see. In this case simply use points/name=pont. –  cgnieder Dec 23 '12 at 20:11
This solution is very good, I've switched your exsheets package. –  uzsolt Mar 4 '13 at 16:00
@uzsolt glad you like it :) –  cgnieder Mar 4 '13 at 18:27

Maybe your problem is solved by the (brand new) exsheets package? Questions can be assigned classes and you can select what classes to show...

-
It seems very impressive. But (as I see) I can't do what I want: same questions with different datas. If it's possible I don't want type any text twice if it doesn't need. Please see Hasan Zakeri's answer. Or can I do it? –  uzsolt Oct 21 '12 at 17:13
@uzsolt It can't right now. I might add something, though. –  cgnieder Dec 3 '12 at 11:26
@cgnieder do you are the developer? :) I'm waiting about this. Do you accept "feature requests"? :) –  uzsolt Dec 3 '12 at 15:34
@uzsolt I am :) You can report issues and make requests at the bitbucket site or send me an email. Both addresses are mentioned in the manual. –  cgnieder Dec 3 '12 at 17:51