From 17e285e7733468f00b6e8d096fdd7ffe818f09c8 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 11 Jun 2018 12:19:19 +0900 Subject: acrotex update --- texmf-dist/tex/latex/acrotex/aebjs.def | 260 +++++++++++++++++++++++++-------- 1 file changed, 203 insertions(+), 57 deletions(-) (limited to 'texmf-dist/tex/latex/acrotex/aebjs.def') diff --git a/texmf-dist/tex/latex/acrotex/aebjs.def b/texmf-dist/tex/latex/acrotex/aebjs.def index f3acd920..59be747d 100644 --- a/texmf-dist/tex/latex/acrotex/aebjs.def +++ b/texmf-dist/tex/latex/acrotex/aebjs.def @@ -8,7 +8,7 @@ %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Exerquiz.sty package, %% -%% Copyright (C) 1999-2017 D. P. Story %% +%% Copyright (C) 1999-2018 D. P. Story %% %% dpstory@uakron.edu %% %% %% %% This program can redistributed and/or modified under %% @@ -18,8 +18,9 @@ %% License, or (at your option) any later version. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ProvidesFile{aebjs.def} - [2017/03/16 v7.8g % + [2018/03/21 v8.2.2 % Exerquiz document level JavaScript (dps)] + \ifmakeExSlLocal\protect\endgroup^^J\fi \def\aeb@array{new Array} \def\refac#1{\\(#1\\)}\def\regrp#1{(#1)}\def\rechrclass#1{[#1]} \def\redm{\\.}\def\remul{\\*}\def\rediv{\\/}\def\repow{\\^} @@ -31,6 +32,17 @@ \def\NoPeekAlert{eqAppAlert(#1)}}\def\newNoPeekArgs{} \def\NoPeekAlert{eqAppAlert(\noPeekMsg,3)} \newcommand{\dlLibSpecRespJS}{"none","undefined","empty"} +\newif\ifSubstVars\SubstVarsfalse % dps17 +\newif\ifShowAppr\ShowApprtrue % dps17 +\def\altApprOn{\ShowApprtrue} % dps17 +\def\altApprOff{\ShowApprfalse} % dps17 +\def\corrChoiceFullyOn{\def\eqCorrChoiceFully{true}} +\def\corrChoiceFullyOff{\def\eqCorrChoiceFully{false}} +\corrChoiceFullyOn +\def\corrLocalChoiceFullyOn{\def\eqCorrLocalChoiceFully{true}} % dpsf07 +\def\corrLocalChoiceFullyOff{\def\eqCorrLocalChoiceFully{false}} % dpsf07 +\def\resetLocalChoiceFully{\let\eqCorrLocalChoiceFully\@empty} % dpsf07 +\resetLocalChoiceFully % no local implementation \begin{insDLJS*}[exerquizLoaded]{exerquiz} \begin{newsegment}{AeB: AcroTeX eDucation Bundle} /* @@ -50,12 +62,14 @@ var Score=0; var ptScore=0; var pcScore=0; var quizGrade="C"; +var NQuestions=0; +var NPointTotal=0; var e = Math.E; var pi = Math.PI; var replaceExclaim = \replaceexclaim; var negPointsAllowed = \negpointsallowed; var negPointsMarkupAllowed = \negpointsmarkupallowed; -var aQuizControl = new Array(); +var aQuizControl = new Object; var RightWrong=new Array(); var ProbValue = new Array(); var ProbDist = new Array(); @@ -236,6 +250,8 @@ function addMathObject(UserInput) function ParseInput(UserInput) { var re, repi; + re = /\b(a)\b/g; + UserInput = UserInput.replace(re, "(a)"); UserInput = stripWhiteSpace (UserInput); if (!ok2Continue) return null; for(var i=0; i< aGroup.length; i++) @@ -424,20 +440,24 @@ function TypeParameters(v) if ( aV[i].indexOf(":") == -1 ) aV[i] = "r:"+aV[i]; return aV.join(",") } -function ProcResp(flag,CorrAns,n,epsilon,domain,indepVar,oComp) +function ProcResp(flag,CorrAns,n,epsilon,domain,indepVars,oComp) { if (!ProcessIt) return null; var fieldname = event.target.name; - var UserAns = event.value; + var bSubstVars=(arguments.length>7); // dps17 + var UserAns=(arguments.length>7)?arguments[7]:event.value; var success = _ProcResp(flag,CorrAns,UserAns,% -n,epsilon,domain,indepVar,oComp); - if ( success == -1 || !ok2Continue ) return null; - if ( success == null ) { return syntaxError(), null; } +n,epsilon,domain,indepVars,oComp); + if ( success == -1 || !ok2Continue ) + { resetHeadsUp(flag,fieldname); return null; } // dps17 + if ( success == null ) + { resetHeadsUp(flag,fieldname); + return syntaxError(), null; } // dps17 return notifyField(success, flag, fieldname); } // changed name of var comp -> oComp -function _ProcResp(flag,CorrAns,UserAns,n,epsilon,domain,indepVar,oComp) -{ +function _ProcResp(flag,CorrAns,UserAns,n,epsilon,domain,% +indepVars,oComp){ ok2Continue = true; CorrAns = ParseInput(CorrAns); if (!ok2Continue) { @@ -462,9 +482,9 @@ function _ProcResp(flag,CorrAns,UserAns,n,epsilon,domain,indepVar,oComp) var reRlCommaSubst=/@c@/g; UserAns=UserAns.replace(reRlCommaSubst,","); UserAns = ParseInput(UserAns); - indepVar = TypeParameters(indepVar); + indepVars = TypeParameters(indepVars); if (!ok2Continue) return null; - var success=randomPointCompare(n,domain,indepVar,% + var success=randomPointCompare(n,domain,indepVars,% epsilon,CorrAns,UserAns,comp); if ( success && (typeof(oComp)=="object") % && (typeof(oComp.postParse)!="undefined") ) @@ -489,7 +509,7 @@ function processSpecialParse(oParse,UserAns) { } return retn; } -function randomPointCompare (n,domain,indepVar,epsilon,% +function randomPointCompare (n,domain,indepVars,epsilon,% CorrAns,userAns,comp) { var error, i, j, k; @@ -510,7 +530,7 @@ CorrAns,userAns,comp) -eval(endpoints[0]))*Math.random(); } var cXY = aXY.toString(); - error = comp(domain,cXY,indepVar,CorrAns,userAns); + error = comp(domain,cXY,indepVars,CorrAns,userAns); if (error == null) return null; if ( (error == -1) || (error > epsilon) ) {j=-1; break;} } @@ -623,6 +643,87 @@ function requireFormNot(UserAns, regexpr) { } } \end{newsegment} +\begin{newsegment}{Eq: Support for multi-letter variables} +if (!String.prototype.trim) { + String.prototype.trim = function () { + return this.replace(/^[\s\string\uFEFF\string\xA0]+|% +[\s\string\uFEFF\string\xA0]+$/g, ''); + }; +} +function _rplVarsBy(str1,str2) { + var re=new RegExp(str1,"g"); + var result=str1.replace(re,str2); + return result; +} +function processMathVars(str) { + var pos1,pos2,lead,tmp; + while ((pos1=str.indexOf("_rplVarsBy"))!=-1) { + pos2=str.indexOf("@"); + lead=str.substring(0,pos1); + tmp=str.substring(pos1,pos2); + str=str.substring(pos2+1); + tmp=eval(tmp); + str=lead+tmp+str; + } + str=str.replace(/\s/g,""); + return str; +} +getSubstValue.aSubsts=new Array(); // dps17 +function getSubstValue(v,s){ +/* + v=variable list, it may have the form "xyz", or if there + substitutions, it might look like "_rplVarsBy('theta','x')@"; + s=Either the user's answer or the author's answer. + + First develop an array of all variables are their substitutes. + ie, getSubstValue.aSubsts=[ "c","h", ["theta",x"], ["alpha",y],...]; +*/ + var pos1,pos2,tmp,args,re,arg1,arg2; +/* + change new style to old + New style: v="c,_rplVarsBy('theta->\u03B8','r:x')@,% +_rplVarsBy('alpha->\u03B1','r:y')@"; + Old style: v="c_rplVarsBy('theta->\u03B8','x')@% +_rplVarsBy('alpha->\u03B1','y')@"; +*/ + re=/([^'])(,)/g; + v=v.replace(re,'$1'); + re=/([ri]\string\:)+(\string\w)/g; + v=v.replace(re,'$2'); + getSubstValue.aSubsts=[]; // dps17 + var start=0; + while (true) { + v=v.substring(start); + pos1=v.indexOf("_rplVarsBy"); + if (pos1==-1) break; + pos2=v.indexOf("@"); + args=v.substring(pos1+10+1,pos2-1); + tmp=args.split(","); + arg1=eval(tmp[0].toString()); + tmp1=arg1.split("->"); + for (var i=0; i