Question: Problem with frac() in MapleTA

I am setting up a practice set on how to find a common denominator, add, and reduce.

If I do not set "allow arithmatic", there is no way for students to correctly type in the answer, which is CURRENTLY the return value for a frac() function call. If I DO set "allow arithmatic", the student can just literally type the question into the answer box to get full credit / never has to reduce, etc, which defeats the purpose of the lesson. This is also the case with the Maple Graded answer type unless I do something fancier than I'm doing.

I can set up the answer properly without using frac() and reduce the fraction, but then--when the answer should be a whole number--the student has to type in "3/1" as an example.

I've also tried setting up an if statement for the answer, but when i convert the numbers to strings, then "2/3" becomes .2.0/3.0". 

So, at this point, I'm super open to ideas. 

 

 

# Define the denominators. We want them to be between 2 and 8.
$B=rint(2,8);
$D=rint(2,8);

# Make it so that the numerators can be between 1 and 1 less than the denominators.
# We also want to make sure they're not 0.
# Hashtag dividingby0.
$R=rint(-$B+1,$B-1);
$A=if($R,$R,1);
$S=rint(-$D+1,$D-1);
$C=if($S,$S,1);

# Calculate the numerator multiplied by the denominator. We'll do this step expressly
# because we'll want it for our feedback.
$X=($A*$C);
$Y=($B*$D);

#Calculate the greatest common factor and the answer.
$G=if(gcd($X,$Y),gcd($X,$Y),1);
$ANS=frac($X,$Y);

Please Wait...