\documentclass{article}
\usepackage[%
    web={pro,tight,nodirectory},
    eforms,
    uselayers
]{aeb_pro}
\usepackage[lang=custom,nonrandomized]{dps}
\usepackage[uselayers]{aeb_pro}
\usepackage{graphicx}
\usepackage{pstricks-add}
\usepackage[absolute,overlay]{textpos}

\margins{.5in}{.5in}{.5in}{.5in} % left,right,top, bottom
\screensize{8in}{8.5in} % height, width

\DeclareDocInfo
{
    title=A Rookie's Big Night Out,
    author=D. P. Story,
    university=Acro\negthinspace\TeX.Net,
    email=dpstory@acrotex.net,
    subject=A Rookie's Big Night Out,
    keywords={matching, layers, game},
    talksite=http://www.acrotex.net,
    copyrightyears=2006-\the\year,
}
\talkdateLabel{Version}
\version{1.0}\nocopyright

\everyTextField{\textFont{TiRo}}

%
% A command for typesetting content in a layer, using absolute coordinates
% of textblock environment of the texpos package.
%
\def\setTextBlock#1{%
    \par\begin{textblock*}{2\linewidth}[0,0](.33\paperwidth,.42\paperheight)
    \xBld{#1}\psshadowbox[framesep=0pt]{\fcolorbox{red}{cornsilk}{%
    \parbox{\linewidth}{\insertRC{#1}}}}\eBld
    \end{textblock*}
}
% Convenience macro to set the content of the layer.
% #1 = the letter in the puzzle corresponding to the current question
% #2 = the content of the layer
%
\newcommand{\setContent}[2]{\defineRC{#1}{\textbf{Problem \theenumi:} #2}\setTextBlock{#1}}

% Command for placing the tiles of the picture. We assume that the pictures are number
% consecutively across rows.
% #1 = optional extension of the image
% #2 = number of rows
% #3 = number of columns
% #4 = base name of picture files
% #5 = parameters for the \includegraphics command, used to set the size of the tile
% Usage: \insertPuzzleImages{3}{2}{flowers1/DSC_0453_}{width=.5\linewidth}
\makeatletter
\newcommand\insertPuzzleImages[5][]{%
    \begingroup\offinterlineskip\count0=0
    \def\dpsExt{#1}\ifx\dpsExt\@empty\else\def\dpsExt{.#1}\fi
    \multido{\iR=1+1}{#2}%
    {%
        \hbox{%
        \multido{\iC=1+1}{#3}%
        {%
            \global\advance\count0by1\relax
            \ifnum\count0<10\relax
                \xBld{pic0\the\count0}\includegraphics[#5]{#40\the\count0 \dpsExt}\eBld
            \else
                \xBld{pic0\the\count0}\includegraphics[#5]{#4\the\count0 \dpsExt}\eBld
            \fi
        }}%\newline
    }%
%    \vfill
    \endgroup
}
\makeatother

\rheader{}

\parindent0pt
\parskip6pt

\DeclarePuzzle
{%
    {F}{F}
    {l}{l}
    {o}{o}
    {w}{w}
    {e}{e}
    {r}{r}
    {s}{s}
}

%\writeComposingEnv
%\begin{document}
%\end{document}

\begin{Composing}

\begin{cQ}{F}
Clothes\setContent{F}{You wear your \underbar{\hspace*{\ublength}} clothes when you pick her up.}
\end{cQ}
\begin{cA}{F}
best
\end{cA}

\begin{cQ}{l}
Shoes\setContent{l}{You should \underbar{\hspace*{\ublength}} your shoes before you put them on, and before
you pick her up.}
\end{cQ}
\begin{cA}{l}
shine
\end{cA}

\begin{cQ}{o}
Hair\setContent{o}{Part your hair in the
\underbar{\hspace*{\ublength}} of your head before you leave
your flat to pick her up.}
\end{cQ}
\begin{cA}{o}
middle
\end{cA}

\begin{cQ}{w}
Socks\setContent{w}{Your socks should have no \underbar{\hspace*{\ublength}} in them.}
\end{cQ}
\begin{cA}{w}
holes
\end{cA}

\begin{cQ}{e}
Shirt\setContent{e}{Your shirt should be clean and \underbar{\hspace*{\ublength}} the day before you
pick her up.}
\end{cQ}
\begin{cA}{e}
pressed (ironed)
\end{cA}

\begin{cQ}{r}
Sideburns\setContent{r}{Your sideburns should be \underbar{\hspace*{\ublength}} below your waist.}
\end{cQ}
\begin{cA}{r}
trimmed
\end{cA}

\begin{cQ}{s}
Hand\setContent{s}{When you arrive at her doorstep, you should have \underbar{\hspace*{\ublength}} in
your left hand.}
\end{cQ}
\begin{cA}{s}
flowers
\end{cA}

%---------- distractions ----------

\begin{cA}{fake1}
worst
\end{cA}

\begin{cA}{fake2}
scuffed
\end{cA}

\begin{cA}{fake3}
in the back
\end{cA}

\begin{cA}{fake4}
sand
\end{cA}

\begin{cA}{fake5}
wrinkled
\end{cA}

\begin{cA}{fake6}
long and hairy
\end{cA}

\begin{cA}{fake7}
sauerkraut
\end{cA}


\end{Composing}

%----------------
%
% The two commands \afterQhookA and \OnFocusQhookAA are hooks onto
% the \dpsQ command of the dps package. This allows us to post process
% the user's choice of a questions, and allows us to execute JS on focus.
% We use these two to call to JS function to support these additional
% features.
%
\def\afterQhookA#1{dpsShowLayer("#1")}
\def\OnFocusQhookAA#1{dpsHidePreviousLayer("#1")}

\begin{insDLJS}[dpsShowLayer]{dpslayer}{Layer Support}
// In this doc, we do not require a sign in by user. See example in ex3 for the
// use of the sign in feature.
var studentSignedIn = false;
/*
    Create mapping from letters to pictures
*/
var pic = new Array();
pic["F"]="pic01";
pic["l"]="pic02";
pic["o"]="pic03";
pic["w"]="pic04";
pic["e"]="pic05";
pic["r"]="pic06";
pic["s"]= null;
function dpsShowLayer(name)
{
    if ( studentSignedIn ) {
        var o = getxBld(name);
        if ( o != null  ) o.state = true;
    } else {
        var f = this.getField("dpsSignInName");
        if ( f == null ) {
            studentSignedIn = true;
            dpsShowLayer(name);
        }
        else event.target.value = "Off";
    }
}
function dpsHidePreviousLayer(name)
{
//    console.println("dpsShowLayer: activeQuestion = " + activeQuestion);
    if (!studentSignedIn) {
        var f = this.getField("dpsSignInName");
        if ( f != null ) {
            var nameField = f.value;
            if ( nameField.replace(/\s*/g,"") == "" )
                app.alert("You must enter your name in the field at the top of the page to get credit for this assignment.");
            else
                studentSignedIn = true;
        }
    } else studentSignedIn = true;
    if ( activeQuestion != "" ) {
        var activename = activeQuestion.replace(/ckbxQ\./,"");
        dpsHideLayer(activename);
    }
}
function dpsHideLayer(name)
{
    var o = getxBld(name);
    if ( o != null  ) o.state = false;
}
function afterCorrectChoiceHook()
{
    var name = activeQuestion.replace(/ckbxQ\./,"");
//    console.println( "afterCorrectChoiceHook(): name = " + name);
    try { if (pic[name] != null ) dpsShowLayer(pic[name]); } catch(e) {};
    dpsHideLayer(name);
}
/*
    When the puzzle is complete, there is an option to show an additional
    layer, here, we do nothing. This can be changed to fit
    your needs. See
*/
function dpsFinishedHook()
{
    return;
}
\end{insDLJS}


\begin{document}

\def\answidth{1.7in}
\def\queswidth{2in}

{\bfseries\noindent
\makebox[\textwidth]{\rlap{\webauthor}\hfill\textcolor{blue}{\webtitle}\hfill\llap{Acro\negthinspace\TeX.Net}}}

\textcolor{red}{\textbf{Instructions:}} Select a question from
the left panel by clicking its checkbox. Select your answer from
the right panel.  No guessing! A maximum of $\dsthreshold$ tries
on any problem before you get $\dspenaltypoints$ penalty points!
Passing is to complete the puzzle with only $\dspassing$
incorrect answers.

\def\answidth{1.7in}
\def\queswidth{2in}
\def\ublength{.5in}

\fbox{\begin{minipage}[t][5in][t]{\queswidth-2\fboxsep-2\fboxrule}\raggedright
\makebox[\linewidth]{\centering\textbf{Questions}}
\begin{enumerate}
\displayRandomizedQuestions
\end{enumerate}
\par\bigskip
\insertPuzzleImages{3}{2}{flowers1/DSC_0453_}{hiresbb,width=.5\linewidth}
\end{minipage}}%
%
\fbox{\begin{minipage}[t][5in][t]{\linewidth-\answidth-\queswidth-2\fboxsep-2\fboxrule}
When you have a date with a young lady, rookie, what do you take with you?\par\smallskip
\begin{center}
\parbox{2.6in}{\insertPuzzle{7}}
\end{center}
\hspace*{-\fboxsep}\rule{\linewidth+2\fboxsep}{.4pt}
\vfill
\placeMessageField[\Ff\FfReadOnly\BC{}]{\linewidth}{10\baselineskip}
\end{minipage}}%
%
\fbox{\begin{minipage}[t][5in][t]{\answidth-2\fboxsep-2\fboxrule}\raggedright
\makebox[\linewidth]{\textbf{Answers}}
\begin{itemize}
\displayRandomizedAnswers
\end{itemize}
\par\smallskip
\end{minipage}}%

\clearpage

\end{document}
