\documentclass[a4paper]{article}
\usepackage[box,completemulti,keys=line]{automultiplechoice}

\usepackage{tikz}

\begin{document}

%%% preparation of the groups

\setdefaultgroupmode{withoutreplacement}

\element{figures}{
  \begin{question}{find-rectangle-in-choices-horiz}
    This is an example using small figures for each choice, set in
    horizontal. For choices in vertical shape, just use
    \texttt{choices}.
    Which of these figures is a rectangle?
    \begin{choiceshoriz}
      \correctchoice{%
        \begin{tikzpicture}
          \draw (-0.8,-0.5) rectangle (0.8,0.5);
        \end{tikzpicture}
      }
      \wrongchoice{%
        \begin{tikzpicture}
          \draw (-0.5,-0.5) -- (0.5,0.5);
        \end{tikzpicture}
      }
      \wrongchoice{%
        \begin{tikzpicture}
          \draw (0,0) circle (0.5);
        \end{tikzpicture}
      }
      \wrongchoice{%
        \begin{tikzpicture}
          \draw (-0.7,-0.5) -- (0,0.5) -- (0.7,-0.5) -- cycle;
        \end{tikzpicture}
      }
    \end{choiceshoriz}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-above-choices}
    This is a trivial example with a figure above the choices, which
    are displayed in horizontal.
    What is this figure?\\[1ex]
    \centerline{%
      \begin{tikzpicture}
        \draw (-4.5,-0.5) rectangle (4.5,0.5);
      \end{tikzpicture}
    }
    \begin{choiceshoriz}
      \correctchoice{A rectangle}
      \wrongchoice{A triangle}
      \wrongchoice{A circle}
      \wrongchoice{An ellipse}
    \end{choiceshoriz}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-below-choices}
    This is a trivial example with a figure below the choices, which
    are displayed in horizontal.
    What is this figure?
    \begin{choiceshoriz}
      \correctchoice{A rectangle}
      \wrongchoice{A triangle}
      \wrongchoice{A circle}
      \wrongchoice{An ellipse}
    \end{choiceshoriz}
    \centerline{%
      \begin{tikzpicture}
        \draw (-4.5,-0.5) rectangle (4.5,0.5);
      \end{tikzpicture}
    }
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-left-of-vertical-choices}
    We now go with an example where the figure is placed left from
    choices, which are displayed in vertical.
    What is this figure?\\[1ex]
    \begin{minipage}[c]{0.6\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \begin{tikzpicture}
        \draw (-4.5,-0.5) rectangle (4.5,0.5);
      \end{tikzpicture}
    \end{minipage}
    \begin{minipage}[c]{0.4\linewidth}
      \begin{choices}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choices}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-left-of-horiz-choices}
    We now go with an example where the figure is placed left from
    choices, which are displayed in horizontal.
    What is this figure?\\[1ex]
    \begin{minipage}[c]{0.15\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \begin{tikzpicture}
        \draw (-0.8,-0.5) rectangle (0.8,0.5);
      \end{tikzpicture}
    \end{minipage}
    \begin{minipage}[c]{0.85\linewidth}
      \begin{choiceshoriz}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choiceshoriz}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-right-of-vertical-choices}
    We now go with an example where the figure is placed right from
    choices, which are displayed in vertical.
    Everything is placed in the choices area.
    What is this figure?\\[1ex]
    \begin{minipage}[c]{0.4\linewidth}
      \begin{choices}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choices}
    \end{minipage}
    \begin{minipage}[c]{0.6\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \begin{tikzpicture}
        \draw (-4.5,-0.5) rectangle (4.5,0.5);
      \end{tikzpicture}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-right-of-horiz-choices}
    We now go with an example where the figure is placed right from
    choices, which are displayed in horizontal.
    Everything is placed in the choices area.
    What is this figure?\\[1ex]
    \begin{minipage}[c]{0.84\linewidth}
      \begin{choiceshoriz}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choiceshoriz}
    \end{minipage}
    \begin{minipage}[c]{0.15\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \begin{tikzpicture}
        \draw (-0.8,-0.5) rectangle (0.8,0.5);
      \end{tikzpicture}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-right-of-full-block-top}
    \begin{minipage}[t]{0.7\linewidth}
      In this example, the figure is placed right from all the
      text+choices block.
      Note that actual text will start as a block after the question
      header, we cannot integrate text with it, so we nedd to account
      for that space in the minipage size. This will look weird
      if tag is placed after the question header instead of above.
      What is this figure?
      \begin{choices}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choices}
    \end{minipage}
    \begin{minipage}[t]{0.15\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \centerline{
        \begin{tikzpicture}
          \draw (-0.5,-1.5) rectangle (0.5,1.5);
        \end{tikzpicture}}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-right-of-full-block-top-newline}
    \\
    \begin{minipage}[t]{0.88\linewidth}
      In this example, the figure is placed right from all the
      text+choices block.
      To better place text a line break is used, actual text will
      otherwise start as a block after the question
      header, as in previous example. This will look weird
      if tag is placed after the question header instead of above.
      Not the best look, but a lesser evil that will work reasonably
      with tags both above and after the question header.
      What is this figure?
      \begin{choices}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choices}
    \end{minipage}
    \begin{minipage}[t]{0.1\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \centerline{
        \begin{tikzpicture}
          \draw (-0.5,-1.5) rectangle (0.5,1.5);
        \end{tikzpicture}}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-left-of-full-block-top-newline}
    \\
    \begin{minipage}[t]{0.1\linewidth}
      \vspace*{0pt} % helps getting figure size in minipage
      \centerline{\begin{tikzpicture}
          \draw (-0.5,-1.5) rectangle (0.5,1.5);
        \end{tikzpicture}}
    \end{minipage}
    \begin{minipage}[t]{0.9\linewidth}
      In this example, the figure is placed left from all the
      text+choices block.
      Note that a line break is needed to allow everything be set to
      the left, since we cannot move the question header.
      Not the best look, but a lesser evil that will work reasonably
      with tags both above and after the question header.
      What is this figure?
      \begin{choices}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choices}
    \end{minipage}
  \end{question}
}

