summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/eq-save/eq-save.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-04-28 03:01:33 +0000
committerNorbert Preining <norbert@preining.info>2021-04-28 03:01:33 +0000
commitd929e40413ebfcbeaadd7e5469ed1eb0d867ba97 (patch)
tree29822671cc2b8a5972bc139952a695cd038df417 /macros/latex/contrib/eq-save/eq-save.dtx
parent95b070aee1a6351879af117f723c84d50b48338d (diff)
CTAN sync 202104280301
Diffstat (limited to 'macros/latex/contrib/eq-save/eq-save.dtx')
-rw-r--r--macros/latex/contrib/eq-save/eq-save.dtx85
1 files changed, 52 insertions, 33 deletions
diff --git a/macros/latex/contrib/eq-save/eq-save.dtx b/macros/latex/contrib/eq-save/eq-save.dtx
index dbdf6b4868..531995f8b3 100644
--- a/macros/latex/contrib/eq-save/eq-save.dtx
+++ b/macros/latex/contrib/eq-save/eq-save.dtx
@@ -14,7 +14,7 @@
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}[1997/12/01]
%<package>\ProvidesPackage{eq-save}
-%<package> [2021/02/17 v1.2 eq-save: save exerquiz quizzes and resume (dps)]
+%<package> [2021/04/27 v1.2.5 eq-save: save exerquiz quizzes and resume (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,hyperindex=false]{hyperref}
@@ -213,11 +213,21 @@
}
% \end{macrocode}
% \paragraph*{Open Page Action} We add a page open event to restore the data as needed. We only do this once
-% per document session.
-% \begin{macrocode}
-\thisPageAction{\JS{if(!restoreQuizData.hasRestoredData)\r\t
- var rqdTO=(app.setTimeOut("restoreQuizData();app.clearTimeOut(rqdTO);%
- restoreQuizData.hasRestoredData=true",1000));}}{}
+% per document session. The script used in contained in the command \DescribeMacro\restoreQD\cs{restoreQD}.
+% \changes{v1.2.3}{2019/27/07}{Made the open doc script into a macro \string\cs{resoreQD}}
+% \changes{v1.2.4}{2019/08/01}{Changed to page open}
+% \changes{v1.2.5}{2019/08/07}{added dirty=false to \string\cs{restoreQD}}
+% \begin{macrocode}
+\def\restoreQD{if(!restoreQuizData.hasRestoredData)\r\t
+ var rqdTO=(app.setTimeOut("try{restoreQuizData()}catch(e){};%
+ app.clearTimeOut(rqdTO);%
+ restoreQuizData.hasRestoredData=true;dirty=false;",1000));}
+%\addToDocOpen{\JS{\restoreQD}}
+\thisPageAction{\JS{\restoreQD}}{}
+%\thisPageAction{\JS{if(!restoreQuizData.hasRestoredData)\r\t
+% var rqdTO=(app.setTimeOut("restoreQuizData();%
+% app.clearTimeOut(rqdTO);%
+% restoreQuizData.hasRestoredData=true",1000));}}{}
% \end{macrocode}
% \paragraph*{Action prior to saving} It is important to save the quiz data, we can only do that if we save
% it to a field, the value of the field will be saved. We save the data to a hidden text field
@@ -366,10 +376,9 @@ cntCorrectResponses.nOutOfInDoc=0;
cntCorrectResponses.nPtsCorrectInDoc=0;
cntCorrectResponses.nPtsOutOfInDoc=0;
% \end{macrocode}
-%\leavevmode\IndexJS{cntCorrectResponses()}^^A
-% The workhorse of \pkg{eq-save}. It keeps tabs on the
-% total number of correct answers and the total number of questions. All \env{shortquiz}es are known immediately,
- %but results from \env{quiz} environments are not known until the student presses the `End Quiz' button.
+%\leavevmode\IndexJS{cntCorrectResponses()}is the workhorse of \pkg{eq-save}. It keeps tabs on the
+%total number of correct answers and the total number of questions. All \env{shortquiz}es are known immediately,
+%but results from \env{quiz} environments are not known until the student presses the `End Quiz' button.
% \begin{macrocode}
function cntCorrectResponses() {
var f=this.getField("\eqsroot");
@@ -414,6 +423,7 @@ function cntCorrectResponses() {
% included when they should.
% \changes{v1.1}{2018/04/07}{Removed test for isCorrect}
% \begin{macrocode}
+% if (typeof f.isCorrect=="undefined") continue;
cntCorrectResponses.nOutOfInDoc+=1;
if (f.isCorrect==1) {
cntCorrectResponses.nCorrectInDoc+=1;
@@ -471,11 +481,10 @@ function cntCorrectResponses() {
(cntCorrectResponses.nPtsOutOfInDoc));
}
% \end{macrocode}
-% \leavevmode\IndexJS{addInQuizResults()}^^A
-% Called by \texttt{cntCorrectResponses()} to add in the results
+% \leavevmode\IndexJS{addInQuizResults()} is called by \texttt{cntCorrectResponses()} to add in the results
% from the quizzes, if known. Because `Begin Quiz' and `End Quiz' can be links (not recommended) we save
% the results of the quiz as the value of the field \texttt{ScoreData.\ameta{quizName}}. \pkg{exerquiz}
-% package saved the quiz data in the form \texttt{"Score;\penalty0NQuestions;\penalty0ptScore;\penalty0NPointTotal"}.
+% package save the quiz data in the form \texttt{"Score;\penalty0NQuestions;\penalty0ptScore;\penalty0NPointTotal"}.
% This string can be split and the individual
% values may be retrieved.
% \begin{macrocode}
@@ -502,8 +511,7 @@ cntCorrectResponses.nCorrectInDoc;
}
}
% \end{macrocode}
-% \leavevmode\IndexJS{clearAllSQElements()}^^A
-% Clears all the quiz fields (all types). Much of the code
+% \leavevmode\IndexJS{clearAllSQElements()} clears all the quiz fields (all types). Much of the code
% here is copied from \pkg{exerquiz}.
% \begin{macrocode}
function clearAllSQElements() {
@@ -543,8 +551,7 @@ function clearAllSQElements() {
oRecordOfQuizData=new Object();
}
% \end{macrocode}
-% \leavevmode\IndexJS{chk4PassToQuestions()}^^A
-% This function is used in the keystroke and format
+% \leavevmode\IndexJS{chk4PassToQuestions()} This function is used in the keystroke and format
% phase of the \cs{nameField} command. If the student/user clears the field or changes the value
% of the field once it has been committed, \texttt{chk4PassToQuestions()} then calls \texttt{clearAllSQElements()}
% to clear all fields.
@@ -574,8 +581,7 @@ function chk4PassToQuestions(event) {
}
}
% \end{macrocode}
-% \leavevmode\IndexJS{collectQuizData()}^^A
-% Called by the \texttt{willSave} event. It saves
+% \leavevmode\IndexJS{collectQuizData()} is called by the \texttt{willSave} event. It save
% the object \texttt{oRecordOfQuizData} to the field \texttt{holdScoreData} as a string.
% \begin{macrocode}
function collectQuizData() {
@@ -583,9 +589,10 @@ function collectQuizData() {
f.value=(oRecordOfQuizData.toSource());
}
% \end{macrocode}
-% \leavevmode\IndexJS{restoreQuizData()}^^A
-% Called when the document is opened and attempts to
+% \leavevmode\IndexJS{restoreQuizData()} is called when the document is opened and attempts to
% transfer the value of \texttt{holdScoreData} back into \texttt{oRecordOfQuizData}.
+% \changes{v1.2}{2019/07/02}{Added ProbDist array}
+% \changes{v1.2.1}{2019/07/05}{Added RightWrong array}
% \begin{macrocode}
restoreQuizData.hasRestoredData=false;
function restoreQuizData() {
@@ -597,26 +604,38 @@ function restoreQuizData() {
// name of field is endQuiz.qzname
var pos=fname.indexOf(".");
var qzName=fname.substring(pos+1);
-% \end{macrocode}
+ var qzRoot=fname.substring(0,pos);
+ % \end{macrocode}
% (2021/02/17) Conditional to handle \texttt{ScoreData} only, this enables other
% data that are objects to be present in \texttt{oRecordOfQuizData}.
% \changes{v1.2}{2021/02/17}{Added conditional to process \texttt{ScoreData} only}
-% \begin{macrocode}
- if (fname.indexOf("ScoreData.")) {
- lstOfQuizzes[qzName]=eval(qzName);
- Score=1*oRecordOfQuizData[fname][0];
- NQuestions=1*oRecordOfQuizData[fname][1];
- ptScore=1*oRecordOfQuizData[fname][2];
- NPointTotal=1*oRecordOfQuizData[fname][3];
- var h=this.getField("ScoreData."+qzName);
- h.value=Score+";"+NQuestions+";"+ptScore+";"+NPointTotal;
+% \changes{v1.2.5}{2021/04/27}{Added a switch (JS) for more complex decision within
+% \string\texttt{restoreQuizData}}
+% \begin{macrocode}
+ switch(qzRoot) {
+ case "ScoreData":
+ lstOfQuizzes[qzName]=eval(qzName);
+ Score=1*oRecordOfQuizData[fname][0];
+ NQuestions=1*oRecordOfQuizData[fname][1];
+ ptScore=1*oRecordOfQuizData[fname][2];
+ NPointTotal=1*oRecordOfQuizData[fname][3];
+ var h=this.getField("ScoreData."+qzName);
+ h.value=Score+";"+NQuestions+";"+ptScore+";"+NPointTotal;
+ break;
+ case "ProbDist":
+ ProbDist=eval(oRecordOfQuizData[fname]);
+ break;
+ case "RightWrong":
+ RightWrong=eval(oRecordOfQuizData[fname]);
+ break;
+ default:
+ console.println("name not recognized:"+fname);
}
} else f.isCorrect=oRecordOfQuizData[fname];
}
}
% \end{macrocode}
-% \leavevmode\IndexJS{IhrNameFormat()}^^A
-% The format script for the \cs{nameField} command.
+% \leavevmode\IndexJS{IhrNameFormat()} is the format script for the \cs{nameField} command.
% \begin{macrocode}
function IhrNameFormat(event){
if(event.value!="") {