**Issue**: the unanswered HTML blank set the variable response to "No answer", **but! it gets translated**

function setFeedback(response, answer){ if (response == "No answer" && answer == null) { /* not yet attempted */ run([], 1); } else if (answer == null) { /* previously attempted */ run(response, 2); } else if (answer != null) { /* show correct answer in the gradebook */ run(answer, 3); } };

Fix:

function setFeedback(response, answer){ var translations = ["No answer","Sin respuesta", "未解答", "Aucune réponse", "Keine Antwort", "Καμία απάντηση", "Nessuna Risposta", "解答なし", "답변 없음", "Brak odpowiedzi", "Sem resposta"]; if (translations.indexOf(response) >= 0 && answer == null) { /* not yet attempted */ run([], 1); } else if (answer == null) { /* previously attempted */ run(response, 2); } else if (answer != null) { /* show correct answer in the gradebook */ run(answer, 3); } };

Some background for this:

HTML blank has the following states:

- Assignment: not answered, first attempt
- Assignment: not answered, not the first attempt (student browsed to a different question and came back)
- Assignment: answered, not the first attempt (student browsed to a different question and came back)
- Gradebook: students answer
- Gradebook: correct answer
- Preview: not answered, first attempt
- Preview: answered, gradebook-like overview

App can determine the state using the following variables:

- interactiveMode
- response
- answer

*interactiveMode* is *true* when question is either opened in the assignment or in the preview.

*response* is either “No answer” (and translations), *null* or whatever your app returns with *getResponse*(). *response* is set to *null* when app is opened in the grade book to show the correct answer. In all other cases it's either *"No response" *(or translation) or whatever was previously returned with getResponse(). In the assignment, response is initialized with “No response” both on the first attempt as on every revisit of the question as long student didn’t interact with the app causing getResponse() to be called.

*answer* is either null or whatever is set in the Correct-field of the blank.

In the gradebook app is run twice, one for the left and one for the right pane. Apps are run in two separate iframes and cannot be interconnected easily.

nonZeroVec := overload( [ proc(v::Vector) option overload; local dim:=LinearAlgebra:-Dimension(v); if LinearAlgebra:-Equal(v,LinearAlgebra:-ZeroVector(dim)) then v(rand(1..dim)()):=rand(1..4)()*(-1)^rand(0..1)():fi: end, proc(l::list) option overload; local i; for i from 1 to numelems(l) do nonZeroVec(l[i]) od: end ] ): nonSing3 := proc() local a,b,num1,num2,c,trans,M: #Generate Random Column Vectors: a:=LinearAlgebra:-RandomVector(3, generator = -4..4): b:=LinearAlgebra:-RandomVector(3, generator = -4..4): #Check for zero vectors: nonZeroVec([a,b]): #Ensure Linear Independance: while LinearAlgebra:-Equal(abs(a/norm(a)),abs(b/norm(b))) do num1:=rand(0..1)(): num2:=rand(0..1)(): b(1):=(-1)^num1 *rand(1..2)()+b(1): b(2):=(-1)^(num2*(1-num1)) *rand(1..2)()+b(2): b(3):=(-1)^((1-num2)*(1-num1)) *rand(1..2)() +b(3): nonZeroVec([a,b]): od: c:=LinearAlgebra:-CrossProduct(a,b): c:=c/max(igcd(c(1),c(2),c(3)),1): M:=Matrix( combinat:-permute(convert([a,b,c],list))[rand(1..6)()] ): trans:=rand(0..1)(): M:=M*(1-trans) + LinearAlgebra:-Transpose(M)*trans: return M; end proc:]]>

(No more will you have to write : [convert(a,string), convert(b,string), convert(c,string)...etc.] )

str := proc(x)simply add at end of your final line of maple call:

local i,rtn := []:

if type(x,list) then

for i to numelems(x) do rtn:=[op(rtn),str(x[i])] od:

else rtn:=convert(x,string): fi:

return rtn:

end proc:

