## WeBWorK Problems

### Problem with Embedding 3D Geogebra in WeBWorK

by Zachery Sharon -
Number of replies: 0
I'm trying to use Geogebra in a WeBWorK problem, but the applet seems to have trouble with 3D commands.

I've written an optimization problem involving a cone, and I wanted to embed an interactive Geogebra graph so that the student can see the relationship between the independent variable and the volume of the cone. I have attached a screenshot of the error message that Geogebra produces within the WeBWorK problem. In the screenshot, you can see the expression (0,0,R/(2pi)*sqrt(4pi*t-t**2)), this is the vertex of the cone, and R-R*t*(2pi)^-1 is the radius of the cone. These are the only objects that were created in the 3D window.

It seems like 3D commands cause problems as I've never encountered this issue with 2D commands. I probably need to test a few other 3D commands to see if they work.

Has anyone encountered this problem?

(Edit: I'm not sure why my text isn't wrapping. Sorry about that.)

############## PG code below ############

# written by zach sharon 4/5/19
# based on Paul Pearson's problem at https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Calc1/06-01-Antiderivatives-graphically/AF1/AF1.pghttps://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Calc1/06-01-Antiderivatives-graphically/AF1/AF1.pg

######### other resources used to make this problem
# http://webwork.maa.org/moodle/mod/forum/discuss.php?d=4041
# https://wiki.geogebra.org/en/Reference:GeoGebra_Apps_API
# http://dev.geogebra.org/examples/html/example-api-listeners.html
# http://webwork.maa.org/pod/pg_TRUNK/lib/Applet.html#methods_defined_for_the_javascript_applet_ww_applet_list_appletname_
#

##########################################
# Initialization

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"unionTables.pl",
"niceTables.pl",
"AppletObjects.pl",
"PGchoicemacros.pl",
"PGcourse.pl",
"parserImplicitPlane.pl",
"PGML.pl",
"PGbasicmacros.pl"
);
$showPartialCorrectAnswers = 1; TEXT(beginproblem()); ########################################## # Setup$r = random(3,8,1);
$ans = Compute("2*pi-sqrt(8/3)*pi"); ###################################### # Create link to applet: ###################################$appletName = "applet1";

$applet = GeogebraWebApplet( code => "geogebra.GeoGebraApplet", archive => "geogebra.jar", codebase => findAppletCodebase("geogebra.jar"), appletName =>$appletName,
appletId => $appletName, submitActionAlias => 'getAppletValues', # default actionAlias initializeActionAlias => 'configure', # default actionAlias setStateAlias => 'setXML', getStateAlias => 'getXML', setConfigAlias => '', getConfigAlias => '', returnFieldName => '', width => 720, # may want to modify width, originally 640 height => 540, # may want to modify height, originally 480 # mayscript => "true", debugMode => 0, # set debugMode to 0 for no debug # to 1 to make xml representation visible # to 2 to add alerts detailing progression # through the applet XonInit=> 'ggbOnInit', type => 'geogebraweb', #submitActionScript => qq{ getQE('answerBox').value = getAppletValues() }, submitActionScript => '', selfLoading => 1, params => GEOGEBRA_PARAMS(),# paste parameters in ); ################################## # Setup GeogebraWebApplet -- ################################### ############################################### # # For persistence of GeoGebra applet state # when answers are submitted or page is refreshed. # Uses JavaScript interface to GeoGebra. HEADER_TEXT( qq! <script Xlanguage="javascript"> function ggbOnInit(param) { if (param == "$appletName") {
ww_applet_list[param].safe_applet_initialize(2);
}
}

</script>
<noscript>For this question to work properly,
you must enable JavaScript, or use another browser
(or computer) on which JavaScript works.</noscript>
!);

####################
# PNG picture of GeoGebra applet for hardcopy

#$im = image( "AF1.png", width=>520, height=>520, tex_size=>900 ); ########################################## # Main text BEGIN_PGML A circle with radius [[$r]] has a sector with angle [\theta] cut out. The two cut edges of the larger piece are then joined to form the lateral surface of a cone. What angle [\theta] maximizes the volume of the cone?

[\theta=][______________________________]{$ans} END_PGML Context()->texStrings; BEGIN_TEXT \{$BCENTER.
MODES(HTML=>$applet->insertAll(debug=>0, reinitialize_button=>1, includeAnswerBox=>0,), TeX=>$im).
$ECENTER \} END_TEXT Context()->normalStrings; ######################################### # The applet as a base64 string ######################################### sub GEOGEBRA_PARAMS { my$result = {
showResetIcon=>"false" ,
enableRightClick=>"false" ,
enableLabelDrags=>"false",