WeBWorK Problems

Problem with Embedding 3D Geogebra in WeBWorK

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();

loadMacros(
"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") {
applet_loaded(param,1); // report that applet is ready.
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",
showMenuBar=>"false" ,
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",
ggbbase64=>"UEsDBBQACAgIAE9uiE4AAAAAAAAAAAAAAAAWAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc0srzUsuyczPU0hPT/LP88zLLNHQVKiu5QIAUEsHCEXM3l0aAAAAGAAAAFBLAwQUAAgICABPbohOAAAAAAAAAAAAAAAAFwAAAGdlb2dlYnJhX2RlZmF1bHRzMmQueG1s7VrfU9s4EH6+/hUaPd09kNhOnKQMoUM7c3PMUHpzMJ17VeyNo0ORfJYMDn99Zcm/QhIanFACLQ9Yq0gr6dtP69XKJx+yOUO3kEgq+Bi7HQcj4IEIKY/GOFXToxH+cPruJAIRwSQhaCqSOVFj7Octq35a6vg905vE8RgHjEhJA4xiRlTeZYxDjFAm6TEXl2QOMiYBXAUzmJMLERBltMyUio+73bu7u045XkckUTeKVCeTWoGeK5djXBSOtbqlTnc909xzHLf77+cLq/6IcqkIDwAjvY4QpiRlSuoiMJgDV0gtYhjjWLBFJDhGjEyAjfHfpVz0GOOhg0/f/XbCKIcrtWCA1IwGNxyknpGPCzWOLfxFwxByPDESeqVULXR5OMLdXIOciTskJv9BoLWqJIVqUCOYNvrnT4KJBCW6o9/DSFvD19omZgjC4hnRpY7r2D+3/95x3YHr2d6MLCBBt4TlrU0NSZUIjEJTOyVMQtlWD/1ZhGB/6RftOZ0bqyCpIDYLkTFAaErVUrV1F4Yolb6TbgHrWoBz7JYQthU1xO4LQewYgJ0VfJ3DxXOa8iBXePmVJNXqeMpYA8+Bj9ug4Tn9DXgM/cMHpFrcpzS5bbKr13ecVnjsyo5a636x2H2nPLZdKVeNvaol9Ps0AfijgajbDs/h0ACaPzSinu+/0I5z14MaCJGEEmVjfEkuMVoUz3v7NE0MOlf0vhjSb9Yac9Qz3wwxo7JG+MIINbK9NdDaOW7DVf1eeMDWI/flndmT+foErI/cFnwOIQaux1JLpHZbkXowMsjnj4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UD9wJdPDDyLpcmMqla7K5U7nFEMReOPF01+S9Ge6Izf0v0gIPsBi2IZs4hJGclbzviwL5buJX61fcW70yA3ouef1xq/FmS0g2wbMTfFu6muc8MHYN4XCIeqHw/f2No/I7b/0fXqv1BLBwi7diEyEwoAAJ0mAABQSwECFAAUAAgICABPbohORczeXRoAAAAYAAAAFgAAAAAAAAAAAAAAAAAAAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc1BLAQIUABQACAgIAE9uiE5UIeOr5AQAAFkmAAAXAAAAAAAAAAAAAAAAAF4AAABnZW9nZWJyYV9kZWZhdWx0czJkLnhtbFBLAQIUABQACAgIAE9uiE5JaPm6NgMAACMRAAAXAAAAAAAAAAAAAAAAAIcFAABnZW9nZWJyYV9kZWZhdWx0czNkLnhtbFBLAQIUABQACAgIAE9uiE67diEyEwoAAJ0mAAAMAAAAAAAAAAAAAAAAAAIJAABnZW9nZWJyYS54bWxQSwUGAAAAAAQABAAIAQAATxMAAAAA"
};

$result;
}


COMMENT('Uses GeoGebraWeb (JavaScript) so it should work on computers and tablets. Uses MO and is NOT randomized. Does not use a JS listener. Uses a blank geogebra applet just to show an interactive diagram.');

ENDDOCUMENT();

Attachment errorMessage.PNG