WeBWorK Problems

Geogebra Images not rendering

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
loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  # Used to provide contextual help for how to type answers.
  "AnswerFormatHelp.pl",
  # 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-#



######################################
# Create  link to applet:
###################################
# 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
                                              # to 2 to add alerts detailing progression
                                              # through the applet
   onInit                => '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 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
# a hidden AnswerBox
###################################
# TEXT($PAR,  MODES(TeX=>'geogebraweb code',
#                      HTML=>$applet->insertAll(
#                                debug =>0,
#                                reinitialize_button => 1,
#                                #includeAnswerBox=>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",
showMenuBar=>"false" ,
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",
ggbbase64=>"UEsDBBQACAgIAJh6skwAAAAAAAAAAAAAAAAWAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc0srzUsuyczPU0hPT/LP88zLLNHQVKiu5QIAUEsHCEXM3l0aAAAAGAAAAFBLAwQUAAgICACYerJMAAAAAAAAAAAAAAAAFwAAAGdlb2dlYnJhX2RlZmF1bHRzMmQueG1s7Vpbc+I2FH7u/gqNn9qHgG0wkEzITnZnOs1MNtspmZ2+Cvtg1AjJteRg8usrS74RMAMkIbAND1hHPjqSvu/o6ObLz+mMokeIBeFsaDkt20LAfB4QFg6tRE7OBtbnq0+XIfAQxjFGEx7PsBxaXqZZllNSq9PTpVEqyAXjd3gGIsI+jPwpzPAt97HUqlMpo4t2ez6ftwqjLR6H7TCUrVQEFlINYmJo5YkLZW6p0Lyj1V3bdtp/f7s15s8IExIzHyykGhvABCdUCpUECjNgEslFBENrkjA/a8XdDxxbiOIx0KHFEkotlJcZWj3Puvr0y6WY8jni43/AV3kyTqDU10I701Gvv3LKYxQPLdfuWkhBphAY639MoylWqVbfM9oULyBGj5hmr3UOTiT3tQGdO8FUQKGrqvrGAzBvurk+IzONIhISIsWWhUQEEOiU6aGqOFIVafZq9ogYTXEEz+q5bOfwrABFiZBlh2+1UALkdOxVhIzNzRDZGiDHfg7RWeY3RwqRqocwGMkFBSSnxH9gIJRzdmrGssQfJAggGz+mTMQJkyPylFvz6rnalM4+czaTEHG6CDkrUf2zkEsq+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Wg8vOgS+a3c7UJdThpPKVkm9yKpGGESrR1r0fKZ+jkGHqM1xDBj+C9vk9oHImLkANIH8jqn9dr3vr4UCzsFgtk4l8EXPxchTjtngex/ylOH7dNSEz9aTCBMXN83SuNc+Ynss51zIoJaYCS+pc5XSm1HiRTuCX+HtR/HGEsKQaF2XLc+qzjHfy6uw8i4XTxPBDz6f/A1BLBwjtDh97wwYAAJkSAABQSwECFAAUAAgICACYerJMRczeXRoAAAAYAAAAFgAAAAAAAAAAAAAAAAAAAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc1BLAQIUABQACAgIAJh6skx/wxLUzgQAAFYmAAAXAAAAAAAAAAAAAAAAAF4AAABnZW9nZWJyYV9kZWZhdWx0czJkLnhtbFBLAQIUABQACAgIAJh6skwwyCiE3wIAAI0NAAAXAAAAAAAAAAAAAAAAAHEFAABnZW9nZWJyYV9kZWZhdWx0czNkLnhtbFBLAQIUABQACAgIAJh6skztDh97wwYAAJkSAAAMAAAAAAAAAAAAAAAAAJUIAABnZW9nZWJyYS54bWxQSwUGAAAAAAQABAAIAQAAkg8AAAAA"

};

$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>
    Made from a ULETH template.<BR>
    ');
ENDDOCUMENT();



 

In reply to Tim Alderson

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. 
In reply to Andrew Parker

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?
In reply to Tim Alderson

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>