[Aimmath-commit] AIM/WEB-INF/maple/aim TextQuestion.mpl,1.11,1.12
Brought to you by:
gustav_delius,
npstrick
From: <mo...@us...> - 2004-01-12 06:15:58
|
Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim In directory sc8-pr-cvs1:/tmp/cvs-serv1542/WEB-INF/maple/aim Modified Files: TextQuestion.mpl Log Message: Implements the String() wrapper for the c> prompt. Using c> String(sometype), where 'sometype' is a Maple type, caused AIM to interpret the student's answer as a string, and then check if the string is of type 'sometype' for validation. Note that if Maple can determine that 'sometype' is a subtype of type 'string', the wrapper String() is not needed and may be ommitted. This mechanism is useful for defining and validating custom input types for student answers. Index: TextQuestion.mpl =================================================================== RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/TextQuestion.mpl,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TextQuestion.mpl 9 Jan 2004 06:47:00 -0000 1.11 --- TextQuestion.mpl 12 Jan 2004 06:15:55 -0000 1.12 *************** *** 158,162 **** ", proc(this,x::`aim/Question/Attempt_`) ! local savedframe,attempt,mapletype,err,msg,ans,rightans,ok,rawmark,tlimit; # KM global Config; --- 158,163 ---- ", proc(this,x::`aim/Question/Attempt_`) ! local savedframe,attempt,mapletype,err,msg,ans,rightans,ok,rawmark,tlimit, ! cleanmapletype; # KM global Config; *************** *** 173,176 **** --- 174,182 ---- rightans := eval(this['RightAnswer']); mapletype := this['MapleType']; + # KM + cleanmapletype:=`if`(type(mapletype,specfunc(anything,'String')), + op(mapletype), + mapletype): + # END KM msg := ""; *************** *** 181,185 **** # KM # WAS: not(type(rightans,mapletype)) then ! not(type(Value(rightans),mapletype)) then # END KM msg := __("Teacher's answer has the wrong type."); --- 187,191 ---- # KM # WAS: not(type(rightans,mapletype)) then ! not(type(Value(rightans),cleanmapletype)) then # END KM msg := __("Teacher's answer has the wrong type."); *************** *** 369,378 **** else if attempt['Answer'] <> NULL then ! # KM & GG if type([attempt['Answer']],[string]) then html := cat( - __("No validation is possible with this question. \n"), __("Your last answer, exactly as you typed it, was: \n"), "<br/><pre>", --- 375,383 ---- else if attempt['Answer'] <> NULL then ! # KM if type([attempt['Answer']],[string]) then html := cat( __("Your last answer, exactly as you typed it, was: \n"), "<br/><pre>", *************** *** 469,473 **** # KM # WAS: if reqtype = string then ! if subtype(reqtype,string) then # END # don't allow the empty string to be valid or it will cause --- 474,479 ---- # KM # WAS: if reqtype = string then ! # WAS: if subtype(reqtype,string) then ! if subtype(reqtype,string) or type(reqtype,specfunc(type,'String')) then # END # don't allow the empty string to be valid or it will cause *************** *** 479,483 **** # check that the string matches the required type in the case # where the user has specified a subtype of type string ! if (not(type([rawans],[reqtype]))) then attempt['ValidationNote'] := __("wrong type"); attempt['ValidationMessage'] := --- 485,491 ---- # check that the string matches the required type in the case # where the user has specified a subtype of type string ! # removing the String() wrapper when needed ! if type(reqtype,specfunc(type,'String')) then reqtype:=op(reqtype); fi: ! if (not(type(rawans,reqtype))) then attempt['ValidationNote'] := __("wrong type"); attempt['ValidationMessage'] := |