Thanks.

It is an applet I created that generates a random A and B

and puts the sum in C.

I started with code from another problem and simplified it as much as I could to focus on the functionality I want.

I can tell that I am sending values to the applet and retrieving them.

The difficult line is

which computes the correct answer for the third input. I would like that to be the javascript variable c.

I will admit that I do not understand what the lines

$lsgraph =

"<div id='ggb' class='ww-ggb'></div>

and

[$lsgraph]* [__]{$ansa}[__]{$ansb}[__]{$ansc}

I also don't know if there is a way to get a value like c, which was computed by GeoGebra into the WeBWorK text.

Thanks again.

Mike

pg file attached below.

#######################

## DESCRIPTION

## Basic Applet manipulation

## ENDDESCRIPTION

## DBsubject('')

## Author('Mike May')

################################################################################

# Initialization

################################################################################

DOCUMENT();

HEADER_TEXT('<script type="text/javascript" src="https://cdn.geogebra.org/apps/deployggb.js"></script>

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ww_ggb_applet/lib/ww_ggb_applet.js"></script>');

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGML.pl",

"contextArbitraryString.pl",

"parserPopUp.pl",

"niceTables.pl",

"PGchoicemacros.pl",

);

TEXT(beginproblem());

################################################################################

# Problem Setup

################################################################################

Context("Numeric");

$A=random(1,20,1);

$B=random(1,20,1);

$lsgraph =

"<div id='ggb' class='ww-ggb'></div>

<script>

var onLoad = function(applet) {

applet.evalCommand('A: $A');

applet.evalCommand('B: $B');

applet.setVisible('scattersoln',false);

var a = this.applet.getValue('A');

var b = this.applet.getValue('B');

var c = this.applet.getValue('C');

this.setAnswer('AnSwEr0001', a);

this.setAnswer('AnSwEr0002', b);

this.setAnswer('AnSwEr0003', c);

}

var onUpdate = function(obj) {

var a = this.applet.getValue('A');

var b = this.applet.getValue('B');

var c = this.applet.getValue('C');

this.setAnswer('AnSwEr0001', a);

this.setAnswer('AnSwEr0002', b);

this.setAnswer('AnSwEr0003', c);

}

wwG = new WwGgbApplet('ggb', {height:200, width:150, borderColor:'#FFFFFF', 'material_id':'mnz7sa8t', appletOnLoad: onLoad, appletOnUpdate: onUpdate, hideAnswers: true});

</script>";

$ansa = Compute("$A");

$ansb = Compute("$B");

$ansc = Compute("1");

# [$table]***

################################################################################

# Text

################################################################################

BEGIN_PGML

A company sends out ten different questionnaires to its customers.

The table shows the number sent and replies received for each questionnaire.

[$lsgraph]* [__]{$ansa}[__]{$ansb}[__]{$ansc}

Complete the following parts using the interactive graph above.

A=[$A]

B=[$B]

C=[$C]

END_PGML

################################################################################

# Answers and Solutions

################################################################################

#BEGIN_PGML_SOLUTION

#END_PGML_SOLUTION

ENDDOCUMENT();