How To
Allow Probabilities or Percents

in the same question.

Mobius Logo

In Probability questions we frequently use percentages and probabilities interchangeably. It is understandable then that a student may answer in either format. For example a question with an answer of 0.20 (or 20%) may well be answered with 0.2, 20% or 20. The problem is to properly deal with the % symbol, as it has special meaning to Maple and can easily cause syntax errors.

Choose Maple Graded as your Response field. Set the "Expression Type" value to "Maple Syntax". Now assuming your answer is $Ans, use this marking code:

 

M:=0;

A:=searchtext("%","$RESPONSE");
T:=substring("$RESPONSE", 1 .. A-1);
TN:=parse(T);

if (A>0) or (TN>1) then
    Bf:=TN/100
else
    Bf:=TN;
end if;

 
if (abs(Bf-$Ans)=0) then
   M:=1;
end if;

 
M;

This vesrion does NOT assume that percent answers are always >1. An answer like 0.5% will be treated as the probability 0.005. This is handled by the code

if (A>0) or (TN>1) then
    Bf:=TN/100

The only assumption made here is an entry between 0 and 1 that does not have a % sign is a probability. Notice also that the code does not care if the user uses % or not. 

if you are looking for an answer with tolerance, define $tol and use  

if (abs(Bf-$Ans)<$tol) then
   M:=1;
end if;

To display both forms of the answer, use (in the $ANSWER field):

printf(MathML[ExportPresentation]($Ans));printf(" or ");printf(MathML[ExportPresentation]($Ans*100));printf("&percnt;")

 

 

 



How-To Index

Main Index

Updated: 2023/04/03 SMS/DAG