%%
%% This is file `aebsumrytbls.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% exerquiz.dtx  (with options: `copyright,sumrytbls')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exerquiz.sty package,             2013-12-11         %%
%% Copyright (C) 1999-2013  D. P. Story                 %%
%%   dpstory@uakron.edu                                 %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesFile{aebsumrytbls.def}
 [2013/12/13 v6.7p %
 Exerquiz support for summary tables (dps)]
\def\ccatCurrQzWith(#1){\currQuiz#1}
\def\pbPopulateSumTable{\pushButton[\W0\BG{}\BC{}\S{S}
    \AA{\AAPageVisible{popVisitsTbl("\currQuiz",\thequestionno)}}]%
    {\currQuiz activateSC}{0pt}{0pt}}
\def\pbDoNoCorrectSumryTbl{\makebox[0pt][l]{\pushButton[\F{\FHidden}]%
    {\currQuiz NoCorrections}{0pt}{0pt}}}
\newcount\eq@rowcnt
\newcommand{\sumryTblQ}{Question}
\newcommand{\sumryTblR}{Responded}
\newcommand{\sumryTblP}{Page}
\newcommand{\sumryTblProbFmt}[1]{\textbf{\textcolor{blue}{#1}}}
\newcommand{\sumrytablesep}{\space}
\def\eq@begintab{%
    \begin{tabular}[t]{lcc}\sumryTblQ&\sumryTblR&\sumryTblP\\\hline
    {\Large\strut}%
}
\def\eq@endtab{\end{tabular}}
\define@key{smrytbl}{ntables}{%
    \@tempcntb=#1
    \ifnum\@tempcntb<1 \@tempcntb=1 \fi
    \ifnum\@tempcntb>2 \@tempcntb=2 \fi
    \edef\smrytbl@ntables{\the\@tempcntb}%
}
\def\smrytbl@ntables{2}%
\newif\ifeqshowmarkup\eqshowmarkupfalse
\define@key{smrytbl}{showmarkup}[true]{%
    \csname if#1\endcsname\eqshowmarkuptrue
        \else\eqshowmarkupfalse\fi
}
\newif\ifsmrytbl@corrections\smrytbl@correctionstrue
\define@key{smrytbl}{nocorrections}[true]{%
    \csname if#1\endcsname\smrytbl@correctionsfalse
        \else\smrytbl@correctionstrue\fi
}
\newcommand{\displaySumryTbl}[2][]{%
    \begingroup\edef\currQuiz{#2}%
    \edef\@expand@temp{\noexpand\setkeys{smrytbl}{#1}}%
    \@expand@temp\count0=\smrytbl@ntables\relax
    \ifnum\count0=1\relax\else\count0=2\relax\fi
    \eq@rowcnt=0\relax\@tempcntb=\value{questionno}%
    \ifnum\count0=2
        \divide\@tempcntb2\relax
        \advance\@tempcntb\ifodd\value{questionno}2\else1\fi
        \xdef\@beginSecCol{\the\@tempcntb}%
        \advance\@tempcntb-1\relax
    \fi
    \let\@eqListExp\@@eqListExp
    \eqQzQuesList
    \endgroup
}
\def\@@eqListExp#1#2{%
    \global\advance\eq@rowcnt1
    \ifnum\eq@rowcnt=1
        \pbPopulateSumTable\ifsmrytbl@corrections\else
        \pbDoNoCorrectSumryTbl\fi\expandafter\eq@begintab\fi
    \ifnum\count0=2 \ifnum\eq@rowcnt=\@beginSecCol\relax
        \sumrytablesep\expandafter\eq@begintab\fi\fi
    \sumryTblProbFmt{#1} &%
    \checkBox[\Ff{\FfReadOnly}]%
        {\ccatCurrQzWith(SanityCheck).\the\eq@rowcnt}%
        {9bp}{9bp}{Yes}\ifeqshowmarkup
        \makebox[0pt][l]{\kern3bp\textField[\Ff\FfReadOnly\BC{}
        \textColor{1 0 0}\textSize{0}\autoCenter{n}
        ]{\ccatCurrQzWith(SanityCheckPts).\the\eq@rowcnt}%
        {12bp}{9bp}}\fi&%
    \setLink[\A{\JS{this.pageNum=(#2-1)}}]{#2}\\[1bp]
    \ifnum\count0=2 \ifnum\eq@rowcnt=\@tempcntb
        \expandafter\eq@endtab\fi\fi
    \ifnum\eq@rowcnt=\thequestionno\relax\expandafter\eq@endtab\fi
}
\def\writeProListAux{%
    \eq@IWAuxOut{\string\expandafter\string\gdef
    \string\csname\space\currQuiz QzQuesList\string\endcsname
    {\eqQzQuesList}}%
    \eq@IWAuxOut{\string\expandafter\string\gdef
    \string\csname\space\currQuiz nQuestions\string\endcsname
    {\thequestionno}}%
}
\def\setParamSumryTblAux{%
    \edef\eqQzQuesList{\@nameuse{\currQuiz QzQuesList}}%
    \@ifundefined{\currQuiz nQuestions}{}{%
        \value{questionno}=\@nameuse{\currQuiz nQuestions}}%
}
\newenvironment{sumryTblAux}[1]{%
    \DeclareQuiz{#1}\setParamSumryTblAux}{}
\begin{insDLJS}[correctSumryTbl]{sumtbljs}{Eq: Populate Summary Table}
function correctSumryTbl(qtfield,nQuestions) {
    var sc=this.getField(qtfield+"SanityCheck");
    var nc=this.getField(qtfield+"NoCorrections");
    if (sc != null && nc == null ) {
        for (var i=0; i<nQuestions; i++) {
            var cb=this.getField(qtfield+"SanityCheck."+(i+1));
            if (typeof RightWrong[i+1] == "undefined" ) {
                cb.strokeColor=\wrngColorJS;
                continue;
            }
            if ( RightWrong[i+1] == 1 ) {
                cb.strokeColor=\rghtColorJS;
                continue;
            }
            if ( RightWrong[i+1] == 0 ) {
                // this is either an obj or multiple choice q
                if ( typeof ProbValue[i+1] == "object" )
                    cb.strokeColor=( ProbValue[i+1][2] > 0 )?%
\partialColorJS:\wrngColorJS;
                else cb.strokeColor=\wrngColorJS; // obj q
                continue;
            }
            // either multiple selection or grouped math
            if ( RightWrong[i+1][0] == "grp" ) {
                // grouped question
                var f = this.getField("grpobj."+qtfield+"."+(i+1));
                var l = f.getArray().length;
                // is this right?
                for (var sum=0, j=1; j<=l; j++)
                    sum+=(!!RightWrong[i+1][j]);
                if ( sum == l ) cb.strokeColor=["RGB", 0, .6, 0];
                else cb.strokeColor=( sum > 0 )?%
\partialColorJS:\wrngColorJS;
                continue;
            }
            // multiple selection
            if ( RightWrong[i+1][0] == 1 ) cb.strokeColor=\rghtColorJS;
            else cb.strokeColor=(RightWrong[i+1][1]== 1)?%
\partialColorJS:\wrngColorJS;
        }
    }
    var f=this.getField(qtfield+"SanityCheckPts");
    if ( f != null ) {
        for ( var i = 1; i <= nQuestions; i++) {
            if ( ProbValue[i] == undefined ) ProbValue[i]=0
                // find the next non-null field
                var g=this.getField(qtfield+"SanityCheckPts."+i);
                var qpts=(ProbDist[i]==undefined) ? 0 : ProbDist[i];
                g.value = qpts + (( qpts == 1 ) ? "\eqptLabel\space"
                    : " \eqptsLabel");
        }
    }
}
function popVisitsTbl(qtfield,nQuestions) {
    if ( aQuizControl[qtfield] == 1) {
        this.resetForm([qtfield+"SanityCheck"]);
        for ( var i=0; i < nQuestions; i++ ) {
            var f=this.getField(qtfield+"SanityCheck."+(i+1));
            if ( typeof Responses[i+1]!="undefined")
                f.checkThisBox(0,true);
            else
                f.checkThisBox(0,false);
        }
    }
}
\end{insDLJS}
\endinput
%%
%% End of file `aebsumrytbls.def'.
