# How to debug Maple-graded without Maple (application) browsing

• When working with Maple-graded response areas or question types, it is recommended to test the grading code against incorrect and malformed expression that students could enter by mistake. The easiest tool for this is of course Maple. However, in cases when it is not available, the tips below should help you with debugging.

1. Use algorithm

Algorithm allows you to run Maple code, therefore also the grading code. We'll use the following grading code:

# answer:="$RESPONSE";evalb((x < %/(3,2)) = InertForm:-Parse(answer))  In order to run it in the algorithm, in this particular case, we should use single quotation marks (') to balance the double ones (") of the "$RESPONSE".

$debug = maple(' answer:="$RESPONSE";
evalb((x < %/(3,2)) = InertForm:-Parse(answer))
');


Now replace $RESPONSE with expression you'd like to test and see the result! $debug = maple('
evalb((x < %/(3,2)) = InertForm:-Parse(answer))
');


If the code works well in the algorithm, but not in the grading area, it could be caused by the equality checks. This can be the case when you're applying StringTools on a mathematical expression. The easy way to check for this is the if-then-else test. Consider the following grading code:

evalb($RESPONSE = "a")  In this case answer "a" (without quotation marks) grades as 0.0. In order to check what could be wrong, we rewrite it to: if evalb($RESPONSE = "a") then 0.5 else 0.3 end if


If we enter "a" (without quotation marks) we receive grade of 0.3. This tells us that the earlier grading code doesn't contain syntax errors, and that the expression evalb($RESPONSE = "a") is just been evaluated to false. Now we know that$RESPONSE cannot be compared to "a" without conversion to a String. So we try:

if evalb(convert($RESPONSE, string) = "a") then 0.5 else 0.3 end if  This gave us the expected 0.5 grade. So the original grading code should have been: evalb(convert($RESPONSE, string) = "a")


• @Anatoly_ilin I really like you if-then-else trick.

I think that the single quotes have a specific meaning in T.A. and can cause a variety of strange issues when replacing the double quotes with single ones in the maple call. I have found the best approach to dealing with strings in Maple T.A. is by using the symbol notation and the convert to string. For example

\$foo=maple("
if (1=1) then
convert(hello world,string);
else
convert(goodbye world,string);
end if
");


Even though this adds an extra call to convert, every time we have a string, it is always parse as correct syntax in the grading code and the algorithm.

What do you think?

• @jmtrik Intersting alternative, haven't used it yet. Thanks for the tip!