$m=maple(" str := proc(x)]]>

local i,rtn := []:

if type(x,list) then

for i to numelems(x) do rtn:=[op(rtn),str(x[i])] od:

else rtn:=convert(x,string): fi:

return rtn:

end proc: ... ... str([a,b,c...etc.]) ");

#Make 2x2 Matrix w/ zero determinant

local M, A, flag := true:

while flag do

M := LinearAlgebra[RandomMatrix](2,2, generator = gen):

if LinearAlgebra:-Determinant(M) = 0 then

M[1,1] := (M[1,1] + 1 ) mod 10;

M[1,2] := (M[1,2] + 5 ) mod 10;

M[2,1] := (M[2,1] + 5 ) mod 10;

M[2,2] := (M[2,2] + 4 ) mod 10;

fi:

if LinearAlgebra:-Determinant(M) <> 0 then

flag := false:

fi:

od: #Insert as cofactor into 3x3 Matrix

A := Matrix(\[\[M[1,1],M[1,2],gen()],[M[2,1],M[2,2],gen()],[gen(),gen(),1\]\]): #Edit last element such that determinant is zero

A[3,3] := -(A[3,1]*(A[1,2]*A[2,3]-A[1,3]*A[2,2])

-A[3,2]*(A[1,1]*A[2,3]-A[1,3]*A[2,1]))

/(A[1,1]*A[2,2] - A[1,2]*A[2,1]):

return A: #Returns singular 3x3 matrix

end proc: #re-generate until final element is a 'nice' number

do

qM := singular3(rand(-3..3));

if qM[3,3] = trunc(qM[3,3]) and abs(qM[3,3]) < 4 then

break

fi:

od: qM, LinearAlgebra[Determinant](qM);

]]>

First we create a second order differential equation with constant coefficients, then we use the Maple function *dsolve and the DEtools* package to get the complimentary function, the particular integral and the general solution.

# second order linear differential equations with constant coefficients # real roots restart; ode:=diff(y(x),x,x)+3*diff(y(x),x)+2*y(x)=x^2; compFun:=subs({_C1=A,_C2=B},dsolve(lhs(ode))); partInt:=convert(DEtools[particularsol](ode,y(x)),trig); genSol:=subs({_C1=A,_C2=B},dsolve(ode));

You can just check equivalence of the student's answer and the above expressions but this can cause problems with the coefficients in the complimentary function and the general solution. The standard approach to dealing with this is to run various checks to see if the student's solution is a solution in various cases, to make sure there are two coefficients and that the solutions are suitably general. i.e. not y(x)=0.

Here's the grading code for the three expressions (again, this is in Maple and you will need to convert the variables to $ variables for Maple T.A.).

compFunGrade:=evalb( evalb(convert(simplify(expand(simplify(subs(compFun,lhs(ode)), symbolic)), symbolic), expln) = 0) and subs(x=0,rhs(compFun))<>0 and simplify(subs(x=0,rhs(compFun))/subs(x=1,rhs(compFun)),symbolic)<>0 and nops(indets(rhs(genSol),name) minus {x})=2 );

partIntGrade:=evalb( evalb(convert(simplify(expand(simplify(subs(partInt,lhs(ode))-rhs(ode), symbolic)), symbolic), expln)=0) and subs(x=0,rhs(partInt))<>0 );

genSolGrade:=evalb( evalb(convert(simplify(expand(simplify(subs(genSol,lhs(ode))-rhs(ode), symbolic)), symbolic), expln) = 0) and subs(x=0,rhs(genSol))<>0 and simplify(subs(x=0,rhs(genSol))/subs(x=1,rhs(genSol)),symbolic)<>0 and nops(indets(rhs(genSol),name) minus {x})=2 );

The result of these should be true.

]]>If, for example, you had the teacher's answer and student's response like the following

$TA="ln(x^a)"; $RESPONSE="a*ln(x)";

Then you could use this grading code

assume(a>0); assume(x>0); evalb(simplify($TA-$RESPONSE=0));

Alternatively you can use *simplify(.., symbolic) *which symbolically rearranges the expression, ignoring possible branch cuts.

evalb(simplify($TA-$RESPONSE=0,symbolic));]]>

