[LON-CAPA-users] Implicit Answer Response

H. K. Ng lon-capa-users@mail.lon-capa.org
Wed, 19 Oct 2005 15:28:04 -0400

At 03:02 PM 10/19/2005, you wrote:
>If I wanted students to enter in an answer along the lines of:
>-4cos 500t A
>Where A is unit Amps
>What would be the best way to go about this?
>I was thinking just having students enter in a string, but that won't
>work even if they do all put the answer in Amps instead of mA or
>whatever.  There would be too many variations.. like "-4*cos 500t A" or

Try regular expression for type in the string response. I assume that -4 
and 500 are both variables so let's say that you have

$A = -4;
$w = 500;

$re = 

will accept answers in the following form:
-4cos 500t A
-4 cos 500t A
-4*cos 500t A
-4*cos(500t) A   -- and any number of spaces before and after *, t, ( and )

If you want to accept mA, then the $A should be multiplied by 1000 and 
another alternate comparison added to re. Or you could specify in your 
problem to give the answer in A.