\documentclass[a4paper]{article}

\usepackage[utf8x]{inputenc}    
\usepackage[T1]{fontenc}
\usepackage[box,completemulti,separateanswersheet]{automultiplechoice}  

\begin{document}
\scoringDefaultS{haut=2, p=-1}  % correct score = 1; mz = max or zero (for single answer questions)
\scoringDefaultM{haut=3, p=-1}   % correct score = 1; mz = max or zero (for multiple answer questions)
% you can use \scoring{b= ,m=} to set individual question scores 
% (i.e. b = pts received for correct answer, m = pts lost for wrong answer)
% see question 1 for example

%%% beginning of the test sheet header:    

\noindent{\bf QCM  \hfill TEST}

\vspace*{.5cm}
\begin{minipage}{.9\linewidth}
\centering\large\bf CS169 - Midterm 1\\ October 15, 2013 \\ \end{minipage}

\begin{flushleft}\em
Duration : 3 hours
% insert instructions on answer sheet here
  The use of electronic calculators is forbidden.

  Questions using the sign \multiSymbole{} may have
  zero, one, or several correct answers.  Other questions have a single correct answer.

  Negative points may be given for \emph{wrong} answers.

\end{flushleft}
\vspace{1ex}

%%% end of the header

\AMCrandomseed{1237893}

\def\AMCformQuestion#1{\vspace{\AMCformVSpace}\par {\sc Question #1:} }    


  \begin{question}{id1}
  \scoring
  Given the following Ruby:  
  \begin{verbatim}
  test verbatim again
  \end{verbatim}
  Which is NOT a legal call to the \texttt{foo} method?
  \begin{choices}
    \correctchoice{foo a, \{:x=>1,:y=>2\}, :z=>3}
    \wrongchoice{foo(a, :x=>1, :y=>2, :z=>3)}
    \wrongchoice{foo(a, \{:x=>1,:y=>2\},\{:z=>3\})}
    \wrongchoice{foo a, \{:x=>1,:y=>2\},\{:z=>3\}}
  \end{choices}
  \end{question}

  \begin{question}{id3}
  %\scoring
  Given the following Ruby:  
  \begin{verbatim}
  test verbatim
  \end{verbatim}
  Which is NOT a legal call to the foo method?
  \begin{choices}
    \correctchoice{foo a, \{:x=>1,:y=>2\}, :z=>3}
    \wrongchoice{foo(a, :x=>1, :y=>2, :z=>3)}
    \wrongchoice{foo(a, \{:x=>1,:y=>2\},\{:z=>3\})}
    \wrongchoice{foo a, \{:x=>1,:y=>2\},\{:z=>3\}}
  \end{choices}
  \end{question}

  \begin{questionmult}{id2}
    In the Ruby expression a.foo, which calls method foo on receiver a, which of the following conditions affects whether the call succeeds?  Check all that apply:
  \begin{choices}
    \correctchoice{a responds to the foo method}
    \wrongchoice{a's class, or one of its superclasses or included modules, implements method\textunderscore missing in a way that handles the foo method}
    \wrongchoice{a is an instance of a class, rather than the class itself}
    \correctchoice{a is of the correct class (type)}
  \end{choices}
  \end{questionmult}

\begin{question}{id4} 
  Given the following Ruby:  
  \begin{verbatim}
  test verbatim
  \end{verbatim}
  Which is NOT a legal call to the foo method?
  \begin{choices}
    \correctchoice{foo a, \{:x=>1,:y=>2\}, :z=>3}
    \wrongchoice{foo(a, :x=>1, :y=>2, :z=>3)}
    \wrongchoice{foo(a, \{:x=>1,:y=>2\},\{:z=>3\})}
    \wrongchoice{foo a, \{:x=>1,:y=>2\},\{:z=>3\}}
  \end{choices}
  \end{question}

\begin{question}{id5}
  Given the following Ruby:  
  \begin{verbatim}
  test verbatim
  \end{verbatim}
  Which is NOT a legal call to the foo method?
  \begin{choices}
    \correctchoice{foo a, \{:x=>1,:y=>2\}, :z=>3}
    \wrongchoice{foo(a, :x=>1, :y=>2, :z=>3)}
    \wrongchoice{foo(a, \{:x=>1,:y=>2\},\{:z=>3\})}
    \wrongchoice{foo a, \{:x=>1,:y=>2\},\{:z=>3\}}
  \end{choices}
  \end{question}

\onecopy{1}{    

\AMCcleardoublepage    

\AMCformBegin    

%%% beginning of the answer sheet header

\begin{minipage}{.9\linewidth}
\centering\large\bf CS169 - Midterm 1\\ October 15, 2013 \\ Answer Sheet\end{minipage}

{\setlength{\parindent}{0pt}\hspace*{\fill}\AMCcode{etu}{8}\hspace*{\fill}
\begin{minipage}[b]{6.5cm}
\vspace{3ex}
$\longleftarrow{}$\hspace{0pt plus 1cm} Please fill in your student ID number to the left
and write your full name AND login ID below.

\vspace{3ex}

\hfill\namefield{\fbox{    
    \begin{minipage}{.9\linewidth}
      \vspace*{.5cm}
      Name:
      \vspace*{.5cm}\dotfill
     
      Login ID: 
      \vspace*{.5cm}\dotfill
      \vspace*{1mm}
    \end{minipage}
  }}\hfill\vspace{5ex}\end{minipage}\hspace*{\fill}

}

\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    

\clearpage    

}  

\end{document}
