diff options
Diffstat (limited to 'texmf-dist/doc/latex/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AA.tex')
-rw-r--r-- | texmf-dist/doc/latex/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AA.tex | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/texmf-dist/doc/latex/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AA.tex b/texmf-dist/doc/latex/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AA.tex new file mode 100644 index 00000000..e84d9781 --- /dev/null +++ b/texmf-dist/doc/latex/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AA.tex @@ -0,0 +1,190 @@ +\documentclass{article} +\usepackage{amstext} +\usepackage[designi]{web} +\usepackage{exerquiz}[2019/10/14] + +%\previewOn\pmpvOn + +% save the original defn of \eq@@EndQuizButtonActions as \eq@@EndQuizButtonActionsSave +\efsave\eq@@EndQuizButtonActions\as\eq@@EndQuizButtonActionsDefSave + +\usepackage[ordinary]{thorshammer} + +\thQzHeaderL{PWD Quizzes} +\thQzHeaderCQ{Quiz 1} + +% save the revised defn of \eq@@EndQuizButtonActions as \eq@@EndQuizButtonActionsThorSave +\efsave\eq@@EndQuizButtonActions\as\eq@@EndQuizButtonActionsThorSave + +\renewcommand\eqQuizPointsMsg{% +"\eqptScore\space"+ptScore+" \eqOutOf\space"+nPointTotal} + +\let\app\textsf +\let\pkg\textsf +\let\uif\textsf +\let\env\texttt +\let\opt\texttt +\def\cs#1{\texttt{\char`\\#1}} + + +\execJSOn +\useBeginQuizButton[\CA{Begin}] +\useEndQuizButton[\CA{End}] + +% If the students have Acrobat, they can see the pin number +% if they know how; however, if we use a hash string, the actual +% PIN is not retained within document. +\def\PIN{5243} % PIN number, change as desired + +% save \CorrBtnActionsJS as \CorrBtnActionsJSSave +\efsave\CorrBtnActionsJS\as\CorrBtnActionsJSSave +\begin{defineJS*}[\makeesc\@]{\CorrBtnActionsPwdJS} +var resp=app.response({ + cQuestion: "Enter the PIN number", + cTitle: "View Answers", + bPassword: true +}); +var _resp=Collab.hashString(resp); +if (_resp==_PinCode) { + correctQuiz("@eqBaseName",@thequestionno); + if (typeof correctSumryTbl == "function") + correctSumryTbl("@eqBaseName",@thequestionno); +} +\end{defineJS*} + +\DeclareQuiz{qz1} + +\begin{execJS}{execjs} +this.addScript("Pin Code","var _PinCode = \"" + Collab.hashString("\PIN")+"\""); +\end{execJS} + +\begin{document} + +\section{Introduction} + +\noindent\textbf{Goal:} Make the \uif{Correct} button password +protected.\medskip + +\noindent\textbf{Discussion:} This file illustrates the methods +of protecting the \uif{Correct} button with a password. This +file requires \app{Acrobat} to create; while the companion file +(\texttt{quiz-pwd-to-correct-AR.tex}) does not. + +If only MC and MS questions are posed, the \pkg{thorshammer} +package is not needed; otherwise, it is needed to support the +other types of questions. + +Within \pkg{exerquiz} the command that holds the JavaScript +action of the \uif{Correct} button is \cs{CorrBtnActionsJS}. We +save this macro, and change over to \cs{CorrBtnActionsPwdJS}, +defined in the preamble. We use the commands \cs{efsave} and +\cs{efrestore}, defined in \pkg{eforms}, to change the default +action to the password action, and back again. We do the same +thing for the \uif{End Quiz} action. (\pkg{thorshammer} +redefines \cs{eq@@EndQuizButtonActions}, the JavaScript actio of +the \uif{End Quiz} button.) + + +\newpage + +\section{Quiz with PIN to correct} + +% require students to answer all questions +\renewcommand\minQuizResp{highThreshold} % 1 + +For the quiz below, the \uif{Correct} button has an encrypted +password. The password appears in parentheses for the convenience of the casual reader. + +% use password version of \CorrButton action +\efrestore\CorrBtnActionsJS\from\CorrBtnActionsPwdJS +\begin{quiz*}{\currQuiz} +Solve each +\begin{questions} + \item The sum of 1 and 1 is\dots +\begin{answers}{5} +\bChoices + \Ans0 0\eAns + \Ans0 1\eAns + \Ans1 2\eAns + \Ans0 3\eAns + \Ans0 4\eAns +\eChoices +\end{answers} +\item $9+8=\RespBoxMath{17}{1}{.0001}{[0,1]}\cgBdry\CorrAnsButton{17}$ +\end{questions} +\end{quiz*}\quad\PointsField{\currQuiz}\olBdry\CorrButton{\currQuiz} (PIN: \PIN)\vcgBdry + +\AnswerField{\currQuiz} + +\newpage + +\section{Quiz without PIN to correct} + +Now we try to create an ordinary \pkg{exerquiz} quiz without password protection. + +% restore \eq@@EndQuizButtonActions from its default defn +\efrestore\eq@@EndQuizButtonActions\from\eq@@EndQuizButtonActionsDefSave +% restore \CorrBtnActionsJS from \CorrBtnActionsJSSave +\efrestore\CorrBtnActionsJS\from\CorrBtnActionsJSSave + +\renewcommand\minQuizResp{lowThreshold} + +\begin{quiz*}{qz2} +Solve each +\begin{questions} + \item The sum of 1 and 1 is\dots +\begin{answers}{5} +\bChoices + \Ans0 0\eAns + \Ans0 1\eAns + \Ans1 2\eAns + \Ans0 3\eAns + \Ans0 4\eAns +\eChoices +\end{answers} +\item $9+8=\RespBoxMath{17}{1}{.0001}{[0,1]}\cgBdry\CorrAnsButton{17}$ +\end{questions} +\end{quiz*}\quad\PointsField{\currQuiz}\olBdry\CorrButton{\currQuiz}\vcgBdry + +\AnswerField{\currQuiz} + + +\newpage + +\section{Another quiz with PIN to correct} + +It is possible to have a different PIN number for this quiz (multiple PINs in one document), but +I see no need for this. + +\DeclareQuiz{qz3} + + +% restore \eq@@EndQuizButtonActions from \eq@@EndQuizButtonActionsThorSave +\efrestore\eq@@EndQuizButtonActions\from\eq@@EndQuizButtonActionsThorSave +% restore password protection for Correct button +\efrestore\CorrBtnActionsJS\from\CorrBtnActionsPwdJS + +% require students to answer all questions +\renewcommand\minQuizResp{highThreshold} + +\begin{quiz*}{qz3} +Solve each +\begin{questions} + \item The sum of 1 and 1 is\dots +\begin{answers}{5} +\bChoices + \Ans0 0\eAns + \Ans0 1\eAns + \Ans1 2\eAns + \Ans0 3\eAns + \Ans0 4\eAns +\eChoices +\end{answers} +\item $9+8=\RespBoxMath{17}{1}{.0001}{[0,1]}\cgBdry\CorrAnsButton{17}$ +\end{questions} +\end{quiz*}\quad\PointsField{\currQuiz}\olBdry\CorrButton{\currQuiz} (PIN: \PIN)\vcgBdry + +\AnswerField{\currQuiz} + + +\end{document} |