**Note: You must you choose Maple syntax for the expression type in the Maple-graded answer box.**

Some examples

**Hyperbolic**

$TA = "(exp(x)-exp(-x))/2"; $RESPONSE = "sinh(x)"; evalb(convert($TA-$RESPONSE = 0, expln));

**Trigonometric**

$TA = "(exp(I*x)-exp(-I*x))/(2*I)"; $RESPONSE = "sin(x)"; evalb(convert($TA-$RESPONSE = 0, expln));

Remember you may need to use commands like *simplify* or *expand* to test equality for more complicated expressions. Of course you can always use the following general purpose grading code

evalb(convert(simplify(expand(simplify($RESPONSE-$TA, symbolic)), symbolic), expln) = 0)]]>

p, h1, h2, h3, h4, td, li, .math{ font-size: 16px; } h1, h2, h3, h4{ color: white; padding: 0.5em; } h1{ background: #0872AB; font-size: 30px; } h2{ font-size: 26px; background: #2B82B0; margin-bottom: 8px; } h3{ font-size: 22px; background: #4E98BF; } h4{ font-size: 16px; background: #79B9DB; } h1+h2, h1+h3, h1+h4{ margin-top: -8px; } h2+h3, h2+h4{ margin-top: -6px; } h3+h4{ margin-top: -8px; }]]>

If you run the following code

$m=maple(" printf(MathML[ExportPresentation](2*x)) ");

it will look like this

Notice the space in between the 2 and the x. To get rid of the invisible times use this code

$m=maple(" exprD:=MathML[ExportPresentation](2*x); printf(StringTools:-SubstituteAll(exprD, ``, ``)) ");

Then your expression will look like this

]]>\( x^{2} \)

would look like this

If you want smaller indices on you latex expressions you can use the following code

\( x^{\mathrm{\tiny{2}}} \)

The result is this

]]>evalb(convert(simplify(expand(simplify(input-ta, symbolic)), symbolic), expln) = 0) ]]>

To manually control the width of input boxes for Maple-graded or Mathematical formula questions you can modify the CSS of the question. First add your input boxes to the question text area.

Now open the Custom CSS tab and add the following

input[type='text'] {width:250px }

Saving your question and previewing the result you will now see the wider input boxes.

]]>Here is my data set

$data="[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]";

I want to divide this into three data sets

X 10, 40, 70 ...

Y1 20,50,80...

Y2 30,60,90..

To do this, first we divide the data sets

$m=maple(" K := $data; X := subsop(seq(`if`(`mod`(i, 3) = 1, NULL, i = NULL), i = 1 .. nops(K)), K); Y1 := subsop(seq(`if`(`mod`(i, 3) = 2, NULL, i = NULL), i = 1 .. nops(K)), K); Y2 := subsop(seq(`if`(`mod`(i, 3) = 0, NULL, i = NULL), i = 1 .. nops(K)), K); ");

To plot one of these series we can use

plot(Vector(X), Vector(Y1), style = point, symbol = asterisk, color = `blue`)

To plot both on the same graph we can use the plots[display] function.

plots[display]( plot(Vector(X), Vector(Y1), style = point, symbol = asterisk, color = `blue`), plot(Vector(X), Vector(Y2), style = point, symbol = asterisk, color = `red`) )

The full code looks like this

$data="[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]"; $m=plotmaple(" K := $data: X := subsop(seq(`if`(`mod`(i, 3) = 1, NULL, i = NULL), i = 1 .. nops(K)), K): Y1 := subsop(seq(`if`(`mod`(i, 3) = 2, NULL, i = NULL), i = 1 .. nops(K)), K): Y2 := subsop(seq(`if`(`mod`(i, 3) = 0, NULL, i = NULL), i = 1 .. nops(K)), K): plots[display]( plot(Vector(X), Vector(Y1), style = point, symbol = asterisk, color = `blue`), plot(Vector(X), Vector(Y2), style = point, symbol = asterisk, color = `red`) ) ");

The result is

