%%
%% This is file `aebsumrytbls.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% exerquiz.dtx  (with options: `copyright,sumrytbls')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exerquiz.sty package,                                %%
%% Copyright (C) 1999-2020  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}
 [2021/01/20 v8.6.2 %
 Exerquiz support for summary tables (dps)]
\def\ccatCurrQzWith(#1){\currQuiz#1}
\def\pbPopulateSumTable{\pushButton[\W0\BG{}\BC{}\S{S}\autoCenter{n}
  \TU{\thequestionno}\Ff{\FfReadOnly}
  \AA{\AAPageVisible{try{popVisitsTbl("\currQuiz",\thequestionno)}%
      catch(e){}}}]{\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}
\define@key{smrytbl}{ntables}{%
  \@tempcntb=#1
  \ifnum\@tempcntb<\@ne\@tempcntb=\@ne\fi
  \ifnum\@tempcntb>\thr@@\@tempcntb=\thr@@\fi
  \edef\smrytbl@ntables{\the\@tempcntb}%
}
\def\smrytbl@ntables{2}
\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
}
\define@key{smrytbl}{showOutOf}[true]{%
  \csname if#1\endcsname\eqshowOutOftrue\def\stfmtType{OO}%
    \gdef\showOutOfinSmryTbl{true}\let\stmarkupbox\relax
  \else
    \eqshowOutOffalse\let\stfmtType\@empty
    \gdef\showOutOfinSmryTbl{false}%
  \fi
}
\let\stfmtType\@empty
\define@key{smrytbl}{setDimens}[]{#1}
\def\showOutOfinSmryTbl{false}
\def\stmarkupbox{\makebox[0pt][l]}
\newcommand{\displaySumryTbl}[2][]{%
  \begingroup\edef\currQuiz{#2}\edef\oField{#2}\edef\curr@quiz{#2}%
  \setkeys{smrytbl}{#1}%
  \eqtmpcnta\smrytbl@ntables\relax
  \eq@rowcnt\z@\@tempcntb=\value{questionno}%
  \ifnum\eqtmpcnta=\tw@
    \divide\@tempcntb\tw@
    \advance\@tempcntb\ifodd\value{questionno}\tw@\else\@ne\fi
    \xdef\@beginSecCol{\the\@tempcntb}\advance
    \@tempcntb\m@ne
  \fi
  \ifnum\eqtmpcnta=\thr@@
    \edef\eq@n{\the\@tempcntb}%
    \divide\@tempcntb\eqtmpcnta
    \edef\eq@q{\the\@tempcntb}%
    \@tempcnta=\@tempcntb\multiply\@tempcnta3
    \edef\eq@p{\the\@tempcnta}%
    \@tempcnta=\eq@n
    \advance\@tempcnta-\eq@p\relax
    \ifnum\@tempcnta=\z@
      \@tempcntb=\eq@q \advance\@tempcntb\@ne
      \xdef\@beginSecCol{\the\@tempcntb}%
      \advance\@tempcntb\eq@q\relax
      \xdef\@beginThrdCol{\the\@tempcntb}%
    \else\ifnum\@tempcnta=\@ne
      \@tempcntb=\eq@q \advance\@tempcntb\@ne
      \edef\nB@lCols{\the\@tempcntb}%
      \advance\@tempcntb\@ne
      \xdef\@beginSecCol{\the\@tempcntb}%
      \advance\@tempcntb\eq@q\relax
      \xdef\@beginThrdCol{\the\@tempcntb}%
    \else\ifnum\@tempcnta=\tw@
      \@tempcntb=\eq@q \advance\@tempcntb\@ne
      \edef\nB@lCols{\the\@tempcntb}%
      \advance\@tempcntb\@ne
      \xdef\@beginSecCol{\the\@tempcntb}%
      \advance\@tempcntb\nB@lCols
      \xdef\@beginThrdCol{\the\@tempcntb}%
    \fi\fi\fi
    \@tempcntb=\eq@n
  \fi
    \let\@eqListExp\@@eqListExp
    \eqQzQuesList
    \endgroup
}
\def\eq@begintab{%
  \begin{tabular}[t]{lcc}\sumryTblQ&\sumryTblR&\sumryTblP\\\sthline
  {\Large\strut}}
\def\sthline{\hline}
\def\eq@endtab{\end{tabular}}
\def\sumrytblCkMUsep{\kern3bp}
\def\sumrytbllinkHook#1{#1}
\newcommand{\sumryTblProbFmt}[1]{\textbf{\textcolor{blue}{#1}}}
\newcommand{\sumrytablesep}{\space}
\def\stmarkupWidth{12bp}\def\stmarkupHeight{9bp}\def\stmarkupTextSize{0}
\def\st@scndclmn{%
  \checkBox[\Ff{\FfReadOnly}]
    {\ccatCurrQzWith(SanityCheck).\the\eq@rowcnt}
    {\markupHeight}{\markupHeight}{Yes}%
  \ifeqshowmarkup
    \stmarkupbox{\sumrytblCkMUsep\textField[%
      \Ff\FfReadOnly\BC{}\textColor{\pcMarkupColor}
      \textSize{\stmarkupTextSize}\autoCenter{n}]
    {\ccatCurrQzWith(SanityCheck\stfmtType Pts).\the\eq@rowcnt}%
    {\stmarkupWidth}{\stmarkupHeight}}%
  \fi
}
\def\st@thrdclmn#1{%
  \setLink[\linktxtcolor{\@linkcolor}
    \A{\JS{this.pageNum=(#1-1)}}]{\sumrytbllinkHook{#1}}}
\def\@@eqListExp#1#2{\global\advance\eq@rowcnt\@ne
  \ifnum\eq@rowcnt=\@ne
    \pbPopulateSumTable\ifsmrytbl@corrections\else
    \pbDoNoCorrectSumryTbl\fi\expandafter\eq@begintab\fi
  \ifnum\eqtmpcnta>\@ne\ifnum\eq@rowcnt=\@beginSecCol\relax
    \eq@endtab\expandafter\sumrytablesep\expandafter\eq@begintab
  \fi\fi
  \ifnum\eqtmpcnta=\thr@@\ifnum\eq@rowcnt=\@beginThrdCol\relax
    \eq@endtab\expandafter\sumrytablesep\expandafter\eq@begintab
  \fi\fi
    \sumryTblProbFmt{#1}&\st@scndclmn&\st@thrdclmn{#2}\\[1bp]
  \ifnum\eq@rowcnt=\value{questionno}\expandafter\eq@endtab\fi
}
\def\writeProListAux{%
  \eq@IWAuxOut{\string
    \csarg\string\gdef{\currQuiz QzQuesList}{\eqQzQuesList}}%
  \eq@IWAuxOut{\string
    \csarg\string\gdef{\currQuiz nQuestions}{\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 oQName=eval(qtfield);
    var rightColor=(typeof oQName.RightColorJSLoc=="undefined")%
?\rghtColorJS:oQName.RightColorJSLoc;
    var wrongColor=(typeof oQName.WrongColorJSLoc=="undefined")%
?\wrngColorJS:oQName.WrongColorJSLoc;
    var partialColor=(typeof oQName.PartialColorJSLoc=="undefined")%
?\partialColorJS:oQName.PartialColorJSLoc;
    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=wrongColor;
                continue;
            }
            if ( RightWrong[i+1] == 1 ) {
                cb.strokeColor=rightColor;
                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 )?%
partialColor:wrongColor;
                else cb.strokeColor=wrongColor; // 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 )?%
partialColor:wrongColor;
                continue;
            }
            // multiple selection
            if ( RightWrong[i+1][0] == 1 ) cb.strokeColor=rightColor;
            else cb.strokeColor=(RightWrong[i+1][1]== 1)?%
partialColor:wrongColor;
        }
    }
    var f1=this.getField(qtfield+"SanityCheckPts");
    var f2=this.getField(qtfield+"SanityCheckOOPts");
    var h=this.getField(qtfield+"activateSC");
    if ( f1 != 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];
                if ( !negPointsAllowed && (qpts < 0) ) qpts=0;
                var thesePts= qpts + (( qpts == 1 )?%
" \eqptLabel":" \eqptsLabel");
                g.value = thesePts;
        }
    }
    if ( f2 != 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+"SanityCheckOOPts."+i);
                var qpts=(ProbDist[i]==undefined) ? 0 : ProbDist[i];
                if ( !negPointsAllowed && (qpts < 0) ) qpts=0;
                var ptValue = oQName.PtValues[i];
                var probPts = ptValue + (( ptValue == 1 )?%
" \eqptLabel":" \eqptsLabel");
                g.value = qpts +" \stOutOf\space"+probPts;
        }
    }
}
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));
            f.checkThisBox(0,(typeof Responses[i+1]!="undefined"));
        }
    }
}
function fieldPopTbl(qtfield) {
    var f=this.getField(qtfield+"activateSC");
    if ( f != null) {
        var n=Number(f.userName);
        var a = [ qtfield, n ];
        popVisitsTbl.apply(null,a);
    }
}
\end{insDLJS}
\endinput
%%
%% End of file `aebsumrytbls.def'.
