Hello community:

I'm trying to figure out how to pass values from SAGE to WeBWorK. Please help me fix the error in Sample 2.

Thanks!

Carl Yao

Sample 1 works:

Context("Numeric");

$a1 = 2;

$a2 = 10;

$a3 = -28;

$form = Formula("$a1*x^2 + $a2*x + $a3");

$SageCode1=<<END;

print factor($form)

END

$result = AskSage($SageCode1,{accepted_tos=>true});

$ans =Compute($result);

BEGIN_PGML

[`[$ans]`]

END_PGML

Sample 2 doesn't work:

Context("Numeric");

$a1 = 2;

$a2 = 10;

$a3 = -28;

$form = Formula("$a1*x^2 + $a2*x + $a3");

$SageCode1=<<END;

test=factor($form)

WEBWORK['test']=test

END

$result = AskSage($SageCode1,{accepted_tos=>true});

$ans= Compute($result->{webwork}->{test})->reduce;

BEGIN_PGML

[`[$ans]`]

END_PGML

did you ever get an answer or learn why there is a difference? Tring to learn Sage too.