%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% exerquiz.4ht                          2021-02-07-14:58 %
% Copyright (C) 1999-2009       Eitan M. Gurari         %
% Copyright 2009-2021 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.

\def\Rect#1{#1}
\ifx \pdf@rect\:UnDef
   \newsavebox{\pdf@box}
   \def\pdf@rect#1{\leavevmode #1}
\fi
\NewConfigure{javascript}{1}

\let\sv:tocsection\tocsection
\def\tocsection{\let\toclikesection\:gobbleIII \sv:tocsection}
\def\hypertarget#1#2{\Link{}{#1}\EndLink#2}
\def\hyperlink#1#2{\Link{#1}{}#2\EndLink}

\append:def\exercise{\Link{}{page.ex\the@exno}\EndLink }
\pend:def\endsolution@sq{\def\thepage{ex\the@exno}}

\let\:shortquiz\shortquiz
\def\shortquiz{\gHAdvance\:onClick by 1
   \Link{}{page.qz\:onClick}\EndLink   \:shortquiz
   \pend:def\endsolution@sq{\def\thepage{qz\:onClick}}}

\pend:def\include@quizsolutions{%
    \let\sv:newpage\newpage
    \append:def\newpage{\ht:everypar{\HtmlPar}}}
\append:def\include@solutions{%
    \let\noindent\sv:noindent}

\HAssign\:onClick = 0
\HAssign\Prob:N = 0
\HAssign\Quiz:N = 0

\append:def\shortquiz{\pend:def\answers{\gHAdvance\Prob:N by 1
   \let\:NAME\empty}}
\let\:@quiz\@quiz
\def\@quiz*#1#2{%
   \if #1f \let\c:quiz\C:quiz\fi
   \:@quiz*{#1}{#2}%
   \pend:defI\answers{\gHAdvance\Prob:N by 1
   \let\:NAME\empty}}

\pend:def\quiz{%
   \let\:bqlabel\bqlabel
   \def\bqlabel{\IgnorePar\EndP
      \Tg<form action="." class="quiz"
            id="thisform\Quiz:N">%
            \Tg<input value="\:bqlabel"  type="reset"
             onClick='\c:quiz' />}%
    \let\:eqlabel\eq@eqlabel
    \def\eq@eqlabel{\IgnorePar\EndP
             \Tg<input type="button" value="\:eqlabel"
             onClick='\a:javascript \d:quiz' />%
        \ifeq@nocorrections\else
           \Tg<input type="button" value="\eq@CA"
              name="correct\Quiz:N"
              onClick='\a:javascript \e:quiz' />%
        \fi
    }%
    \gHAdvance\Quiz:N by 1 \gHAssign\Prob:N=0    \ShowPar
   }
\append:def\endquiz{\let\eq@eqlabel=\:eqlabel
   \Tg</form>\Tag{ans-\Quiz:N}{\Prob:N}}
\pend:def\shortquiz{\leavevmode
   \Tg<form action="." class="shortquiz">\IgnorePar}
\append:def\endshortquiz{\Tg</form>}{}{}
\def\Ans@i#1{\stepcounter{quizno}{
   \ifx#11
         \js:click{\b:shortquiz}{\a:shortquiz}{\ifx
                \@qzsolndest\empty 0\else 1\fi}%
   \else \js:click{\c:shortquiz}{\a:shortquiz}{0}%
   \fi
}}%
\NewConfigure{shortquiz}{3}
\pend:defII\ReturnTo{\noindent\a:ReturnTo}
\append:defII\ReturnTo{\b:ReturnTo}
\NewConfigure{ReturnTo}{2}

\def\Ans@l#1{\stepcounter{quizno}%
   \ifnum #1=1 \def\:NAME{ id="ans\Quiz:N x\Prob:N" }\fi
   \def\ANS{#1}%
   \js:click{\b:quiz}{\a:quiz}{0}}
\NewConfigure{quiz}{5}

\def\Ans@f#1{\stepcounter{quizno}%
   \ifnum #1=1 \def\:NAME{ id="ans\Quiz:N x\Prob:N" }\fi
   \def\ANS{#1}%
   \js:click{\B:quiz}{\A:quiz}{0}}
\NewConfigure{quiz*}[3]{\def\A:quiz{#1}\def\B:quiz{#2}\def\C:quiz{#3}}
\Configure{quiz*}{}{}{}

\LinkCommand\js:link{input,,,, /}
\LinkCommand\js:Link{input,onClick='\a:javascript \noexpand\:tempa
   href(\noexpand\:gobble,,, /}
\def\js:click#1#2#3{\ifnum #3=0
      \js:link[ type="button" value="#2"\Hnewline
                class="onClickClass"  onClick='\a:javascript #1'
                name="ans\Quiz:N y\Prob:N"
                \:NAME]{}{}%
   \else
      \def\:tempa{#1}%
      \js:Link[ );' type="button" value="#2"\Hnewline
                name="ans\Quiz:N y\Prob:N"
                class="onClickClass"  \:NAME]{\@qzsolndest}{}%
   \fi
}

\Hinput{exerquiz}
\endinput