\element{figures}{
  \begin{question}{is-rectangle-left-of-full-block-top-shifted-left}
    \hspace*{-1.7cm}
    \begin{minipage}[t]{0.1\linewidth}
      \vspace*{5mm}
      \begin{tikzpicture}
        \draw (-0.5,-1.5) rectangle (0.5,1.5);
      \end{tikzpicture}
    \end{minipage}
    \begin{minipage}[t]{0.85\linewidth}
      In this example, the figure is placed left from all the
      text+choices block as before, but shifting the figure to try
      better placing. No line break is used and some extra manual
      tweak is needed.
      This will fail for long tags just after the question header, but
      will not look that bad if tag is placed above the question
      header.
      What is this figure?
      \begin{choices}
        \correctchoice{A rectangle}
        \wrongchoice{A triangle}
        \wrongchoice{A circle}
        \wrongchoice{An ellipse}
      \end{choices}
    \end{minipage}
  \end{question}
}

%%% copies

\onecopy{1}{

%%% beginning of the test sheet header:

\noindent{\bf QCM  \hfill TEST}

\vspace*{.5cm}
\begin{minipage}{.4\linewidth}
  \centering\large\bf Testing questions with  figures\\ 2018
\end{minipage}
\namefield{\fbox{\begin{minipage}{.5\linewidth}
      Firstname and lastname:

      \vspace*{.5cm}\dotfill
      \vspace*{1mm}
    \end{minipage}
  }
}
%%% end of the header

\begin{center}
  \hrule\vspace{2mm}
  \bf\Large Figures in questions
  \vspace{1mm}\hrule
\end{center}

\insertgroup{figures}

}

\end{document}
