summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AR.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AR.tex')
-rw-r--r--macros/latex/contrib/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AR.tex174
1 files changed, 174 insertions, 0 deletions
diff --git a/macros/latex/contrib/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AR.tex b/macros/latex/contrib/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AR.tex
new file mode 100644
index 0000000000..9123ce34d3
--- /dev/null
+++ b/macros/latex/contrib/thorshammer/examples/ordinary-option/quiz-pwd-to-correct-AR.tex
@@ -0,0 +1,174 @@
+% Requires Acrobat
+\documentclass{article}
+\usepackage{amstext}
+\usepackage[designi]{web}
+\usepackage{exerquiz}[2019/10/11]
+
+\efsave\eq@@EndQuizButtonActions\as\eq@@EndQuizButtonActionsDefSave
+
+\usepackage[ordinary]{thorshammer}
+
+\thQzHeaderL{PWD Quiz}
+\thQzHeaderCQ{Quiz 1}
+
+\efsave\eq@@EndQuizButtonActions\as\eq@@EndQuizButtonActionsThorSave
+
+%\previewOn\pmpvOn
+
+\renewcommand\eqQuizPointsMsg{%
+"\eqptScore\space"+ptScore+" \eqOutOf\space"+nPointTotal}
+
+\let\app\textsf
+\let\pkg\textsf
+\let\env\texttt
+\let\opt\texttt
+\let\uif\textsf
+
+\execJSOn
+\useBeginQuizButton[\CA{Begin}]
+\useEndQuizButton[\CA{End}]
+
+% If the students have Acrobat, they can see the pin number
+% if they know how.
+
+\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{qz}
+
+\def\PIN{5243} % PIN number, change as desired
+\begin{insDLJS}{pin}{Pin Code}
+var _PinCode = "02JRVZdRgYgCA-Rtje8VkD";
+\end{insDLJS}
+
+\parindent0pt
+\parskip6pt
+
+\begin{document}
+
+\noindent\textbf{Goal:} Make the \uif{Correct} button password protected.\medskip
+
+\noindent\textbf{Discussion:}
+This demo file uses a \emph{hash string} to encode the password for the instructor to correct
+the quiz, it avoids the use of \app{Adobe Acrobat} by getting the hash string from the
+PDF \texttt{get-hash-string}. Copy the hash string generated from \texttt{get-hash-string}
+as the value of the JavaScript variable \texttt{\_PinCode} in the \textsf{insDLJS} environment
+seen in this source file for this document. Then, compile this document and distribute.
+
+%Delay the correction of this next quiz by expanding the new command
+%\verb|\pwdCorrBtnJS|.
+
+\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} \ No newline at end of file