%
% A simple function to process a text or math answer. The text compare
% is done first, the match must be exact. In your problems, the right answer
% might be "-".  If the student does not enter "-", we pass to
%
\begin{insDLJS}[ProcRespTxtMath]{txtmath}{Process Math or Text Responses}
function ProcRespTxtMath(flag,CorrAns,n,epsilon,a,indepVar,oComp)
{
    if (!ProcessIt) return null;
    ok2Continue = true;
    var UserAns = event.value;
    if ( CorrAns=="-") return UserAns=="-";
    else return ( UserAns=="-") ? false : ProcResp(flag,CorrAns,n,epsilon,a,indepVar,oComp);
}
\end{insDLJS}



\begin{insDLJS}[dljslibRMbbbb]{dljsliRMbbbb}{RMbbbb}

function ProcRespSetFormulaEmpty(flag,CorrAns,n,epsilon,a,indepVar,oComp)
{
    ok2Continue = true;
    if (!ProcessIt) return null;
    var fieldname = event.target.name;
    var UserAns = event.value;
    this.getField(fieldname).strokeColor = \eqDefaultColor;
    UserAns = stripWhiteSpace(UserAns);
    if (!ok2Continue) return null;
    if (UserAns == "nic") {
      success = (CorrAns == UserAns);
      return notifyField(success, flag, fieldname);
    }
    if (CorrAns == "nic") {
      success = (CorrAns == UserAns);
      return notifyField(success, flag, fieldname);
    }
    var aUserAns = UserAns.split(",");
    var aCorrAns = CorrAns.split(",");
    var numCorrect = 0;
    var match = 0;
    if ( aUserAns.length != aCorrAns.length ) return notifyField(false, flag, fieldname);
    for ( var i=0; i< aCorrAns.length; i++) {
        match = 0;
        for ( var j=i; j< aUserAns.length; j++) {
            var retn = _ProcResp(flag,aCorrAns[i],aUserAns[j],n,epsilon,a,indepVar,oComp);
            if ( retn == null ) return syntaxError(), null;
            if (retn==1) {
               var temp=aUserAns[j];
               aUserAns[j]=aUserAns[i];
               aUserAns[i]=temp;
               match = match + 1;
            }
        }
        numCorrect += (match) ? 1 : 0;
    }
    var success = (numCorrect == aCorrAns.length) ? true : false;
    if ( success == null ) return syntaxError(), null;
    return notifyField(success, flag, fieldname);
}

\end{insDLJS}