WeBWorK Problems

Return string from Sage

by F. Heiderich -
Number of replies: 2
I would like to return a string from Sage to WeBWorK using the AskSage function, but have problems doing so.

The following trivial example works:

DOCUMENT();
loadMacros(
"PGstandard.pl", # Standard macros for PG language
);
TEXT(beginproblem());
$SageCode=<<END; print("\"hello\"") END$sageReply = AskSage($SageCode,{accepted_tos=>true,seed=>$problemSeed});
BEGIN_TEXT
Sage reply: $sageReply END_TEXT ENDDOCUMENT();  But the following fails: DOCUMENT(); loadMacros( "PGstandard.pl", # Standard macros for PG language ); TEXT(beginproblem());$SageCode=<<END;
print("\"hello world\"")
END
$sageReply = AskSage($SageCode,{accepted_tos=>true,seed=>$problemSeed}); BEGIN_TEXT Sage reply:$sageReply
END_TEXT
ENDDOCUMENT();



The space between "hello" and "world" seems to case the trouble. Can someone explain how to properly return strings from Sage to WeBWorK?

Re: Return string from Sage

by John Travis -
Just to be certain, there is also the macro "sage.pl" which allows you to do an entire sage cell and allows for sending back a list of items if desired. Details at

http://webwork.maa.org/wiki/Sage_in_WeBWorK

Good luck with this.