## WeBWorK Problems

### Geogebra Images not rendering

by Tim Alderson -
Number of replies: 5

Hello,

Running WW 2.15, Geogebra generated images are not rendering. Verified with OPL problems as well as the one included below.
Not getting any errors reported (to the screen).

Any hints as to where to look for a fix?

Problem code and image follow:

## DESCRIPTION
## This is Problem 1.1.9 from the APEX Calculus text. It covers graphical approximation of limits.
## ENDDESCRIPTION

## DBsubject(Calculus - single variable)
## DBchapter(Limits and continuity)
## DBsection(Finding limits using graphs)
## Level(2)
## Institution('Valdosta State University')
## Author('S. V. Ault')
## RevisedBy('F. J. Francis')
## TitleText1('APEX Calculus')
## AuthorText1('Hartman')
## EditionText1('3.0')
## Section1('1.1')
## Problem1('9')
## MO(1)
## Keywords('limit', 'limits', 'ULETH-MATH1560', 'ULETH-MATH1565')

###########################
#  Initialization
DOCUMENT();

# Load whatever macros you need for the problem
"PGstandard.pl",
"MathObjects.pl",
# Used to provide contextual help for how to type answers.
# Provides greater control over the layout of the problem.
"PGML.pl",
# Used to support the GeoGebra applet.
"AppletObjects.pl",
# Used for course-specific initializations.
"PGcourse.pl",
# Used to format the table in the solution
"niceTables.pl",
"unionTables.pl"
);
# Sets up basic problem information.
TEXT(beginproblem());

#############################
#   Setup
#-ULETH-#
Context("Numeric")->variables->are(x=>"Real");

#Randomize the question parameters.
$a=random(4,10,1);$amin1=$a-1;$amin2=$a-2;$a2=2*$a;$f = Formula("(x^2 - $amin2*x -$a2)/(x^2- $amin1*x -$a)");

#Values used in the table of approximations
$a002=$a+0.002;
$a001=$a+.001;
$a0005=$a+.0005;
$a0001=$a+.0001;
$ax002=$a-0.002;
$ax001=$a-.001;
$ax0005=$a-.0005;
$ax0001=$a-.0001;

$aa002=$f->eval(x=>$a002);$aa001=$f->eval(x=>$a001);
$aa0005=$f->eval(x=>$a0005);$aa0001=$f->eval(x=>$a0001);
$aax002=$f->eval(x=>$ax002);$aax001=$f->eval(x=>$ax001);
$aax0005=$f->eval(x=>$ax0005);$aax0001=$f->eval(x=>$ax0001);

#Evaluate the limit
$liminom=($a+2);
$limidenom=($a+1);
$limi=$liminom/$limidenom; #Initialize the table of numerical approximations$approximationTable = $BCENTER.begintable(4) . row( "x","f(x)","x","f(x)") . row($a002, $aa002,$ax002, $aax002). row($a001, $aa001,$ax001, $aax001). row($a0005, $aa0005,$ax0005, $aax0005). row($a0001, $aa0001,$ax0001, $aax0001) . endtable().$ECENTER;
#-ENDULETH-#

######################################
###################################
# You can name your applet (anything reasonable :-) )
# Adjust the height and width as desired
# Paste the geogebra parameters in at the bottom of the page just above the
# command end command
# so that they don't get in the way
###################################

$appletName = "ggbfoo";$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                 => 450,              # may want to modify width
height                => 320,              # may want to modify height
# mayscript             => "true",
debugMode             => 0,   # set debugMode to 0 for no debug
# to 1 to make xml representation visible
# through the applet
onInit                => 'ggbOnInit',
type                  => 'geogebraweb',
#submitActionScript    => qq{ getQE('answerBox').value = getAppletValues() },
submitActionScript => '',
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.

qq!
<script language="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> !); ####################################################### # # For setting initial values in GeoGebra from WeBWorK # Uses JavaScript interface to GeoGebra. TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function setAppletCoefficients() { var applet=getApplet("$appletName");   // alert("Updating coefficients");
if (typeof(applet)!="undefined") {
if (typeof(applet.setValue)!="undefined") {

////////////////////////////////////////////////////////////////
//  List the values of the parameters to be set in the applet here

// Set variables
applet.setValue("a", $a); } else { setTimeout("setAppletCoefficients()", 1000); } } else { setTimeout("setAppletCoefficients()",1000); } } ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()};
</script>
END_SCRIPT

###################################
#insert applet into body  -- this does not need to be changed
# except to adjust the insertion of the reinitialize_button or
###################################
# TEXT($PAR, MODES(TeX=>'geogebraweb code', # HTML=>$applet->insertAll(
#                                debug =>0,
#                                reinitialize_button => 1,
# )));

#############################
#   Problem Text
#-ULETH-#
Context()->texStrings;

$column1 = PGML::Format(<<END_PGML); Approximate the given limit using the provided graph. [\lim_{x \to$a} \, $f = ] [______] [@ AnswerFormatHelp("numbers") @]* END_PGML #-ENDULETH-# BEGIN_TEXT \{ ColumnTable($column1,
$BCENTER.$BBOLD."Graph of $$f(x) = f$$.".$EBOLD.$PAR.
MODES(HTML=>$applet->insertAll(debug=>0, reinitialize_button=>1, includeAnswerBox=>0,), TeX=>$im).
ECENTER , indent => 0, separation => 30, valign => "TOP" ); \} END_TEXT Context()->normalStrings; ############################# # Solution #-ULETH-# BEGIN_PGML_SOLUTION Approximations toward the limit from the left and the right are given in the following table. [@approximationTable @]***

The limit of [[$f]] as [x] approaches [$a] is [[$limi] = \frac{[$liminom]}{[$limidenom]}]. END_PGML_SOLUTION #-ENDULETH-# ############################# # Answer evaluation #-ULETH-# # Setting this to 1 means that students will receive feedback on whether their # answers are correct.$showPartialCorrectAnswers = 0;
#-ENDULETH#
ANS( num_cmp( $limi , strings => ["DNE","dne"] ) ); ######################################### # The applet as a base64 string ######################################### sub GEOGEBRA_PARAMS { my$result = {
showResetIcon=>"false" ,
enableRightClick=>"false" ,
enableLabelDrags=>"false",
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",

};

\$result;
}

COMMENT('
Randomization provides 7 possible versions of this question.<BR>
Includes a solution set.<BR>
Uses GeoGebraWeb (JavaScript), so it should work on computers and tablets.  <BR>
');
ENDDOCUMENT();

### Re: Geogebra Images not rendering

by Andrew Parker -
It seems that the URL for the GeoGebra CDN has changed, and we have a fix out (thanks @drgrice1):
https://github.com/openwebwork/pg/pull/582

If you have already updated your version of WeBWorK, then pulling the latest version of PG (on the PG-2.16 branch, currently) will fix this immediately.

by Glenn Rice -

### Re: Geogebra Images not rendering

by Tim Alderson -
Thank you Andrew.

I have not been able to get 2.16 running yet. Any idea as to how I might apply a fix to 2.15?

### Re: Geogebra Images not rendering

by Glenn Rice -

If you have server administrative access then you can modify the file /opt/webwork/pg/lib/Applet.pm and change line 1163 from

<script type="text/javascript" language="javascript" src="//web.geogebra.org/4.4/web/web.nocache.js"></script>

to

<script type="text/javascript" language="javascript" src="https://www.geogebra.org/apps/latest/web/web.nocache.js"></script>