Maple Worksheet Error when loading a MathApp


  • administrators

    The are a few reasons why MathApps fail to load. Here I present one case that I found along with the fix.

    If you load a create a MathApp question and want to pass parameters from TA into the MathApp, you might find that you get an error as shown in the image below.

    For this question the MathApp had a InitParams function like this

    InitParams := proc( {v::float=10.0 } ) 

    This means the default value for v is 10.0 but this will be overridden if a value for v is passed from TA.

    To pass values from TA you set the Initialisation Parameters in the MathApp question designer like so.

    v=$a;

    Where $a is a variable set in the question algorithm box. For this example let's set $a to a single value.

    $a=3.0;

    If you refresh the algorithm box you will find that T.A. stores the 3.0 as 3. i.e. it stores it as an integer.

    Now since we required v was of type float in the MathApp this throws the error we see above.

    v::float

    If we want to fix this we can either use a maple call to provide the number. This correctly stores the number.

    $v=maple("3.0");

    You will now find that this stores $a as 3.0 and since the type is correct the MathApp loads correctly.

    If you have multiple numbers that you wish to pass into the MathApp, it is best to add format all these numbers with a single maple call and use switch to get the numbers back. Fewer maple calls gives better question performance.

    For example.

    $m = maple("
    v:= 3.0;
    d:= 0.2e-1;
    L:= 25.0;
    rho_:= 1000.0;
    eta_:= 0.1e-2;
    epsilon_:= 0.00015;
    map(x->convert(x,string),[v,d,L,rho_,eta_,epsilon_])
    ");
    $v=switch(0,$m);
    $d=switch(1,$m);
    $L=switch(2,$m);
    $rho_=switch(3,$m);
    $eta_=switch(4,$m);
    $epsilon_=switch(5,$m);
    

Log in to reply