From 26f4947f509c2440ce28e625133a15f6a2446920 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 13 Sep 2018 10:28:30 +0900 Subject: update acrotex --- texmf-dist/tex/latex/acrotex/aebjs.def | 3048 ++++++++++++++++---------------- 1 file changed, 1524 insertions(+), 1524 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 59be747d..57fd0c3b 100644 --- a/texmf-dist/tex/latex/acrotex/aebjs.def +++ b/texmf-dist/tex/latex/acrotex/aebjs.def @@ -1,1524 +1,1524 @@ -%% -%% This is file `aebjs.def', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% exerquiz.dtx (with options: `copyright,aebjs') -%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Exerquiz.sty package, %% -%% Copyright (C) 1999-2018 D. P. Story %% -%% dpstory@uakron.edu %% -%% %% -%% This program can redistributed and/or modified under %% -%% the terms of the LaTeX Project Public License %% -%% Distributed from CTAN archives in directory %% -%% macros/latex/base/lppl.txt; either version 1 of the %% -%% License, or (at your option) any later version. %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\ProvidesFile{aebjs.def} - [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{\\^} -\def\redigit{\\d}\def\reany{.}\def\rebstr{\string^}\def\reestr{\string$} -\def\preReqForm{\Array(requireForm,\@gobble} -\def\preDenyForm{\Array(denyForm,\@gobble} -\def\postDenyForm{\Array(requireFormNot,\@gobble} -\newcommand{\noPeekArgs}[1]{% - \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} -/* - Document Level JavaScript - AcroTeX eDucation Bundle - D. P. Story copyright 2000-\the\year -*/ -var exerquizLoaded = true; -this.disclosed = true; -app.runtimeHighlight=false; -\end{newsegment} -\begin{newsegment}{Eq: Global Data} -var ok2Continue = true; -var ProcessIt = true; -var retn; -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 Object; -var RightWrong=new Array(); -var ProbValue = new Array(); -var ProbDist = new Array(); -var ProbType = new Array(); -var Responses=new Array(); -var appAlerts = new Object; -var _mathVars="x"; -var _ModalNotOn=true; -var GradeScaleDefault=new Array(\eqGradeScale); -var aDlLibSpecResp=new Array(\dlLibSpecRespJS); -var JSfBuiltIn = new Array - ( "abs","acos","asin","atan","ceil", "floor","cos","exp", - "log","max","min","pow","random","round","sin", - "sqrt","tan"); -var JSfCustomEarly = new Array ("arctan", "arcsin", "arccos") -var JSfCustomLate = new Array - ( "logc", "ln","sec","csc","cot", - "asinh", "acosh","atanh","acoth","asech","acsch", - "sinh", "cosh","tanh","coth","sech","csch","sgn", - "C","P","fact","pi"); -var JSf = new Array().concat(JSfCustomEarly, JSfBuiltIn, JSfCustomLate); -var JSfCustom = new Array().concat(JSfCustomEarly, JSfCustomLate); -var JSc = new Array("PI","E") -function ln(x) { return Math.log(x); } -function sec(x) { return 1/Math.cos(x); } -function csc(x) { return 1/Math.sin(x);} -function cot(x) { return Math.cos(x)/Math.sin(x); } -function arctan(x) { return Math.atan(x); } -function arcsin(x) { return Math.asin(x); } -function arccos(x) { return Math.acos(x); } -function logc(x) { return Math.LOG10E * Math.log(x); } -function C(x,y) {return ch(x,y);} -function P(x,y) {return perm(x,y);} -function sinh(x) { return ( Math.exp(x) - Math.exp(-x) )/2; } -function cosh(x) { return ( Math.exp(x) + Math.exp(-x) )/2; } -function tanh(x) { - return (Math.exp(x)-Math.exp(-x))/(Math.exp(x)+Math.exp(-x)); } -function coth(x) { - return ( Math.exp(x)+Math.exp(-x))/(Math.exp(x)-Math.exp(-x)); } -function sech(x) { return 2/( Math.exp(x) + Math.exp(-x) )/2; } -function csch(x) { return 2/( Math.exp(x) - Math.exp(-x) )/2; } -function asinh(x) { return Math.log (x+Math.sqrt(Math.pow(x,2)+1)); } -function acosh(x) { - return Math.log (x+Math.sqrt(Math.pow(x,2)-1)); } // x ge 1 -function atanh(x) { return .5*Math.log ((1+x)/(1-x)); } // -1 < x < 1 -function acoth(x) { return atanh(1/x); } // |x| > 1 -function asech(x) { return acosh(1/x); } // 0 < x le 1 -function asch(x) { return asinh(1/x); } // x ne 0 -function acsch(x) { return asinh(1/x); } // x ne 0 -function sgn(x) { return (x==0?0:(x<0?-1:1)) }; -var aGroup = new Array - ( ["\(","\)",\eqParens], - ["[","]",\eqBrackets], - ["{","}",\eqBraces] - ); -\end{newsegment} -\begin{newsegment}{Eq: Support for Math Fill-in} -var _mto; -function eqAppAlert(args) { - _ModalNotOn = false; - var retn=app.alert(args); - _mto= app.setTimeOut("_ModalNotOn = true", 100); - return retn; -} -function CkBalP(UserInput,lDelimiter,rDelimiter) -{ - var Lcount=0, Rcount=0; - for (var k=0; k < UserInput.length; k++) - { - if (UserInput.charAt(k) == lDelimiter) Lcount++; - else if (UserInput.charAt(k) == rDelimiter) Rcount++; - } - return (Lcount==Rcount); -} -function CkBalVert(UserInput) -{ - var Lcount=0; - for (var k=0; k < UserInput.length; k++) - if (UserInput.charAt(k)=="|") Lcount++; - return (Lcount \% 2 == 0); -} -function Ckfuncs(UserInput) -{ - var re, rei, reii; - re = /[a-zA-Z]{2,}/g; - reii=/r:|i:|,/g - var _v=_mathVars.replace(reii,""); -rei=new RegExp("[^"+_v+"]", "g"); - aF = UserInput.match(re); - if ( aF == null ) return true; - for (var i=0; i < aF.length; i++) - { -if ( rei.exec(aF[i]) == null ) continue; - for(var j=0; j < JSf.length; j++) - if ( aF[i].indexOf(JSf[j]) != -1 ) break; - if (j < JSf.length) continue; - for(var j=0; j < JSc.length; j++) - if ( aF[i].indexOf(JSc[j]) != -1 ) break; - if(j==JSc.length) - { - eqAppAlert(\eqerrBadMathFunc,3); - ok2Continue=false; - return false; - } - } - return true; -} -function DisplayAnswer(fieldname,theanswer) -{ - ProcessIt = false; - var oDefault; - if (arguments.length > 2 ) - var oQName = arguments[2]; - else var oQName = oDefault; - if (typeof oQName=="undefined") - var oQName = new Object; - var defaultColor=(typeof oQName.DefaultColorJSLoc=="undefined")% -?\defaultColorJS:oQName.DefaultColorJSLoc; - try { - this.getField(fieldname).value=(theanswer); - } catch(e) {} - ProcessIt = true; -} -function EvalCorrAnsButton(fieldname,theanswer) -{ - theanswer = eval(theanswer); - DisplayAnswer(fieldname,theanswer); -} -function FindBalP(UserInput,Poff,Forward) -{ - var j,depth; - if (Forward) - { - for (depth=-1, j=Poff+1; depth !=0; j++) - { - if ( j > UserInput.length) return null; - if (UserInput.charAt(j)=="\(") depth--; - else if (UserInput.charAt(j)=="\)") depth++; - } - j-- - } - else - { - for (depth=-1, j=Poff-1; depth !=0; j--) - { - if ( j < 1 ) return null; - if (UserInput.charAt(j)=="\)") depth--; - else if (UserInput.charAt(j)=="\(") depth++; - } - j++ - } - return j; -} -function stripWhiteSpace (UserInput) -{ - UserInput = UserInput.replace(/\s/g,""); - if(UserInput==null || UserInput.length==0) - { - ok2Continue = false; - return false; - } else return UserInput; -} -function stripOutMuli (UserInput) -{ - UserInput = UserInput.replace(/\*/g,""); - return UserInput; -} -function addMathObject(UserInput) -{ - for ( var i=0; i < JSfBuiltIn.length; i++) { - var re = new RegExp("\\b("+JSfBuiltIn[i]+")\\b","g"); - UserInput = UserInput.replace(re,"Math.$1"); - } - re = /\b(PI)\b/g; - UserInput = UserInput.replace(re,"Math.$1"); - return 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++) - { - if(!CkBalP(UserInput, aGroup[i][0], aGroup[i][1])) - { - eqAppAlert(\eqerrDelimNotBal,3); - ok2Continue = false; - return false; - } - } - UserInput = ChngAllGrpsToParens(UserInput); - if ( replaceExclaim &&(typeof fact == "function") ) - UserInput = UserInput.replace(% -/(?=\()?(\d+)(?=\))?!/g,"fact($1)"); - if (!CkBalVert(UserInput)) - { - eqAppAlert(\eqerrABS,3); - ok2Continue = false; - return false; - } - UserInput=groupJSf(UserInput); - re=/(\w)(e)(\^)/g; - repi=/(\w)(pi)/g; - UserInput=UserInput.replace(re, "$1*$2$3"); - UserInput=UserInput.replace(repi, "$1*$2"); - UserInput=UserInput.replace(/(sec)/g, "s@e@c"); - re=/(\w)(e)([^\^])?/g; - UserInput=UserInput.replace(re,"$1($2\^1)$3"); - UserInput=UserInput.replace(/(s@e@c)/g, "sec"); - re=/E(\d)/g; - UserInput=UserInput.replace(re,"E+$1"); - re=/(\d)\*E/g; - UserInput=UserInput.replace(re,"$1E"); - if(!Ckfuncs(UserInput)) return false; - if (typeof(Ck4Exponents) != "undefined") - UserInput = Ck4Exponents(UserInput); - if (typeof(Ck4Products) != "undefined" ) - UserInput = Ck4Products(UserInput); - ok2Continue = true; - re = /\b(log)\b/g; - UserInput = UserInput.replace(re, "logc"); - while (/\|/.test(UserInput)&&(ok2Continue)) - { - re = /(\|)([^\|]*)(\|)([-\+\/\*\^\)\|])/; - if (re.test(UserInput)) - if (re.exec(UserInput)[4] == '^') - UserInput = UserInput.replace(re, "(abs($2))$4"); - else - UserInput = UserInput.replace(re, "abs($2)$4"); - else - { - re = /(\|)([^\|]*)(\|$)/; - if (re.test(UserInput)) - UserInput = UserInput.replace(re, "abs($2)"); - } - } - re=/\b(pi)\b/g; - UserInput=UserInput.replace(re,"($1)") - var reTstExp = /(\))?\^(\()?/g; - while ( ((aResults=reTstExp.exec(UserInput))!=null)&&(ok2Continue) ) - { - var firstGroup = Number(Boolean(aResults[1])); // 0 or 1 - var secondGroup = 2*Number(Boolean(aResults[2])); // 0 or 2 - var caseStudy = firstGroup+secondGroup; // 0,1,2,3 - switch(caseStudy) { - case 0: - re=/([a-zA-Z]|\d*\.?\d*)\^([a-zA-Z]|[\+-]?\d+\.?\d*|% -[\+-]?\d*\.?\d+)/; - if (re.test(UserInput)) - UserInput=Ck4OddRoots(UserInput,re); - else ok2Continue=false; - break; - case 1: - aP =/\)\^/.exec(UserInput); - LeftP=FindBalP(UserInput,aP.index,0); - re = new RegExp("\\((.{"+eval(aP.index-LeftP-1) - +"})\\)\\^([a-zA-Z]|[\+-]?\\d+\\.?\\d*|% -[\+-]?\\d*\\.?\\d+)"); - if (re.test(UserInput)) - UserInput=Ck4OddRoots(UserInput,re); - else ok2Continue=false; - break; - case 2: - aP = /\^\(/.exec(UserInput); - RightP=FindBalP(UserInput,aP.index+1,1); - re = new RegExp("([a-zA-Z]|\\d*\\.?\\d*)\\^\\((.{" - +eval(RightP-aP.index-2)+"})\\)"); - if (re.test(UserInput)) - UserInput=Ck4OddRoots(UserInput,re); - else ok2Continue=false; - break; - case 3: - aP = /\)\^\(/.exec(UserInput); - LeftP=FindBalP(UserInput,aP.index,0); - RightP=FindBalP(UserInput,aP.index+2,1); - re = new RegExp("\\((.{"+eval(aP.index-LeftP-1) - +"})\\)\\^\\((.{"+eval(RightP-aP.index-3)+"})\\)"); - if (re.test(UserInput)) - UserInput=Ck4OddRoots(UserInput,re); - else ok2Continue=false; - break; - default: - ok2Continue=false; - } - } - if (!ok2Continue) - { - eqAppAlert(\eqerrBadExp,3); - return false; - } - else { - UserInput=addMathObject(UserInput); - return UserInput; - } -} -function ChngAllGrpsToParens(UserInput) -{ - UserInput = UserInput.replace(/\[|\{/g, "\("); - UserInput = UserInput.replace(/\]|\}/g, "\)"); - return UserInput; -} -function Ck4OddRoots(UserInput,re) { - var a=re.exec(UserInput); - while ( a[2].charAt(0)=="\(") { - var RightP=FindBalP(a[2],0,1); // forward search - if (RightP == a[2].length-1) - a[2]=a[2].substring(1,a[2].length-1); - else break; - } - var b=a[2].split("/"); - if ( b.length==2 ) { - try { _m=eval(b[1]) - if ( _m == undefined || isNaN(_m) ) throw new Error(); - var d = b[1]; - var isEnclosed=(d.charAt(0) == "\(" && d.charAt(d.length-1)=="\)"); - if (!isEnclosed) - if (/.+[\+\-].+/.test(d)) throw new Error(); - if (isEnclosed) d = s.substring(1,d.length-1); - var n = b[0]; - isEnclosed=(n.charAt(0) == "\(" && n.charAt(d.length-1)=="\)"); - if (!isEnclosed) - if (/.+[\+\-].+/.test(n)) throw new Error(); - if ( d == parseInt(d) && ( Boolean(d \% 2) ) ) { - UserInput=UserInput.replace(re, - "(pow(sgn($1),"+n+")*(pow(abs($1),$2)))"); - return UserInput; - } - } catch(e) {} - } - UserInput=UserInput.replace(re,"(pow($1,$2))"); - return UserInput; -} -function groupJSf(UserInput) -{ - var re, regexp, aP, RightP; - for (var i=0; (i7); // dps17 - var UserAns=(arguments.length>7)?arguments[7]:event.value; - var success = _ProcResp(flag,CorrAns,UserAns,% -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,% -indepVars,oComp){ - ok2Continue = true; - CorrAns = ParseInput(CorrAns); - if (!ok2Continue) { - eqAppAlert("Syntax error in author's answer! Check console.",3); - return null; - } - var comp = ( typeof oComp == "object" ) ? - ((typeof oComp.comp == "undefined" ) ? - diffCompare : oComp.comp ) : oComp; - if ( (typeof(oComp)=="object") % -&& (typeof(oComp.priorParse)!="undefined") ) { - var retn=processSpecialParse(oComp.priorParse,UserAns); - if (retn==null) return -1; - } - var reCP=/((C|P)\(.+?)(,)(.+?\))/g - UserAns=UserAns.replace(reCP,"$1@c@$4"); - var reComma=/,/; - if ( reComma.test(UserAns) ) { - eqAppAlert(\eqSyntaxErrorComma,3); - return -1; - } - var reRlCommaSubst=/@c@/g; - UserAns=UserAns.replace(reRlCommaSubst,","); - UserAns = ParseInput(UserAns); - indepVars = TypeParameters(indepVars); - if (!ok2Continue) return null; - var success=randomPointCompare(n,domain,indepVars,% -epsilon,CorrAns,UserAns,comp); - if ( success && (typeof(oComp)=="object") % -&& (typeof(oComp.postParse)!="undefined") ) - success=processSpecialParse(oComp.postParse,UserAns); - return success; -} -function processSpecialParse(oParse,UserAns) { - var retn, f, _o - if ( typeof(oParse) == "object" ) { - for ( var i=0; i < oParse.length; i++) { - _o=oParse[i]; - if (typeof(_o)=="function") { - retn=_o(UserAns); - if (retn==null) return retn; - } else { - retn=_o[0].apply(null, [ UserAns ].concat(_o.slice(1))); - if (retn==null) return null; - } - } - } else { - retn = oParse(UserAns); - } - return retn; -} -function randomPointCompare (n,domain,indepVars,epsilon,% -CorrAns,userAns,comp) -{ - var error, i, j, k; - var aXY = new Array(); - domain = domain.replace(/[\[\]\s]/g, ""); - var aIntervals = domain.split("&"); - for (k=0; k < aIntervals.length; k++) - { - var aInterval = aIntervals[k].split("x"); - nI = aInterval.length; - with (Math) { - for (j=0; j < n; j++) - { - for (i=0; i < nI; i++) - { - var endpoints = aInterval[i].split(","); - aXY[i] = eval(endpoints[0])-0+(eval(endpoints[1])% --eval(endpoints[0]))*Math.random(); - } - var cXY = aXY.toString(); - error = comp(domain,cXY,indepVars,CorrAns,userAns); - if (error == null) return null; - if ( (error == -1) || (error > epsilon) ) {j=-1; break;} - } - } - if (j!=n) return false; - } - return true; -} -function diffCompare(_a,_c,_v,_F,_G) { - var aXY = _c.split(","); - var _V = _v.split(","); // e.g. _V[0] = "i:x" - var _n = aXY.length; - for (var _i=0; _i < _n; _i++) - { - if (_V[_i].charAt(0) == "r" ) - eval ("var "+_V[_i].charAt(2)+"="+aXY[_i]+";"); - else // assume type "i" - eval ("var "+_V[_i].charAt(2)+"="+Math.ceil(aXY[_i])+";"); - } - _F = eval(_F); - if ( app.viewerVersion >= 5) - { - var rtnCode = 0; - eval("try {if(isNaN(_G = eval(_G))) rtnCode=-1; }" - +"catch (e) { rtnCode=1; }"); - switch(rtnCode) - { - case 0: break; - case 1: return null; - case -1: return -1; - } - } - else - if(isNaN(_G = eval(_G))) return -1; - return Math.abs ( _F - _G ); -} -function reldiffCompare(_a,_c,_v,_F,_G) { - var aXY = _c.split(","); - var _V = _v.split(","); // e.g. _V[0] = "i:x" - var _n = aXY.length - for (var _i=0; _i < _n; _i++) - { - if (_V[_i].charAt(0) == "r" ) - eval ("var "+_V[_i].charAt(2)+"="+aXY[_i]+";"); - else // assume type "i" - eval ("var "+_V[_i].charAt(2)+"="+Math.ceil(aXY[_i])+";"); - } - _F = eval(_F); - if ( app.viewerVersion >= 5) - { - var rtnCode = 0; - eval("try { if(isNaN(_G = eval(_G))) rtnCode=-1; }" - +"catch (e) { rtnCode=1; }"); - switch(rtnCode) - { - case 0: break; - case 1: return null; - case -1: return -1; - } - } - else - if(isNaN(_G = eval(_G))) return -1; - return Math.abs ( (_F - _G)/_G ); -} -function requireForm(UserAns, regexpr) { - var msg=\defaultReqFormMsg; - UserAns = stripWhiteSpace (UserAns); - if (!ok2Continue) return null; - UserAns = ChngAllGrpsToParens(UserAns); - if (arguments.length>2) msg=arguments[2]; - if (typeof(regexpr.length)=="undefined") { - if (regexpr.test(UserAns)) return true; - else { eqAppAlert(msg,3); return null; } - } else { - for (var i=0; i2) msg=arguments[2]; - if (typeof(regexpr.length)=="undefined") { - if (regexpr.test(UserAns)) { eqAppAlert(msg,3); return null; } - else return true; - } else { - for (var i=0; i"); - for (var i=0; i0); - return notifyField(success,flag,fieldname); -} -function compareTxt(userAnswer,authorAnswer,filterMethod,compareMethod) -{ - var caseSensitive = ( compareMethod==3 ) ? "" : "i"; - var reSwitches = "g"+caseSensitive; - userAnswer = new String(userAnswer).filter(filterMethod); - switch(compareMethod) { - case 1: - var AuthorAnswer; - var aAuthorAnswer = authorAnswer.split(/\s+/); - for (var j=0; j < aAuthorAnswer.length; j++) { - AuthorAnswer = new String(% -aAuthorAnswer[j]).filter(filterMethod); - AuthorAnswer = AuthorAnswer.replace(/\./g,"\\."); - AuthorAnswer = AuthorAnswer.replace(/@any@/g,"."); - var re = new RegExp(AuthorAnswer, reSwitches); - if (!re.test(userAnswer)) return false; - } - return true; - default: - authorAnswer=new String(authorAnswer).filter(filterMethod); - return (userAnswer == authorAnswer) ? true : false; - } -} -String.prototype.filter = eqFilter; -function eqFilter(filterMethod) { - switch (filterMethod) { - case 0: - var re = /\W/g; - return this.replace(re,"").toLowerCase(); - case 1: - var re = /\s/g; - return this.replace(re,"").toLowerCase(); - case 2: - var re = /\s/g; - return this.replace(re,""); - case 3: - default: - return this.toString(); - } -} -\end{newsegment} -\begin{newsegment}{Eq: Quiz Management} -function InitMsg(msg) { return (\eqInitQuizMsg) } -function syntaxError() { eqAppAlert(\eqSyntaxErrorUndefVar,3); } -var lstOfQuizzes=new Object(); -var reExtractBaseName=/^.+?\.(.+?)\..+$/; -function ProcUserResp(key,userresp,probno,notify) -{ - if (key==null) { - ProcUserNoResp.apply(null,arguments); - return; - } - if ( arguments.length > 4 ) { - if ( typeof RightWrong[probno] == "undefined" ) { - RightWrong[probno] = new Array(); - RightWrong[probno][0] = "grp"; - Responses[probno] = new Array(); - } - RightWrong[probno][arguments[4]] = (!!key) ? 1 : 0; - Responses[probno][arguments[4]] = userresp; - } else { - if ( typeof key == "object" ) { - RightWrong[probno][0] = key[0]; - RightWrong[probno][1] = key[1]; -Responses[probno] = userresp; -if (Responses[probno].length==0) - Responses[probno]=undefined; - } else { - RightWrong[probno] = (!!key)?1:0; -Responses[probno] = userresp; -} - } - if ( (typeof fieldPopTbl == "function")&&(event.type != "Link") ) { - var a=reExtractBaseName.exec(event.target.name); - fieldPopTbl(a[1]); - } -} -function ProcUserNoResp(key,userresp,probno,notify) -{ - if ( arguments.length > 4 ) { - RightWrong[probno][arguments[4]] = undefined; - Responses[probno][arguments[4]] = undefined; -var bVoidArray=true; -for (var i=0; i 2) { - if ( typeof ProbValue[probno] == "undefined" ) { - ProbValue[probno]=[1,arguments[5],arguments[3],arguments[4]]; - ProbValue[probno][3+arguments[2]] = ptvalue; - } else ProbValue[probno][3+arguments[2]] = ptvalue; - } - else { - ProbValue[probno]=ptvalue; - } -} -function RecordProblemType(qType,probno) -{ - ProbType[probno]=qType; -} -function GrpRight( a, nProb, qtfield ) -{ - var f = this.getField("grpobj."+qtfield+"."+nProb); - var l = f.getArray().length - var prod = 1; - for ( var i=1; i <= l; i++) prod *= !!a[i]; - return prod; -} -function DisplayQuizResults(qtfield,nPointTotal,nQuestions) -{ - Score = 0; ptScore = 0; - NPointTotal=nPointTotal; NQuestions=nQuestions; - for (var i=1; i < RightWrong.length; i++) - { - if ( (typeof RightWrong[i] == "object" ) % - && ( RightWrong[i][0] == "grp" ) ) { - // grouped question - Score += GrpRight(RightWrong[i], i, qtfield); - var aWeights = ProbValue[i].slice(2); - var evalGrpJS = eval(ProbValue[i][1]); - var evalGrpJSValue = evalGrpJS(this,qtfield,i, - RightWrong[i],aWeights); - ProbDist[i] = evalGrpJSValue; - ptScore = ptScore + evalGrpJSValue; - } else { - if (typeof RightWrong[i] == "object") { - if ( RightWrong[i][0] == 1 ) { - Score++; - ProbDist[i]=(typeof ProbValue[i] == "object") ? - 1*ProbValue[i][1] : 1*ProbValue[i]; - ptScore += (1*ProbDist[i]); - } else { - if (RightWrong[i][1] == 1) - ProbDist[i]=(typeof ProbValue[i]=="object") ? - 1*ProbValue[i][1] : 1*ProbValue[i]; - else - ProbDist[i]=(typeof ProbValue[i] == "object") ? - 1*ProbValue[i][1] : 0; - ptScore += (1*ProbDist[i]); - } - } else { - if (RightWrong[i]==1) { - Score++; - ProbDist[i] = ( typeof ProbValue[i] == "object") ? - 1*ProbValue[i][1] : 1*ProbValue[i]; - ptScore += (1*ProbDist[i]); - } - else { - ProbDist[i] = ( typeof ProbValue[i] == "object") ? - 1*ProbValue[i][2] : 0; - ptScore += (1*ProbDist[i]); - } - } - } - } - if ( !negPointsAllowed && (ptScore < 0) ) ptScore = 0; - if (ptScore == nPointTotal) pcScore = 100; - else pcScore = util.printf("\%.1f", (100 * ptScore) / nPointTotal); - var oQName=eval(qtfield); - var gradeScale=% -(typeof oQName.GradeScaleLoc=="undefined")% -?GradeScaleDefault:oQName.GradeScaleLoc; - quizGrade = GetGrade.apply(null,gradeScale); - var f = this.getField("ScoreField."+qtfield); - if ( f != null ) f.value=(\eqQuizTotalMsg); - f = this.getField("PointsField."+qtfield); - if ( f != null) f.value=(\eqQuizPointsMsg); - f = this.getField("PercentField."+qtfield); - if ( f != null) f.value=(\eqQuizPercentMsg); - f = this.getField("GradeField."+qtfield); - if ( f != null) f.value=(\eqQuizGradeMsg); -} -function GetGrade() -{ - var cGrade, aRange; - var l = arguments.length/2; - if (pcScore >=100) return arguments[0]; - if (pcScore < 0 ) return arguments[arguments.length-2]; - for (var i=0; i < l; i++) - { - cGrade = arguments[2*i]; - aRange = arguments[2*i+1]; - if ( (pcScore >= arguments[2*i+1][0]) - && (pcScore < arguments[2*i+1][1])) return cGrade; - } - return null; -} -function ProcessQuestion (key,letterresp,probno, - quizno,qtfield,notify,mark,msg) { - var silent = ( arguments.length > 8 ) ? true : false; - if (!isQuizInitialized(qtfield)) - { - if (!silent) eqAppAlert(InitMsg(msg),3); - this.resetForm(["mc."+qtfield+"."+probno, - "mck."+qtfield+"."+probno]); - } - else - { - ProcUserResp(key,letterresp,probno,notify); - if (mark==1) - { - var oQName=eval(qtfield); - var defaultColor=% -(typeof oQName.DefaultColorJSLoc=="undefined")% -?\defaultColorJS:oQName.DefaultColorJSLoc; - var rightColor=% -(typeof oQName.RightColorJSLoc== "undefined")% -?\rghtColorJS:oQName.RightColorJSLoc; - var wrongColor=% -(typeof oQName.WrongColorJSLoc=="undefined")% -?\wrngColorJS:oQName.WrongColorJSLoc; - var rightAnsSymb=% -(typeof oQName.RightAnsSymbJSLoc=="undefined")% -?\rghtAnsSymbJS:oQName.RightAnsSymbJSLoc; - var wrongAnsSymb=% -(typeof oQName.WrongAnsSymbJSLoc=="undefined")% -?\wrngAnsSymbJS:oQName.WrongAnsSymbJSLoc; - var corrAnsSymb=% -(typeof oQName.CorrAnsSymbJSLoc=="undefined")% -?\corrAnsSymbJS:oQName.CorrAnsSymbJSLoc; - var f = this.getField("mcq."+qtfield+"."+probno); - var fck = this.getField("mck."+qtfield+"."+probno); - var bMultiSelect = ( fck != null ) ? true : false; - f.delay=true; - this.resetForm([f.name]); - var a = f.getArray(); - var l = a.length; - if ( bMultiSelect ) { - var ack = fck.getArray(); - for ( var i=0; i 0 ) ? 1 : 0; - var retn = [ [ scoreThisProblem, passKey ], letterResponses ] ; - return retn; -} -function LimitSelection(n,fname,k) { - var f = this.getField(fname); - var g = f.getArray(); - var total=0; - for (var i=0; i n) { - eqAppAlert(\limSelWarningMsg,3); - f=this.getField(fname+"."+k); - f.checkThisBox(0,false); - return false - } else return true; -} -\end{newsegment} -\begin{newsegment}{Eq: Miscellaneous JS} -function chooseJSColor( b, c1, c2 ) { - return ( b ) ? c1 : c2; -} -function notifyField(success, flag, fieldname) { - if ( flag != 0 ) - return (success)?true:false; - var f = this.getField(fieldname); - var re=/^(obj|grpobj)\./; - var gname=fieldname.replace(re,"rbmarkup\."); - var g =this.getField(gname); - var isthereRBUP = ( g !=null ); - var h = fieldname.replace(re,""); - var index=h.indexOf("."); - var oQName = eval(h.substring(0,index)); - var rightColor=(typeof oQName.RightColorJSLoc=="undefined")% -?\rghtColorJS:oQName.RightColorJSLoc; - var rightSymb=(typeof oQName.RightColorJSLoc=="undefined")% -?\rghtAnsSymbJS:oQName.RightAnsSymbJSLoc; - var wrongColor=(typeof oQName.WrongColorJSLoc=="undefined")% -?\wrngColorJS:oQName.WrongColorJSLoc; - var wrongSymb=(typeof oQName.WrongAnsSymbJSLoc=="undefined")% -?\wrngAnsSymbJS:oQName.WrongAnsSymbJSLoc; - if (success) { - f.strokeColor = rightColor; - if (isthereRBUP) { - g.style = rightSymb; - g.textColor=rightColor; - g.display=display.visible; - } - return true; - } else { - updateTally.downState=false; - updateTally(fieldname); - f.strokeColor = wrongColor; -if (isthereRBUP) { - b2 = ( typeof oQName.WrongAnsSymbJSLoc == "undefined" ); - g.style = wrongSymb; - g.textColor=wrongColor; - g.display=display.visible; - } - return false; - } -// return null; // remove ? -} -function updateTally(fieldname) -{ - var objre = /^obj\./; - var grpre = /^grpobj\./; - if ( grpre.test(fieldname) ) { - fieldname = fieldname.replace(grpre,""); - var pos = fieldname.lastIndexOf("."); - fieldname = fieldname.substring(0,pos); - } else if ( objre.test(fieldname) ) - fieldname = fieldname.replace(objre,""); - var f = this.getField("tally."+fieldname); - if ( f != null ) { - if (!updateTally.downState) f.value += 1; - return true; - } else return false; - -} -var bNoPeekWait=false; -var oNoPeekTimer; -function noPeek(qtfield,rtnPage) -{ - if (!bNoPeekWait) { - if ( (typeof (aQuizControl[qtfield]) == "undefined") % -|| (aQuizControl[qtfield] != -1) ) { - bNoPeekWait=true; - oNoPeekTimer=app.setTimeOut("bNoPeekWait=false;% -app.clearTimeOut(oNoPeekTimer);",5); - this.pageNum = rtnPage-1; - \NoPeekAlert; - } - } else this.pageNum = rtnPage-1; -} -var oCB=\bcheckboxused -function OnBlurRespBox (retn) -{ - var qname = arguments[1]; - var oQName = eval(qname); - var respMsg; - var cTitle = "AcroTeX eDucation Bundle"; - if (retn != null) { - if ( typeof appAlerts[qname] == "undefined") - appAlerts[qname] = {bAfterValue: false, % -cMsg: "\doNotShowAgainMsg"}; - var respMsg = (retn) ? \eqsqrtmsg\space : \eqsqwgmsg; - if ( (event.target == this) || !oCB) - eqAppAlert({ cMsg: respMsg, nIcon: 3, cTitle: cTitle }); - else { - if ( ! appAlerts[arguments[1]].bAfterValue ) - eqAppAlert({ cMsg: respMsg, nIcon: 3, cTitle: cTitle, % -oCheckbox: appAlerts[qname]}); - } - } - else { - var re=/^(obj|grpobj)\./; - var gname=event.target.name.replace(re,"rbmarkup\."); - var g =this.getField(gname); - var isthereRBUP = ( g !=null ); - var str = event.target.value.toString(); - if (str.replace(/\s/g,"") == "") { - var defaultColor=% -(typeof oQName.DefaultColorJSLoc=="undefined")% -?color.black:oQName.DefaultColorJSLoc; - if (isthereRBUP) g.display=display.hidden; - event.target.strokeColor = defaultColor; - } - } -} -function jmpToNamedDest(fName,cDest,bAlert) { - if ( (typeof appAlerts[fName]!="undefined" % -&& appAlerts[fName].bAfterValue) || bAlert==0) - app.setTimeOut("this.gotoNamedDest(\""+cDest+"\")",500); - else - this.gotoNamedDest(cDest); -} -function lowThreshold(nQuestions) -{ - return true; -} -function highThreshold(nQuestions) -{ - var cnt=0; - for ( var i=0; i< Responses.length; i++ ) { - if ( typeof Responses[i]!="undefined") cnt++ - } - if ( cnt= nQuestions); -} -\end{newsegment} -\begin{newsegment}{Eq: Support for Grouped Questions} -function groupEval(doc,qtfield,probno,aKey,aWeights) -{ - var totalGrpPts = aWeights[0]; - var totalWeight = aWeights[1]; - for ( var i=1,total=0; i< aKey.length; i++ ) - if (aKey[i] != undefined) total += aKey[i]*aWeights[i+1]; - return total; -} -function WeightedEval(doc,qtfield,probno,aKey,aWeights) -{ - var f = doc.getField("grpobj." + qtfield + "." + probno); - var nGrpQno = f.getArray().length; - var totalGrpPts = aWeights[0]; - var totalWeight = aWeights[1]; - for ( var i=1,total=0; i < aKey.length; i++ ) - if (aKey[i] != undefined) total += aKey[i]*aWeights[i+1]; - total /= totalWeight; - total = Math.floor( total * totalGrpPts ); - return total; -} -function groupBernoulliEval(doc,qtfield,probno,aKey,aWeights) -{ - var f = doc.getField("grpobj." + qtfield + "." + probno); - var nGrpQno = f.getArray().length; - var totalGrpPts = aWeights[0]; - for ( var i=1,isCorrect=1; i<= nGrpQno; i++ ) - isCorrect *= (aKey[i] != undefined) ? (Number(aKey[i])) : 0; - return (isCorrect*totalGrpPts); -} -\end{newsegment} -\end{insDLJS*} -\endinput -%% -%% End of file `aebjs.def'. +%% +%% This is file `aebjs.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% exerquiz.dtx (with options: `copyright,aebjs') +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Exerquiz.sty package, %% +%% Copyright (C) 1999-2018 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ProvidesFile{aebjs.def} + [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{\\^} +\def\redigit{\\d}\def\reany{.}\def\rebstr{\string^}\def\reestr{\string$} +\def\preReqForm{\Array(requireForm,\@gobble} +\def\preDenyForm{\Array(denyForm,\@gobble} +\def\postDenyForm{\Array(requireFormNot,\@gobble} +\newcommand{\noPeekArgs}[1]{% + \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} +/* + Document Level JavaScript + AcroTeX eDucation Bundle + D. P. Story copyright 2000-\the\year +*/ +var exerquizLoaded = true; +this.disclosed = true; +app.runtimeHighlight=false; +\end{newsegment} +\begin{newsegment}{Eq: Global Data} +var ok2Continue = true; +var ProcessIt = true; +var retn; +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 Object; +var RightWrong=new Array(); +var ProbValue = new Array(); +var ProbDist = new Array(); +var ProbType = new Array(); +var Responses=new Array(); +var appAlerts = new Object; +var _mathVars="x"; +var _ModalNotOn=true; +var GradeScaleDefault=new Array(\eqGradeScale); +var aDlLibSpecResp=new Array(\dlLibSpecRespJS); +var JSfBuiltIn = new Array + ( "abs","acos","asin","atan","ceil", "floor","cos","exp", + "log","max","min","pow","random","round","sin", + "sqrt","tan"); +var JSfCustomEarly = new Array ("arctan", "arcsin", "arccos") +var JSfCustomLate = new Array + ( "logc", "ln","sec","csc","cot", + "asinh", "acosh","atanh","acoth","asech","acsch", + "sinh", "cosh","tanh","coth","sech","csch","sgn", + "C","P","fact","pi"); +var JSf = new Array().concat(JSfCustomEarly, JSfBuiltIn, JSfCustomLate); +var JSfCustom = new Array().concat(JSfCustomEarly, JSfCustomLate); +var JSc = new Array("PI","E") +function ln(x) { return Math.log(x); } +function sec(x) { return 1/Math.cos(x); } +function csc(x) { return 1/Math.sin(x);} +function cot(x) { return Math.cos(x)/Math.sin(x); } +function arctan(x) { return Math.atan(x); } +function arcsin(x) { return Math.asin(x); } +function arccos(x) { return Math.acos(x); } +function logc(x) { return Math.LOG10E * Math.log(x); } +function C(x,y) {return ch(x,y);} +function P(x,y) {return perm(x,y);} +function sinh(x) { return ( Math.exp(x) - Math.exp(-x) )/2; } +function cosh(x) { return ( Math.exp(x) + Math.exp(-x) )/2; } +function tanh(x) { + return (Math.exp(x)-Math.exp(-x))/(Math.exp(x)+Math.exp(-x)); } +function coth(x) { + return ( Math.exp(x)+Math.exp(-x))/(Math.exp(x)-Math.exp(-x)); } +function sech(x) { return 2/( Math.exp(x) + Math.exp(-x) )/2; } +function csch(x) { return 2/( Math.exp(x) - Math.exp(-x) )/2; } +function asinh(x) { return Math.log (x+Math.sqrt(Math.pow(x,2)+1)); } +function acosh(x) { + return Math.log (x+Math.sqrt(Math.pow(x,2)-1)); } // x ge 1 +function atanh(x) { return .5*Math.log ((1+x)/(1-x)); } // -1 < x < 1 +function acoth(x) { return atanh(1/x); } // |x| > 1 +function asech(x) { return acosh(1/x); } // 0 < x le 1 +function asch(x) { return asinh(1/x); } // x ne 0 +function acsch(x) { return asinh(1/x); } // x ne 0 +function sgn(x) { return (x==0?0:(x<0?-1:1)) }; +var aGroup = new Array + ( ["\(","\)",\eqParens], + ["[","]",\eqBrackets], + ["{","}",\eqBraces] + ); +\end{newsegment} +\begin{newsegment}{Eq: Support for Math Fill-in} +var _mto; +function eqAppAlert(args) { + _ModalNotOn = false; + var retn=app.alert(args); + _mto= app.setTimeOut("_ModalNotOn = true", 100); + return retn; +} +function CkBalP(UserInput,lDelimiter,rDelimiter) +{ + var Lcount=0, Rcount=0; + for (var k=0; k < UserInput.length; k++) + { + if (UserInput.charAt(k) == lDelimiter) Lcount++; + else if (UserInput.charAt(k) == rDelimiter) Rcount++; + } + return (Lcount==Rcount); +} +function CkBalVert(UserInput) +{ + var Lcount=0; + for (var k=0; k < UserInput.length; k++) + if (UserInput.charAt(k)=="|") Lcount++; + return (Lcount \% 2 == 0); +} +function Ckfuncs(UserInput) +{ + var re, rei, reii; + re = /[a-zA-Z]{2,}/g; + reii=/r:|i:|,/g + var _v=_mathVars.replace(reii,""); +rei=new RegExp("[^"+_v+"]", "g"); + aF = UserInput.match(re); + if ( aF == null ) return true; + for (var i=0; i < aF.length; i++) + { +if ( rei.exec(aF[i]) == null ) continue; + for(var j=0; j < JSf.length; j++) + if ( aF[i].indexOf(JSf[j]) != -1 ) break; + if (j < JSf.length) continue; + for(var j=0; j < JSc.length; j++) + if ( aF[i].indexOf(JSc[j]) != -1 ) break; + if(j==JSc.length) + { + eqAppAlert(\eqerrBadMathFunc,3); + ok2Continue=false; + return false; + } + } + return true; +} +function DisplayAnswer(fieldname,theanswer) +{ + ProcessIt = false; + var oDefault; + if (arguments.length > 2 ) + var oQName = arguments[2]; + else var oQName = oDefault; + if (typeof oQName=="undefined") + var oQName = new Object; + var defaultColor=(typeof oQName.DefaultColorJSLoc=="undefined")% +?\defaultColorJS:oQName.DefaultColorJSLoc; + try { + this.getField(fieldname).value=(theanswer); + } catch(e) {} + ProcessIt = true; +} +function EvalCorrAnsButton(fieldname,theanswer) +{ + theanswer = eval(theanswer); + DisplayAnswer(fieldname,theanswer); +} +function FindBalP(UserInput,Poff,Forward) +{ + var j,depth; + if (Forward) + { + for (depth=-1, j=Poff+1; depth !=0; j++) + { + if ( j > UserInput.length) return null; + if (UserInput.charAt(j)=="\(") depth--; + else if (UserInput.charAt(j)=="\)") depth++; + } + j-- + } + else + { + for (depth=-1, j=Poff-1; depth !=0; j--) + { + if ( j < 1 ) return null; + if (UserInput.charAt(j)=="\)") depth--; + else if (UserInput.charAt(j)=="\(") depth++; + } + j++ + } + return j; +} +function stripWhiteSpace (UserInput) +{ + UserInput = UserInput.replace(/\s/g,""); + if(UserInput==null || UserInput.length==0) + { + ok2Continue = false; + return false; + } else return UserInput; +} +function stripOutMuli (UserInput) +{ + UserInput = UserInput.replace(/\*/g,""); + return UserInput; +} +function addMathObject(UserInput) +{ + for ( var i=0; i < JSfBuiltIn.length; i++) { + var re = new RegExp("\\b("+JSfBuiltIn[i]+")\\b","g"); + UserInput = UserInput.replace(re,"Math.$1"); + } + re = /\b(PI)\b/g; + UserInput = UserInput.replace(re,"Math.$1"); + return 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++) + { + if(!CkBalP(UserInput, aGroup[i][0], aGroup[i][1])) + { + eqAppAlert(\eqerrDelimNotBal,3); + ok2Continue = false; + return false; + } + } + UserInput = ChngAllGrpsToParens(UserInput); + if ( replaceExclaim &&(typeof fact == "function") ) + UserInput = UserInput.replace(% +/(?=\()?(\d+)(?=\))?!/g,"fact($1)"); + if (!CkBalVert(UserInput)) + { + eqAppAlert(\eqerrABS,3); + ok2Continue = false; + return false; + } + UserInput=groupJSf(UserInput); + re=/(\w)(e)(\^)/g; + repi=/(\w)(pi)/g; + UserInput=UserInput.replace(re, "$1*$2$3"); + UserInput=UserInput.replace(repi, "$1*$2"); + UserInput=UserInput.replace(/(sec)/g, "s@e@c"); + re=/(\w)(e)([^\^])?/g; + UserInput=UserInput.replace(re,"$1($2\^1)$3"); + UserInput=UserInput.replace(/(s@e@c)/g, "sec"); + re=/E(\d)/g; + UserInput=UserInput.replace(re,"E+$1"); + re=/(\d)\*E/g; + UserInput=UserInput.replace(re,"$1E"); + if(!Ckfuncs(UserInput)) return false; + if (typeof(Ck4Exponents) != "undefined") + UserInput = Ck4Exponents(UserInput); + if (typeof(Ck4Products) != "undefined" ) + UserInput = Ck4Products(UserInput); + ok2Continue = true; + re = /\b(log)\b/g; + UserInput = UserInput.replace(re, "logc"); + while (/\|/.test(UserInput)&&(ok2Continue)) + { + re = /(\|)([^\|]*)(\|)([-\+\/\*\^\)\|])/; + if (re.test(UserInput)) + if (re.exec(UserInput)[4] == '^') + UserInput = UserInput.replace(re, "(abs($2))$4"); + else + UserInput = UserInput.replace(re, "abs($2)$4"); + else + { + re = /(\|)([^\|]*)(\|$)/; + if (re.test(UserInput)) + UserInput = UserInput.replace(re, "abs($2)"); + } + } + re=/\b(pi)\b/g; + UserInput=UserInput.replace(re,"($1)") + var reTstExp = /(\))?\^(\()?/g; + while ( ((aResults=reTstExp.exec(UserInput))!=null)&&(ok2Continue) ) + { + var firstGroup = Number(Boolean(aResults[1])); // 0 or 1 + var secondGroup = 2*Number(Boolean(aResults[2])); // 0 or 2 + var caseStudy = firstGroup+secondGroup; // 0,1,2,3 + switch(caseStudy) { + case 0: + re=/([a-zA-Z]|\d*\.?\d*)\^([a-zA-Z]|[\+-]?\d+\.?\d*|% +[\+-]?\d*\.?\d+)/; + if (re.test(UserInput)) + UserInput=Ck4OddRoots(UserInput,re); + else ok2Continue=false; + break; + case 1: + aP =/\)\^/.exec(UserInput); + LeftP=FindBalP(UserInput,aP.index,0); + re = new RegExp("\\((.{"+eval(aP.index-LeftP-1) + +"})\\)\\^([a-zA-Z]|[\+-]?\\d+\\.?\\d*|% +[\+-]?\\d*\\.?\\d+)"); + if (re.test(UserInput)) + UserInput=Ck4OddRoots(UserInput,re); + else ok2Continue=false; + break; + case 2: + aP = /\^\(/.exec(UserInput); + RightP=FindBalP(UserInput,aP.index+1,1); + re = new RegExp("([a-zA-Z]|\\d*\\.?\\d*)\\^\\((.{" + +eval(RightP-aP.index-2)+"})\\)"); + if (re.test(UserInput)) + UserInput=Ck4OddRoots(UserInput,re); + else ok2Continue=false; + break; + case 3: + aP = /\)\^\(/.exec(UserInput); + LeftP=FindBalP(UserInput,aP.index,0); + RightP=FindBalP(UserInput,aP.index+2,1); + re = new RegExp("\\((.{"+eval(aP.index-LeftP-1) + +"})\\)\\^\\((.{"+eval(RightP-aP.index-3)+"})\\)"); + if (re.test(UserInput)) + UserInput=Ck4OddRoots(UserInput,re); + else ok2Continue=false; + break; + default: + ok2Continue=false; + } + } + if (!ok2Continue) + { + eqAppAlert(\eqerrBadExp,3); + return false; + } + else { + UserInput=addMathObject(UserInput); + return UserInput; + } +} +function ChngAllGrpsToParens(UserInput) +{ + UserInput = UserInput.replace(/\[|\{/g, "\("); + UserInput = UserInput.replace(/\]|\}/g, "\)"); + return UserInput; +} +function Ck4OddRoots(UserInput,re) { + var a=re.exec(UserInput); + while ( a[2].charAt(0)=="\(") { + var RightP=FindBalP(a[2],0,1); // forward search + if (RightP == a[2].length-1) + a[2]=a[2].substring(1,a[2].length-1); + else break; + } + var b=a[2].split("/"); + if ( b.length==2 ) { + try { _m=eval(b[1]) + if ( _m == undefined || isNaN(_m) ) throw new Error(); + var d = b[1]; + var isEnclosed=(d.charAt(0) == "\(" && d.charAt(d.length-1)=="\)"); + if (!isEnclosed) + if (/.+[\+\-].+/.test(d)) throw new Error(); + if (isEnclosed) d = s.substring(1,d.length-1); + var n = b[0]; + isEnclosed=(n.charAt(0) == "\(" && n.charAt(d.length-1)=="\)"); + if (!isEnclosed) + if (/.+[\+\-].+/.test(n)) throw new Error(); + if ( d == parseInt(d) && ( Boolean(d \% 2) ) ) { + UserInput=UserInput.replace(re, + "(pow(sgn($1),"+n+")*(pow(abs($1),$2)))"); + return UserInput; + } + } catch(e) {} + } + UserInput=UserInput.replace(re,"(pow($1,$2))"); + return UserInput; +} +function groupJSf(UserInput) +{ + var re, regexp, aP, RightP; + for (var i=0; (i7); // dps17 + var UserAns=(arguments.length>7)?arguments[7]:event.value; + var success = _ProcResp(flag,CorrAns,UserAns,% +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,% +indepVars,oComp){ + ok2Continue = true; + CorrAns = ParseInput(CorrAns); + if (!ok2Continue) { + eqAppAlert("Syntax error in author's answer! Check console.",3); + return null; + } + var comp = ( typeof oComp == "object" ) ? + ((typeof oComp.comp == "undefined" ) ? + diffCompare : oComp.comp ) : oComp; + if ( (typeof(oComp)=="object") % +&& (typeof(oComp.priorParse)!="undefined") ) { + var retn=processSpecialParse(oComp.priorParse,UserAns); + if (retn==null) return -1; + } + var reCP=/((C|P)\(.+?)(,)(.+?\))/g + UserAns=UserAns.replace(reCP,"$1@c@$4"); + var reComma=/,/; + if ( reComma.test(UserAns) ) { + eqAppAlert(\eqSyntaxErrorComma,3); + return -1; + } + var reRlCommaSubst=/@c@/g; + UserAns=UserAns.replace(reRlCommaSubst,","); + UserAns = ParseInput(UserAns); + indepVars = TypeParameters(indepVars); + if (!ok2Continue) return null; + var success=randomPointCompare(n,domain,indepVars,% +epsilon,CorrAns,UserAns,comp); + if ( success && (typeof(oComp)=="object") % +&& (typeof(oComp.postParse)!="undefined") ) + success=processSpecialParse(oComp.postParse,UserAns); + return success; +} +function processSpecialParse(oParse,UserAns) { + var retn, f, _o + if ( typeof(oParse) == "object" ) { + for ( var i=0; i < oParse.length; i++) { + _o=oParse[i]; + if (typeof(_o)=="function") { + retn=_o(UserAns); + if (retn==null) return retn; + } else { + retn=_o[0].apply(null, [ UserAns ].concat(_o.slice(1))); + if (retn==null) return null; + } + } + } else { + retn = oParse(UserAns); + } + return retn; +} +function randomPointCompare (n,domain,indepVars,epsilon,% +CorrAns,userAns,comp) +{ + var error, i, j, k; + var aXY = new Array(); + domain = domain.replace(/[\[\]\s]/g, ""); + var aIntervals = domain.split("&"); + for (k=0; k < aIntervals.length; k++) + { + var aInterval = aIntervals[k].split("x"); + nI = aInterval.length; + with (Math) { + for (j=0; j < n; j++) + { + for (i=0; i < nI; i++) + { + var endpoints = aInterval[i].split(","); + aXY[i] = eval(endpoints[0])-0+(eval(endpoints[1])% +-eval(endpoints[0]))*Math.random(); + } + var cXY = aXY.toString(); + error = comp(domain,cXY,indepVars,CorrAns,userAns); + if (error == null) return null; + if ( (error == -1) || (error > epsilon) ) {j=-1; break;} + } + } + if (j!=n) return false; + } + return true; +} +function diffCompare(_a,_c,_v,_F,_G) { + var aXY = _c.split(","); + var _V = _v.split(","); // e.g. _V[0] = "i:x" + var _n = aXY.length; + for (var _i=0; _i < _n; _i++) + { + if (_V[_i].charAt(0) == "r" ) + eval ("var "+_V[_i].charAt(2)+"="+aXY[_i]+";"); + else // assume type "i" + eval ("var "+_V[_i].charAt(2)+"="+Math.ceil(aXY[_i])+";"); + } + _F = eval(_F); + if ( app.viewerVersion >= 5) + { + var rtnCode = 0; + eval("try {if(isNaN(_G = eval(_G))) rtnCode=-1; }" + +"catch (e) { rtnCode=1; }"); + switch(rtnCode) + { + case 0: break; + case 1: return null; + case -1: return -1; + } + } + else + if(isNaN(_G = eval(_G))) return -1; + return Math.abs ( _F - _G ); +} +function reldiffCompare(_a,_c,_v,_F,_G) { + var aXY = _c.split(","); + var _V = _v.split(","); // e.g. _V[0] = "i:x" + var _n = aXY.length + for (var _i=0; _i < _n; _i++) + { + if (_V[_i].charAt(0) == "r" ) + eval ("var "+_V[_i].charAt(2)+"="+aXY[_i]+";"); + else // assume type "i" + eval ("var "+_V[_i].charAt(2)+"="+Math.ceil(aXY[_i])+";"); + } + _F = eval(_F); + if ( app.viewerVersion >= 5) + { + var rtnCode = 0; + eval("try { if(isNaN(_G = eval(_G))) rtnCode=-1; }" + +"catch (e) { rtnCode=1; }"); + switch(rtnCode) + { + case 0: break; + case 1: return null; + case -1: return -1; + } + } + else + if(isNaN(_G = eval(_G))) return -1; + return Math.abs ( (_F - _G)/_G ); +} +function requireForm(UserAns, regexpr) { + var msg=\defaultReqFormMsg; + UserAns = stripWhiteSpace (UserAns); + if (!ok2Continue) return null; + UserAns = ChngAllGrpsToParens(UserAns); + if (arguments.length>2) msg=arguments[2]; + if (typeof(regexpr.length)=="undefined") { + if (regexpr.test(UserAns)) return true; + else { eqAppAlert(msg,3); return null; } + } else { + for (var i=0; i2) msg=arguments[2]; + if (typeof(regexpr.length)=="undefined") { + if (regexpr.test(UserAns)) { eqAppAlert(msg,3); return null; } + else return true; + } else { + for (var i=0; i"); + for (var i=0; i0); + return notifyField(success,flag,fieldname); +} +function compareTxt(userAnswer,authorAnswer,filterMethod,compareMethod) +{ + var caseSensitive = ( compareMethod==3 ) ? "" : "i"; + var reSwitches = "g"+caseSensitive; + userAnswer = new String(userAnswer).filter(filterMethod); + switch(compareMethod) { + case 1: + var AuthorAnswer; + var aAuthorAnswer = authorAnswer.split(/\s+/); + for (var j=0; j < aAuthorAnswer.length; j++) { + AuthorAnswer = new String(% +aAuthorAnswer[j]).filter(filterMethod); + AuthorAnswer = AuthorAnswer.replace(/\./g,"\\."); + AuthorAnswer = AuthorAnswer.replace(/@any@/g,"."); + var re = new RegExp(AuthorAnswer, reSwitches); + if (!re.test(userAnswer)) return false; + } + return true; + default: + authorAnswer=new String(authorAnswer).filter(filterMethod); + return (userAnswer == authorAnswer) ? true : false; + } +} +String.prototype.filter = eqFilter; +function eqFilter(filterMethod) { + switch (filterMethod) { + case 0: + var re = /\W/g; + return this.replace(re,"").toLowerCase(); + case 1: + var re = /\s/g; + return this.replace(re,"").toLowerCase(); + case 2: + var re = /\s/g; + return this.replace(re,""); + case 3: + default: + return this.toString(); + } +} +\end{newsegment} +\begin{newsegment}{Eq: Quiz Management} +function InitMsg(msg) { return (\eqInitQuizMsg) } +function syntaxError() { eqAppAlert(\eqSyntaxErrorUndefVar,3); } +var lstOfQuizzes=new Object(); +var reExtractBaseName=/^.+?\.(.+?)\..+$/; +function ProcUserResp(key,userresp,probno,notify) +{ + if (key==null) { + ProcUserNoResp.apply(null,arguments); + return; + } + if ( arguments.length > 4 ) { + if ( typeof RightWrong[probno] == "undefined" ) { + RightWrong[probno] = new Array(); + RightWrong[probno][0] = "grp"; + Responses[probno] = new Array(); + } + RightWrong[probno][arguments[4]] = (!!key) ? 1 : 0; + Responses[probno][arguments[4]] = userresp; + } else { + if ( typeof key == "object" ) { + RightWrong[probno][0] = key[0]; + RightWrong[probno][1] = key[1]; +Responses[probno] = userresp; +if (Responses[probno].length==0) + Responses[probno]=undefined; + } else { + RightWrong[probno] = (!!key)?1:0; +Responses[probno] = userresp; +} + } + if ( (typeof fieldPopTbl == "function")&&(event.type != "Link") ) { + var a=reExtractBaseName.exec(event.target.name); + fieldPopTbl(a[1]); + } +} +function ProcUserNoResp(key,userresp,probno,notify) +{ + if ( arguments.length > 4 ) { + RightWrong[probno][arguments[4]] = undefined; + Responses[probno][arguments[4]] = undefined; +var bVoidArray=true; +for (var i=0; i 2) { + if ( typeof ProbValue[probno] == "undefined" ) { + ProbValue[probno]=[1,arguments[5],arguments[3],arguments[4]]; + ProbValue[probno][3+arguments[2]] = ptvalue; + } else ProbValue[probno][3+arguments[2]] = ptvalue; + } + else { + ProbValue[probno]=ptvalue; + } +} +function RecordProblemType(qType,probno) +{ + ProbType[probno]=qType; +} +function GrpRight( a, nProb, qtfield ) +{ + var f = this.getField("grpobj."+qtfield+"."+nProb); + var l = f.getArray().length + var prod = 1; + for ( var i=1; i <= l; i++) prod *= !!a[i]; + return prod; +} +function DisplayQuizResults(qtfield,nPointTotal,nQuestions) +{ + Score = 0; ptScore = 0; + NPointTotal=nPointTotal; NQuestions=nQuestions; + for (var i=1; i < RightWrong.length; i++) + { + if ( (typeof RightWrong[i] == "object" ) % + && ( RightWrong[i][0] == "grp" ) ) { + // grouped question + Score += GrpRight(RightWrong[i], i, qtfield); + var aWeights = ProbValue[i].slice(2); + var evalGrpJS = eval(ProbValue[i][1]); + var evalGrpJSValue = evalGrpJS(this,qtfield,i, + RightWrong[i],aWeights); + ProbDist[i] = evalGrpJSValue; + ptScore = ptScore + evalGrpJSValue; + } else { + if (typeof RightWrong[i] == "object") { + if ( RightWrong[i][0] == 1 ) { + Score++; + ProbDist[i]=(typeof ProbValue[i] == "object") ? + 1*ProbValue[i][1] : 1*ProbValue[i]; + ptScore += (1*ProbDist[i]); + } else { + if (RightWrong[i][1] == 1) + ProbDist[i]=(typeof ProbValue[i]=="object") ? + 1*ProbValue[i][1] : 1*ProbValue[i]; + else + ProbDist[i]=(typeof ProbValue[i] == "object") ? + 1*ProbValue[i][1] : 0; + ptScore += (1*ProbDist[i]); + } + } else { + if (RightWrong[i]==1) { + Score++; + ProbDist[i] = ( typeof ProbValue[i] == "object") ? + 1*ProbValue[i][1] : 1*ProbValue[i]; + ptScore += (1*ProbDist[i]); + } + else { + ProbDist[i] = ( typeof ProbValue[i] == "object") ? + 1*ProbValue[i][2] : 0; + ptScore += (1*ProbDist[i]); + } + } + } + } + if ( !negPointsAllowed && (ptScore < 0) ) ptScore = 0; + if (ptScore == nPointTotal) pcScore = 100; + else pcScore = util.printf("\%.1f", (100 * ptScore) / nPointTotal); + var oQName=eval(qtfield); + var gradeScale=% +(typeof oQName.GradeScaleLoc=="undefined")% +?GradeScaleDefault:oQName.GradeScaleLoc; + quizGrade = GetGrade.apply(null,gradeScale); + var f = this.getField("ScoreField."+qtfield); + if ( f != null ) f.value=(\eqQuizTotalMsg); + f = this.getField("PointsField."+qtfield); + if ( f != null) f.value=(\eqQuizPointsMsg); + f = this.getField("PercentField."+qtfield); + if ( f != null) f.value=(\eqQuizPercentMsg); + f = this.getField("GradeField."+qtfield); + if ( f != null) f.value=(\eqQuizGradeMsg); +} +function GetGrade() +{ + var cGrade, aRange; + var l = arguments.length/2; + if (pcScore >=100) return arguments[0]; + if (pcScore < 0 ) return arguments[arguments.length-2]; + for (var i=0; i < l; i++) + { + cGrade = arguments[2*i]; + aRange = arguments[2*i+1]; + if ( (pcScore >= arguments[2*i+1][0]) + && (pcScore < arguments[2*i+1][1])) return cGrade; + } + return null; +} +function ProcessQuestion (key,letterresp,probno, + quizno,qtfield,notify,mark,msg) { + var silent = ( arguments.length > 8 ) ? true : false; + if (!isQuizInitialized(qtfield)) + { + if (!silent) eqAppAlert(InitMsg(msg),3); + this.resetForm(["mc."+qtfield+"."+probno, + "mck."+qtfield+"."+probno]); + } + else + { + ProcUserResp(key,letterresp,probno,notify); + if (mark==1) + { + var oQName=eval(qtfield); + var defaultColor=% +(typeof oQName.DefaultColorJSLoc=="undefined")% +?\defaultColorJS:oQName.DefaultColorJSLoc; + var rightColor=% +(typeof oQName.RightColorJSLoc== "undefined")% +?\rghtColorJS:oQName.RightColorJSLoc; + var wrongColor=% +(typeof oQName.WrongColorJSLoc=="undefined")% +?\wrngColorJS:oQName.WrongColorJSLoc; + var rightAnsSymb=% +(typeof oQName.RightAnsSymbJSLoc=="undefined")% +?\rghtAnsSymbJS:oQName.RightAnsSymbJSLoc; + var wrongAnsSymb=% +(typeof oQName.WrongAnsSymbJSLoc=="undefined")% +?\wrngAnsSymbJS:oQName.WrongAnsSymbJSLoc; + var corrAnsSymb=% +(typeof oQName.CorrAnsSymbJSLoc=="undefined")% +?\corrAnsSymbJS:oQName.CorrAnsSymbJSLoc; + var f = this.getField("mcq."+qtfield+"."+probno); + var fck = this.getField("mck."+qtfield+"."+probno); + var bMultiSelect = ( fck != null ) ? true : false; + f.delay=true; + this.resetForm([f.name]); + var a = f.getArray(); + var l = a.length; + if ( bMultiSelect ) { + var ack = fck.getArray(); + for ( var i=0; i 0 ) ? 1 : 0; + var retn = [ [ scoreThisProblem, passKey ], letterResponses ] ; + return retn; +} +function LimitSelection(n,fname,k) { + var f = this.getField(fname); + var g = f.getArray(); + var total=0; + for (var i=0; i n) { + eqAppAlert(\limSelWarningMsg,3); + f=this.getField(fname+"."+k); + f.checkThisBox(0,false); + return false + } else return true; +} +\end{newsegment} +\begin{newsegment}{Eq: Miscellaneous JS} +function chooseJSColor( b, c1, c2 ) { + return ( b ) ? c1 : c2; +} +function notifyField(success, flag, fieldname) { + if ( flag != 0 ) + return (success)?true:false; + var f = this.getField(fieldname); + var re=/^(obj|grpobj)\./; + var gname=fieldname.replace(re,"rbmarkup\."); + var g =this.getField(gname); + var isthereRBUP = ( g !=null ); + var h = fieldname.replace(re,""); + var index=h.indexOf("."); + var oQName = eval(h.substring(0,index)); + var rightColor=(typeof oQName.RightColorJSLoc=="undefined")% +?\rghtColorJS:oQName.RightColorJSLoc; + var rightSymb=(typeof oQName.RightColorJSLoc=="undefined")% +?\rghtAnsSymbJS:oQName.RightAnsSymbJSLoc; + var wrongColor=(typeof oQName.WrongColorJSLoc=="undefined")% +?\wrngColorJS:oQName.WrongColorJSLoc; + var wrongSymb=(typeof oQName.WrongAnsSymbJSLoc=="undefined")% +?\wrngAnsSymbJS:oQName.WrongAnsSymbJSLoc; + if (success) { + f.strokeColor = rightColor; + if (isthereRBUP) { + g.style = rightSymb; + g.textColor=rightColor; + g.display=display.visible; + } + return true; + } else { + updateTally.downState=false; + updateTally(fieldname); + f.strokeColor = wrongColor; +if (isthereRBUP) { + b2 = ( typeof oQName.WrongAnsSymbJSLoc == "undefined" ); + g.style = wrongSymb; + g.textColor=wrongColor; + g.display=display.visible; + } + return false; + } +// return null; // remove ? +} +function updateTally(fieldname) +{ + var objre = /^obj\./; + var grpre = /^grpobj\./; + if ( grpre.test(fieldname) ) { + fieldname = fieldname.replace(grpre,""); + var pos = fieldname.lastIndexOf("."); + fieldname = fieldname.substring(0,pos); + } else if ( objre.test(fieldname) ) + fieldname = fieldname.replace(objre,""); + var f = this.getField("tally."+fieldname); + if ( f != null ) { + if (!updateTally.downState) f.value += 1; + return true; + } else return false; + +} +var bNoPeekWait=false; +var oNoPeekTimer; +function noPeek(qtfield,rtnPage) +{ + if (!bNoPeekWait) { + if ( (typeof (aQuizControl[qtfield]) == "undefined") % +|| (aQuizControl[qtfield] != -1) ) { + bNoPeekWait=true; + oNoPeekTimer=app.setTimeOut("bNoPeekWait=false;% +app.clearTimeOut(oNoPeekTimer);",5); + this.pageNum = rtnPage-1; + \NoPeekAlert; + } + } else this.pageNum = rtnPage-1; +} +var oCB=\bcheckboxused +function OnBlurRespBox (retn) +{ + var qname = arguments[1]; + var oQName = eval(qname); + var respMsg; + var cTitle = "AcroTeX eDucation Bundle"; + if (retn != null) { + if ( typeof appAlerts[qname] == "undefined") + appAlerts[qname] = {bAfterValue: false, % +cMsg: "\doNotShowAgainMsg"}; + var respMsg = (retn) ? \eqsqrtmsg\space : \eqsqwgmsg; + if ( (event.target == this) || !oCB) + eqAppAlert({ cMsg: respMsg, nIcon: 3, cTitle: cTitle }); + else { + if ( ! appAlerts[arguments[1]].bAfterValue ) + eqAppAlert({ cMsg: respMsg, nIcon: 3, cTitle: cTitle, % +oCheckbox: appAlerts[qname]}); + } + } + else { + var re=/^(obj|grpobj)\./; + var gname=event.target.name.replace(re,"rbmarkup\."); + var g =this.getField(gname); + var isthereRBUP = ( g !=null ); + var str = event.target.value.toString(); + if (str.replace(/\s/g,"") == "") { + var defaultColor=% +(typeof oQName.DefaultColorJSLoc=="undefined")% +?color.black:oQName.DefaultColorJSLoc; + if (isthereRBUP) g.display=display.hidden; + event.target.strokeColor = defaultColor; + } + } +} +function jmpToNamedDest(fName,cDest,bAlert) { + if ( (typeof appAlerts[fName]!="undefined" % +&& appAlerts[fName].bAfterValue) || bAlert==0) + app.setTimeOut("this.gotoNamedDest(\""+cDest+"\")",500); + else + this.gotoNamedDest(cDest); +} +function lowThreshold(nQuestions) +{ + return true; +} +function highThreshold(nQuestions) +{ + var cnt=0; + for ( var i=0; i< Responses.length; i++ ) { + if ( typeof Responses[i]!="undefined") cnt++ + } + if ( cnt= nQuestions); +} +\end{newsegment} +\begin{newsegment}{Eq: Support for Grouped Questions} +function groupEval(doc,qtfield,probno,aKey,aWeights) +{ + var totalGrpPts = aWeights[0]; + var totalWeight = aWeights[1]; + for ( var i=1,total=0; i< aKey.length; i++ ) + if (aKey[i] != undefined) total += aKey[i]*aWeights[i+1]; + return total; +} +function WeightedEval(doc,qtfield,probno,aKey,aWeights) +{ + var f = doc.getField("grpobj." + qtfield + "." + probno); + var nGrpQno = f.getArray().length; + var totalGrpPts = aWeights[0]; + var totalWeight = aWeights[1]; + for ( var i=1,total=0; i < aKey.length; i++ ) + if (aKey[i] != undefined) total += aKey[i]*aWeights[i+1]; + total /= totalWeight; + total = Math.floor( total * totalGrpPts ); + return total; +} +function groupBernoulliEval(doc,qtfield,probno,aKey,aWeights) +{ + var f = doc.getField("grpobj." + qtfield + "." + probno); + var nGrpQno = f.getArray().length; + var totalGrpPts = aWeights[0]; + for ( var i=1,isCorrect=1; i<= nGrpQno; i++ ) + isCorrect *= (aKey[i] != undefined) ? (Number(aKey[i])) : 0; + return (isCorrect*totalGrpPts); +} +\end{newsegment} +\end{insDLJS*} +\endinput +%% +%% End of file `aebjs.def'. -- cgit v1.2.3