21

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}
\addpoints
\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}
1
  • 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. May 23, 2012 at 8:27

4 Answers 4

16

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}
\addpoints
\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}
1
  • Hm, it seems very good :) I'm waiting more answers.
    – uzsolt
    May 23, 2012 at 9:02
13

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}

\usepackage[load-headings]{exsheets}
\SetupExSheets{
  headings = runin-nr ,
  headings-format = \normalfont ,
  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}

enter image description here

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.

7
  • Wow! Very-very impressive :) Next year I'll try it (I hope pupils will be happy :) )
    – uzsolt
    Dec 23, 2012 at 20:04
  • 2
    (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, 2012 at 20:07
  • @uzsolt I see. In this case simply use points/name=pont.
    – cgnieder
    Dec 23, 2012 at 20:11
  • This solution is very good, I've switched your exsheets package.
    – uzsolt
    Mar 4, 2013 at 16:00
  • @uzsolt glad you like it :)
    – cgnieder
    Mar 4, 2013 at 18:27
1

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

4
  • 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, 2012 at 17:13
  • @uzsolt It can't right now. I might add something, though.
    – cgnieder
    Dec 3, 2012 at 11:26
  • @cgnieder do you are the developer? :) I'm waiting about this. Do you accept "feature requests"? :)
    – uzsolt
    Dec 3, 2012 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, 2012 at 17:51
0

Compile with LuaTeX and define a macro that returns either the text for variation A or variation B. That allows you to edit the variations in place. Same syntax as with \vary with exsheets. You have to manually switch between the variations though and compile twice.

% !TEX TS-program = lualatex
% !TEX encoding = UTF-8 Unicode
\documentclass [11pt]{exam}
\usepackage{luacode}
\usepackage[a4paper, total={16cm, 26cm}]{geometry}
\usepackage{fontspec}

% defines a command for the variations
% change to variation B by replacing '#1' with '#2'
\newcommand{\var}[2]{\luadirect{tex.sprint('#1')}}

\begin{document}
\begin{questions}
\question Boris throws two six-sided dices.
\begin{parts}
\part[2] Compute the Probability that \var{both dices display 6}{the results of both diced add up to 12}.
\vspace{3cm}
\part[3] Compute the probability that at least one of the dices shows a \var{1}{2}.
\end{parts}
\end{questions}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .