5

enter image description here

I need to have four different question papers in which the order of the above questions only changed and i need to give the answer for the respective question paper in a separate sheet. so kindly help me to prepare those question papers from this. That i need to prepare another question paper by shuffling the questions and i need to give the answer respectively. How should i do?

 \documentclass[12pt,a4paper]{exam}
    \usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
    \setlength\parindent{0pt}
        %usage \choice{ }{ }{ }{ }
        %(A)(B)(C)(D)
        \newcommand{\fourch}[4]{
        \par
                \begin{tabular}{*{4}{@{}p{0.23\textwidth}}}
                (a)~#1 & (b)~#2 & (c)~#3 & (d)~#4
                \end{tabular}
        }

        %(A)(B)
        %(C)(D)
        \newcommand{\twoch}[4]{

                \begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
                (a)~#1 & (b)~#2
                \end{tabular}
        \par
                \begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
                (c)~#3 & (d)~#4
                \end{tabular}
        }

        %(A)
        %(B)
        %(C)
        %(D)
        \newcommand{\onech}[4]{
        \par
              (a)~#1 \par (b)~#2 \par (c)~#3 \par (d)~#4
        }

        \newlength\widthcha
        \newlength\widthchb
        \newlength\widthchc
        \newlength\widthchd
        \newlength\widthch
        \newlength\tabmaxwidth

        \setlength\tabmaxwidth{0.96\textwidth}
        \newlength\fourthtabwidth
        \setlength\fourthtabwidth{0.25\textwidth}
        \newlength\halftabwidth
        \setlength\halftabwidth{0.5\textwidth}

      \newcommand{\choice}[4]{%
      \settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}%
      \settowidth\widthchb{BM.#2}%
      \ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
      \settowidth\widthchb{CM.#3}%
      \ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
      \settowidth\widthchb{DM.#4}%
      \ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
      \ifdim\widthch<\fourthtabwidth
        \fourch{#1}{#2}{#3}{#4}
      \else\ifdim\widthch<\halftabwidth
        \ifdim\widthch>\fourthtabwidth
          \twoch{#1}{#2}{#3}{#4}
        \else
          \onech{#1}{#2}{#3}{#4}
        \fi
      \fi\fi
    }
    \begin{document}
     \begin{questions}
    \question If $a = 3 + i$ and $z = 2 - 3i$ then the points on the Argand diagram
    representing az, 3az and - az are
    \choice{Vertices of a right angled triangle}{ Vertices of an equilateral 
    triangle}{Vertices of an isosceles triangle}{Collinear}
    \question If z represents a complex number then $\arg (z) + \arg\left(\bar z\right)$ is 
    \choice{$\dfrac{\pi}{4}$}{$\dfrac{\pi}{2}$}{0}{$\dfrac{\pi}{6}$}
    \question If the amplitude of a complex number is $\dfrac{\pi}{2}$ then the number is
    \choice{ purely imaginary}{purely real}{0}{neither real nor imaginary}
    \question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is
    \choice{i}{-i}{1}{-1}
    \question The volume generated by 
    rotating the triangle with vertices at
    (0, 0), (3, 0) and (3, 3) about x-axis is
    \choice{$18\pi$}{$2\pi$}{$36\pi$}{$9\pi$}\end{questions}
    \end{document}

    \end{document}

one more question ##

If i want to shuffle the question to prepare four different questions papers having same questions but with the different question numbers what should i do...??

that is i need to mark the question paper given above as Code A. and i need to print another question paper which marked as Code-B and in this question paper the first question code-A should be in question number 5 and similarly others also should have different positions...

thank you for your help in advance...

2

3 Answers 3

6

I incorporated this answer to solve your problem. After you write your four choices, put the correct choice (a, b, c, etc.) in braces as a fifth choice.

\documentclass[12pt,a4paper]{exam}
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\usepackage{ifthen}

% Accumulate the answers. Unmodified from Phil Hirschorn's answer
% https://tex.stackexchange.com/questions/15350/showing-solutions-of-the-questions-separately/15353
\newbox\allanswers
\setbox\allanswers=\vbox{}

\newenvironment{answer}
{%
    \global\setbox\allanswers=\vbox\bgroup
    \unvbox\allanswers
}%
{%
    \bigbreak
    \egroup
}

\newcommand{\showallanswers}{\par\unvbox\allanswers}
% End Phil's answer


% Is there a better way?
\newcommand*{\getanswer}[5]{%
    \ifthenelse{\equal{#5}{a}}
    {\begin{answer}\thequestion. (a)~#1\end{answer}}
    {\ifthenelse{\equal{#5}{b}}
        {\begin{answer}\thequestion. (b)~#2\end{answer}}
        {\ifthenelse{\equal{#5}{c}}
            {\begin{answer}\thequestion. (c)~#3\end{answer}}
            {\ifthenelse{\equal{#5}{d}}
                {\begin{answer}\thequestion. (d)~#4\end{answer}}
                {\begin{answer}\textbf{\thequestion. (#5)~Invalid answer choice.}\end{answer}}}}}
}

\setlength\parindent{0pt}
%usage \choice{ }{ }{ }{ }
%(A)(B)(C)(D)
\newcommand{\fourch}[5]{
    \par
    \begin{tabular}{*{4}{@{}p{0.23\textwidth}}}
        (a)~#1 & (b)~#2 & (c)~#3 & (d)~#4
    \end{tabular}
    \getanswer{#1}{#2}{#3}{#4}{#5}
}

%(A)(B)
%(C)(D)
\newcommand{\twoch}[5]{
    \par
    \begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
        (a)~#1 & (b)~#2
    \end{tabular}
    \par
    \begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
        (c)~#3 & (d)~#4
    \end{tabular}
    \getanswer{#1}{#2}{#3}{#4}{#5}
}

%(A)
%(B)
%(C)
%(D)
\newcommand{\onech}[5]{
    \par
    (a)~#1 \par (b)~#2 \par (c)~#3 \par (d)~#4
    \getanswer{#1}{#2}{#3}{#4}{#5}
}

\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth

\setlength\tabmaxwidth{0.96\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}

\newcommand{\choice}[5]{%
\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}%
\settowidth\widthchb{BM.#2}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
    \settowidth\widthchb{CM.#3}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
    \settowidth\widthchb{DM.#4}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%

% These if statements were bypassing the \onech option.
% \ifdim\widthch<\fourthtabwidth
%     \fourch{#1}{#2}{#3}{#4}{#5}
% \else\ifdim\widthch<\halftabwidth
% \ifdim\widthch>\fourthtabwidth
%     \twoch{#1}{#2}{#3}{#4}{#5}
% \else
%      \onech{#1}{#2}{#3}{#4}{#5}
%  \fi\fi\fi}

% Allows for the \onech option.
\ifdim\widthch>\halftabwidth
    \onech{#1}{#2}{#3}{#4}{#5}
\else\ifdim\widthch<\halftabwidth
\ifdim\widthch>\fourthtabwidth
    \twoch{#1}{#2}{#3}{#4}{#5}
\else
    \fourch{#1}{#2}{#3}{#4}{#5}
\fi\fi\fi}



\begin{document}
\begin{questions}

\question If $a = 3 + i$ and $z = 2 - 3i$ then the points on the Argand diagram representing az, 3az and - az are
\choice{Vertices of a right angled triangle}{Vertices of an equilateral triangle}{Vertices of an isosceles triangle}{Collinear}{a}

\question If z represents a complex number then $\arg (z) + \arg\left(\bar z\right)$ is 
\choice{$\dfrac{\pi}{4}$}{$\dfrac{\pi}{2}$}{0}{$\dfrac{\pi}{6}$}{b}

\question If the amplitude of a complex number is $\dfrac{\pi}{2}$ then the number is
\choice{purely imaginary}{purely real}{0}{neither real nor imaginary}{a}

\question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is
\choice{i}{-i}{1}{-1}{c}

\question The volume generated by rotating the triangle with vertices at (0, 0), (3, 0) and (3, 3) about x-axis is
\choice{$18\pi$}{$2\pi$}{$36\pi$}{$9\pi$}{a}

\question To complete the song, the last answer should be
\choice{a}{b}{c}{d}{e} % Invalid answer choice


\question To complete the song, the last answer should be 
\choice{a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex}{b}{c}{d}{a} 
\end{questions}

%\newpage  %Uncomment to put on new age
\bigskip
Answer Key:
\bigskip  
\showallanswers % Phil Hirschorn

\end{document}

enter image description here

7
  • thank you somuch... you have my job very very easy.. you know one think i need to type around 1000 mcq's like this.. you did it very simply... thankyou so much.....
    – David
    Jul 8, 2014 at 9:29
  • How can I fix with this code? \question To complete the song, the last answer should be \choice{a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex }{b}{c}{d}{e} % Invalid answer choice Oct 26, 2016 at 4:16
  • @toandhsp I found an error in the \ifdim statements so that the \onech command could never be reached. I fixed that error so now choices longer than one half the page are layed out as single columns. I updated the example result to include your question. Oct 26, 2016 at 20:27
  • @MikeTaylor A new problem. With choices longer than one half the page are layed out as single columns, can you align the key (a), (b), (c), (d)? \choice{a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex}{a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex}{c}{d}{a} Oct 27, 2016 at 0:04
  • @MikeTaylor And how to add the word 'Question' in each question? Oct 27, 2016 at 0:14
1

You can use the automultiplechoice package. With the help of the associated (open source) software, you will be able to correct the answer sheets automatically from the completed answer sheets scans. As an example:

\documentclass[a4paper]{article}
\usepackage[box,completemulti,separateanswersheet]{automultiplechoice}
\usepackage{multicol}
\begin{document}

\AMCrandomseed{1237893}

\element{general}{
  \begin{question}{coll}    
    If $a=3+i$ and $z=2-3i$ then the points on the Argand diagram representing $az$, $3az$ and $-az$ are
    Among the following persons, which one has ever been a President of the French Republic?
    \begin{multicols}{2}
      \begin{choices}
        \wrongchoice{Vertices of a right angled triangle}
        \wrongchoice{Vertices of an equilateral triangle}
        \wrongchoice{Vertices of an isocele triangle}
        \correctchoice{Collinear}
      \end{choices}
    \end{multicols}
  \end{question}
}

\element{general}{
  \begin{question}{arg-sum}    
    If $z$ reprensents a complex number then $arg(z)+arg(\bar z)$
    \begin{multicols}{4}
      \begin{choices}
        \wrongchoice{$\pi/4$}
        \wrongchoice{$\pi/2$}
        \correctchoice{$0$}
        \wrongchoice{$\pi/6$}
      \end{choices}
    \end{multicols}
  \end{question}
}

\onecopy{4}{    

%%% beginning of the test sheet header:    

\noindent{\bf QCM  \hfill TEST}

\begin{center}
  \large\bf Test\\ Examination on Jan. 1st, 2008
\end{center}

%%% end of the header

\shufflegroup{general}
\insertgroup{general}

\AMCcleardoublepage    

\AMCformBegin    

%%% beginning of the answer sheet header

{\large\bf Answer sheet:}
\hfill \namefield{\fbox{    
    \begin{minipage}{.5\linewidth}
      Firstname and lastname:

      \vspace*{.5cm}\dotfill
      \vspace*{1mm}
    \end{minipage}
  }}

\begin{center}
  \bf\em Answers must be given exclusively on this sheet: 
  answers given on the other sheets will be ignored.
\end{center}

%%% end of the answer sheet header

\AMCform    

}  

\end{document}
0

You can also have a look at the esami package, which provides simple commands to automatically achieve what you want.

The doc files for the package contain various examples, but if you need any help to set up your exam sheet, please feel free to ask.

You must log in to answer this question.

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