# Generates a sample of 10 numbers from a uniform distribution on the range 0 to 5 $m1 = maple(" randomize(): #initialise random seed A:=Statistics[RandomVariable](Uniform(0,5)): # uniform on a range 0 to 5 nums:=Statistics[Sample](A,10); #pull 10 numbers from the sample convert(nums,list) # converts the vector of numbers to a list ");

If you want to define your own list of numbers you can define $m1 as something like

$m1="[1.2, 4.4, 5.0, 2.5, 3.4, 4.6, 8.6, 7.8, 1.7, 0.4]";

You can then calculate the various quantities on the list stored in $m1. Note: As a check, in the following I have calculated the sample and population standard deviations using built in functions and the explicit formulas.

$m2=maple(" #mean mu:=Statistics[Mean]($m1); #sample s.d. s0:=Statistics[StandardDeviation]($m1); s1:=sqrt(add(i, i = map( x-> (x-mu)^2, $m1))/(nops($m1)-1)); #explicit #population s.d. sigma0:=evalf(Statistics[StandardDeviation]($m1)*sqrt((nops($m1)-1)/nops($m1))); sigma1:=sqrt(add(i, i = map( x-> (x-mu)^2, $m1))/(nops($m1))); #explicit #sum sum0:=add(i,i=$m1); #range range0:=abs(max($m1)-min($m1)); # return values mu,s0,s1,sigma0,sigma1,sum0,range0 "); #use switch to get the values from the maple call $mean=switch(0,$m2); $s0=switch(1,$m2); $sigma0=switch(3,$m2); $sum0=switch(5,$m2); $range0=switch(6,$m2);

The resultant variable in the algorithm section should now be set to something like the following

]]>

evalb( $ANSWER = $RESPONSE)

with $ANSWER set as [-1, 0.5] , grading code will return 0 when student answers it as [-1, 1/2].

The reason for this is "evalb()". It performs a single, cursory comparison, therefore:

evalb( 0.5 = 1/2 ); # returns 1 or true, because it's one step operation evalb( [0.5] = [1/2] ); # returns 0 of false, because it's a two step operation evalb( [0.5] = [0.5] ); # returns 1 or true, because it's one step operation

**Solutions**:

evalb( simplify( $ANSWER - $RESPONSE = [0.,0.] ) ); # 'quick and dirty'

or

andmap(evalb, `~`[`=`]($ANSWER, $RESPONSE)); # Maple "export" notation

or

andmap(evalb, $ANSWER=~$RESPONSE ); # alternative notation]]>

To fix it add this to your **Question CSS**.

.MathJax nobr>span.math>span { border-left-width:0 !important };

]]>

body { color: #737373; font-size: 12px; font-weight: normal; font-family: Helvetica, Arial, Geneva, Swiss, SunSans-Regular; }

]]>

In order to solve that, the "$" sign should be escaped with "\":

\$

The same method can be used for the answers in the list blank. Consider the following (MS Excel) question:

The correct answer (as typed in by the students) should be:

$A$1:$B$5

This can be defined as:

Maple TA doesn't allow students to use variables in the answers, therefore the $ doesn't need to be escaped:

$m=maple(" expr := diff(x(t), t, t) = 2*x(t); sol:=dsolve(expr, x(t)); subs({_C1 = C, _C2 = D}, sol) ");

This results in

\( \frac{$a}{$b} \). To ensure that it is in it's simplest form I use this MapleTA code:

MapleTA:

$a = rint(1, 20);

$b = rint(1, 20);

$gcd = gcd($a, $b);

$numerator = $a/$gcd;

$denominator = $b/$gcd;

LaTeX:

\( \frac{$numerator}{\denominator} \)

]]>

The only required argument is the size of the matrix, the others are optional.

Usage:

genUniModular(4, gen = rand(-10..10), type = lower)to generate a 4x4 lower triangular unimodular matrix with non-diagonal elements between -10 and 10

]]>$TAexp = int(log(abs($TA))) - if(lt(abs($TA), 1), 1, 0);

$TAman = $TA/10^$TAexp

This can then be formatted with latex: \($TAman \times 10^{$TAexp}\).

]]>