## WeBWorK Problems

### Passing GeoGebra values to WeBWorK as "correct" answers?

by tim Payer -
Number of replies: 15
Greetings,

We are making tentative steps on the two-way communication between a GeoGebra applet embedded within a WeBWorK problem...

Since the GeoGebra applet we are using gives student feedback in terms of an accuracy score,an integer on [0 to 100], how can javascript indicate to WeBWorK that this single value that is passed is "correct" since WeBWorK had no inputs to the applet to begin with?

We can get the student's accuracy value to be passed to WeBWorK from GeoGebra, and we can use a conditional statement to pass on the number one for a comparison with a WeBWorK answer variable to see if this is the correct value. This will cause the green field to light up as "correct". But the student will only see the number one as their entered value and the number one as the "correct value" in WeBWorK. However the student wont see "82" or "78" as the score that they achieved in the applet which is our intention.

So this leads to two Questions:
1.) How can a value passed to WeBWorK from a GeoGebra applet be read as "correct", or at least the score that a student is willing to accept.
2.) If the score is considered correct, does this prevent further attempts at improving one's score by re-attempting the problem with a new function in the embedded applet?

Thanks for any consideration....

Tim

## A simple testing of embedding GeoGebra applet
## Using two-way communication of values between the platforms
## of GeoGebra and WeBWorK
DOCUMENT();
"PGstandard.pl",
"MathObjects.pl",
"PGinfo.pl",
"unionTables.pl",
"AppletObjects.pl",
#"source.pl",
"PGcourse.pl",
);
TEXT(beginproblem());

$showPartialCorrectAnswers = 1; Context("Numeric"); ################################# # Set up problem for random variables # Set parameters for a circle ################################# #$a = random(0,7,1);
$a = 7;$b = random(-3,2,1);
#$ans70 = String("NotBad");$answ = Compute("$b");$answer = Compute("1");
$accin = random(0,100,1);$acc = random(0,100,1);
$wrg = "Nope!"; ###################################### # 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 = "numberTest";
$applet = GeogebraWebApplet( code => "geogebra.GeoGebraApplet", archive => "geogebra.jar", codebase => findAppletCodebase("geogebra.jar"), appletName =>$appletName,
appletId => $appletName, submitActionAlias => 'getAppletValues', # default actionAlias initializeActionAlias => '', # default actionAlias setStateAlias => 'setXML', getStateAlias => 'getXML', setConfigAlias => '', getConfigAlias => '', returnFieldName => '', width => 700, # may want to modify width height => 300, # 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" takes the student submission in a geogebra applet # and passes it to webwork: getQE() is a webwork call for geogebra submission? # A general case of retrieving all values vs specific cases "a" and "b" # is shown below... submitActionScript => qq{ getQE('answerBox').value = getAppletValues() }, #submitActionScript => qq{ getQE('answerBox').value = applet.getValue("a") }, #submitActionScript => qq{ getQE('answerBox').value = applet.getValue("b") }, selfLoading => 1, params => GEOGEBRA_PARAMS(), # paste parameters in ); ####################################################### # # For setting initial values in GeoGebra from WeBWorK # Uses JavaScript interface to GeoGebra. # hotfix #354 via Mike Gage was attempted and disgarded below to no affect: # // Affixed protective <div>s to prevent overlapping text ############################################################# 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 "a" and "b" in GeoGebra to values $a &$b from WebWork
// But this first example passes nothing from ww to ggb
applet.setValue("accin", $accin); // applet.setValue("b",$b);
// applet.setCoords("C", $a,$b);
} else {
setTimeout("setAppletCoefficients()", 1000);
}
} else {
setTimeout("setAppletCoefficients()",1000);
}
}
ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()}; </script> END_SCRIPT ################################## # Setup GeogebraWebApplet -- ################################### # // deleted Affixed protective <div> s to prevent overlapping text HEADER_TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function ggbOnInit(param) { var applet = document.$appletName;
if (param == "$appletName") { applet_loaded(param,1); // report that applet is ready. ww_applet_list[param].safe_applet_initialize(2); ww_applet_list[param].object = param; console.log("ggbOnInit: ww_applet_list["+param+"].object = ", ww_applet_list[param].object ); } } </script> END_SCRIPT HEADER_TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function setConfig() { var appletState = getQE('${appletName}_state').value;
if (ww_applet_list['$appletName'].object == undefined ) { setTimeout("setConfig()", 5000); console.log("waiting"); } else { var applet=$appletName;
}
}
</script>
END_SCRIPT

<script language="javascript">
function getAppletValues() {
console.log("getAppletValues() entered");
// get a handle for the applet object
var applet = $appletName; var A = applet.getValue("accuracy"); // from GeoGebra, 'a' to Webwork? var D = applet.getValue("acc"); // from GeoGebra, 'd' to Webwork? var A = (applet.getValue("accuracy") == applet.getValue("acc"))? 1:0; // true/false var D = (A == 1)? 2:3; // true/false //var B = applet.getYcoord("C"); // from GeoGebra, 'b' to Webwork? or JS? getQE('A').value = applet.getValue("accuracy"); // Send value to ww getQE('D').value = applet.getValue("acc"); // Send value to ww //getQE('B').value = applet.getYcoord("C"); // Send value to ww return(A); //return(B); } </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, ))); ####################################### # TEXT ####################################### Context()->texStrings; BEGIN_TEXT$BR
Enter the value you see in the text.$BR$BR
$BR$BR
$BR$BR
$$\quad \quad \quad \quad \quad \quad \quad \quad accuracy$$ = \{NAMED_ANS_RULE("A", 5)\} Compared against \{$accin\}$PAR
$BR $$\quad \quad \quad \quad \quad \quad \quad \quad 2nd entry$$ = \{NAMED_ANS_RULE("D", 5)\} Compared against \{$accin\} $PAR END_TEXT # # # #$$\quad \quad \quad \quad \quad \quad \quad \quad \quad$$number entry = \{NAMED_ANS_RULE("A", 10)\}$PAR
# CenterX = \{NAMED_ANS_RULE("Ax", 20)\} $PAR #CenterY = \{NAMED_ANS_RULE("Ay", 20)\}$PAR
#Radius_squared = \{NAMED_ANS_RULE("radius_squared", 20)\} $PAR #TEXT($PAR, "foostate |", $inputs_ref->{ "${appletName}_state"}, "|");

#TEXT( "run SetConfig", q!<script language="javascript">setConfig()</script> !) if $inputs_ref->{ "${appletName}_state"} =~ "restart_applet";

#TEXT( "run SetConfig", q!<script language="javascript">setConfig()</script> !) if $inputs_ref->{ "${appletName}_state"};

#########################################
#########################################
#$$\quad \quad \quad \quad \quad \quad \quad \quad \quad$$Coordinate $$x$$ = $$\quad$$\{NAMED_ANS_RULE("A", 5)\} Should be \{$a\}$PAR

#NAMED_ANS( 'Ax' => Real($a1)->cmp ); #NAMED_ANS( 'Ay' => Real($b1)->cmp );
#NAMED_ANS( 'radius_squared' => Real($r2)->cmp ); # Compares student entry in ggb with WW passed variable NAMED_ANS( 'A' => Real($accin)->cmp );
NAMED_ANS( 'D' => Real($acc)->cmp ); #NAMED_ANS( 'B' => Real($b)->cmp );
#Compares WW with WW
NAMED_ANS( 'answerBox' => Real($answer)->cmp ); #NAMED_ANS( 'answerBox' =>$ansb->cmp );

#######################################
sub GEOGEBRA_PARAMS {
my $result = { showResetIcon=>"false" , enableRightClick=>"false" , enableLabelDrags=>"false", showMenuBar=>"false" , showToolBar=>"false", showAlgebraInput=>"false", useBrowserForJS=>"true", ggbbase64=>"UEsDBBQACAgIAFeH1kwAAAAAAAAAAAAAAAAWAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc0srzUsuyczPU0hPT/LP88zLLNHQVKiu5QIAUEsHCEXM3l0aAAAAGAAAAFBLAwQUAAgICABXh9ZMAAAAAAAAAAAAAAAAFwAAAGdlb2dlYnJhX2RlZmF1bHRzMmQueG1s7VrfU9s4EH6+/hUaP909kNiOnQSG0KGdubnOUHpzMJ17VeyNo0ORfJJMHP76yvLPkJgGB0qg5QFrFWklfftpvVr59H26oOgWhCScTSynZ1sIWMBDwqKJlajZ0dh6f/buNAIewVRgNONigdXE8rOWVT8t9bzRIKvDcTyxAoqlJIGFYopV1mVihRZCqSQnjF/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ers?

by tim Payer -

A Partial success with a working model.

By comparing strings passed from an embedded GeoGebra applet to WeBWorK we were able to use a customized answer checker to solve our problem. To review: An embedded GeoGebra applet prompts students to click and drag 13 coordinate points for vertical placement for a connected line plot that approximates the sketch of the derivative overlaid a graph of the parent function. The string that is passed from GeoGebra is an accuracy score with an affixed percentage (for example 73%). The passed string has its percentage stripped within the custom answer checker which permits the remaining integer to be evaluated within a series of intervals that return comments and appropriate scores to the student.

We recognize that there is probably a more elegant way to create such a problem. But we could not get numeric values to pass from GeoGebra with any success and have settled on this stripped string custom answer checker.

Our Questions:

1.) Is there a way to pass numeric values from GeoGebra and assign them to a WeBWorK variable? We have not found any way to manage this.

2.) We would like to have greater control of the resulting score passed from GeoGebra to WeBWorK such that a score of 78% achieved in the applet is awarded 78% of the possible points in WeBWorK. Currently that 78% is rounded up to next multiple of 5 at 80% with our custom answer checker. Short of writing 100 individual answer checkers, is there a way to accomplish this?

3.) Sadly we could not work our way around the overlapping text issue that resulted from the latest version of GeoGebra. We try to use Mike Gage’s hot fix #354 but were not successful. How are the corrective lines below to be used? Is it not in the problem itself?
We are ww subscribers if this matters.

hot fix #354:
<div class = “enclose_geogebra_object”>
<div class = “geogebra_object”>
<script language=”javascript”>

</div>
</div>

Any feedback is most appreciated!

Tim

## This Homework problem uses an embedded GeoGebra applet

## that prompts the student to manipulate the vertical placement

## of 13 coordinate points in order to approximate the sketch of the

## derivative for a given graph of a function.

## The GeoGebra applet "scores" the student's attempt and this score

## must be passed back as a score to the WEBWorK answer checker.

## The GeoGebra applet was written by Professor Marc Renault and used here

## with permission. Check out his website for this and other GeoGebra applets

## related to first year Calculus courses:

## http://webspace.ship.edu/msrenault/GeoGebraCalculus/derivative_try_to_graph.html

DOCUMENT();

"PGstandard.pl",

"MathObjects.pl",

"PGinfo.pl",

"unionTables.pl",

"AppletObjects.pl",

"contextArbitraryString.pl",

"PGcourse.pl",

);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1; Context("Numeric"); ################################# # Only a "correct" answer variable is declared as a string # for comparison for the upper threshold of # " > 95%" for a variable declaration ################################# Context("ArbitraryString");$cor ="> 95%"; # Accuracy above 95% is awarded 100%

Context("Numeric");

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

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

# 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 = "numberTest";$applet = GeogebraWebApplet(

code => "geogebra.GeoGebraApplet",

archive => "geogebra.jar",

codebase => findAppletCodebase("geogebra.jar"),

appletName => $appletName, appletId =>$appletName,

submitActionAlias => 'getAppletValues', # default actionAlias

initializeActionAlias => '', # default actionAlias

setStateAlias => 'setXML',

getStateAlias => 'getXML',

setConfigAlias => '',

getConfigAlias => '',

returnFieldName => '',

width => 700, # may want to modify width

height => 300, # 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" takes the student submission in a geogebra applet

# and passes it to webwork: getQE() is a webwork call for geogebra submission?

# A general case of retrieving all values() vs the specific cases "a" and "b"

# is shown below. The specific cases are commented out.

submitActionScript => qq{ getQE('answerBox').value = getAppletValues() },

#submitActionScript => qq{ getQE('answerBox').value = applet.getValue("a") },

#submitActionScript => qq{ getQE('answerBox').value = applet.getValue("b") },

params => GEOGEBRA_PARAMS(), # paste parameters in

);

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

# For setting initial values in GeoGebra from WeBWorK

# Uses JavaScript interface to GeoGebra.

# hotfix #354 via Mike Gage addressing the overlapping text

# with WeBWorK submission buttons was attempted and disgarded below.

# Affixed protective <div>s to prevent overlapping text, could not be fixed

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

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: One could assign the commented values of "a" and "b" in GeoGebra to the WeBWorK variables$a & $b here. But this problem passes nothing from ww to ggb as it relies upon the student's manipulation of the applet and the resulting score to be passed back to WeBWorK. The commented examples below are just kept as a reference for future problems... */ // applet.setValue("a",$a);

// applet.setValue("b", $b); // applet.setCoords("C",$a, $b); } else { setTimeout("setAppletCoefficients()", 1000); } } else { setTimeout("setAppletCoefficients()",1000); } } ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()};

</script>

END_SCRIPT

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

# Setup GeogebraWebApplet --

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

<script language="javascript">

function ggbOnInit(param) {

var applet = document.$appletName; if (param == "$appletName") {

ww_applet_list[param].safe_applet_initialize(2);

ww_applet_list[param].object = param;

console.log("ggbOnInit: ww_applet_list["+param+"].object = ", ww_applet_list[param].object );

}

}

</script>

END_SCRIPT

<script language="javascript">

function setConfig() {

var appletState = getQE('${appletName}_state').value; if (ww_applet_list['$appletName'].object == undefined ) {

setTimeout("setConfig()", 5000);

console.log("waiting");

} else {

var applet=$appletName; } } </script> END_SCRIPT HEADER_TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function getAppletValues() { console.log("getAppletValues() entered"); // get a handle for the applet object var applet =$appletName;

var D = applet.getValueString("text1"); // from ggb, accuracy to ww

/* The getQE ("Get Question Element") places the GeoGebra value in a

ww answer box as long as the supporting code is there to support the

box entry. But here we want the box to be invisible and for ggb to pass

the accuracy score to ww for comparison.

*/

// getQE('D').value = applet.getValueString("text1"); //Send value to ww

return(D); // Needed for ww to receive value D from ggb

}

</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,

)));

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

# TEXT

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

#$ans7 =~ s/%/ppp/; #$dum =~ s/ %//;

#$dum =~ s/> //; #$ans6=~'answerBox';

Context()->texStrings;

BEGIN_TEXT

$BR$BR

$BR$BR

$BR$BR Click and drag each purple coordinate point to make a sketch of the

$BR derivative based upon the slope of the parent function in black.$BR Use the slider to determine the slope of the tangent line

$BR as an aid to approximate the sketch of the derivative.$BR

END_TEXT

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

## This answer checker takes ggb string 'D' as $s, "student input" ## and compares it to a ww string ($cor) after a strip ( a search and replace)

## of the non-numeric symbols of "%", ">", and " ". The stripped ww string "$cor" ## is assigned to "$c" for "correct", from ww.

## The PostFilter answer hint permits the stripped strings

## to be evaluated as Numeric intervals for Student feedback and scoring...

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

Context("ArbitraryString");

NAMED_ANS( 'answerBox' => String($cor)->cmp->withPostFilter(AnswerHints( sub { my($c, $s,$self) =@_;

$c =~ s/> //; ## Stripping "> " of "> 95%", leaving "95%"$c =~ s/%//; ## Stripping "%" of "95%", leaving "95"

$s =~ s/%//; ## Stripping "%" of the student accuracy, leaving an integer return (($s >= 0) && ($s <= 50)); } => ["Oh no! You must score more than 50%, for any credit. Try again.", score => 0], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 50) && ($s <= 60)); } => ["You could do better with another attempt, yes?", score => 0.60], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 60) && ($s <= 70)); } => ["Try again. You can manage better than this.", score => 0.70], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 70) && ($s <= 75)); } => ["This is okay, But you could do better, yes?", score => 0.75], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 75) && ($s <= 80)); } => ["You are getting better, Try another?", score => 0.80], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 80) && ($s <= 85)); } => ["Nice Work!", score => 0.85], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 85) && ($s <= 90)); } => ["Very Good!", score => 0.90], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return (($s > 90) && ($s <= 95)); } => ["Excellent!", score => 0.95], sub { my($c, $s,$self) =@_;

$c =~ s/> //;$c =~ s/%//;

$s =~ s/%//; return$s > $c; } => ["Perfect!", score => 1], ))); ####################################### sub GEOGEBRA_PARAMS { my$result = {

showResetIcon=>"false" ,

enableRightClick=>"false" ,

enableLabelDrags=>"false",

showToolBar=>"false",

showAlgebraInput=>"false",

useBrowserForJS=>"true",

};

$result; } ENDDOCUMENT(); In reply to tim Payer ### Re: Passing GeoGebra values to WeBWorK as "correct" answers? by tim Payer - Greetings: We have cleaner version of the embedded GeoGebra applet here. While this version is an improvement we still are resigned to using strings as passed values from GeoGebra to WeBWork. This requires using a custom answer checker with which to check for the string to fall within an interval for a response and score for the student. Is there a way in which we could pass numerical values from GeoGebra and assign these values to a variable in WeBWorK for an answer check comparison? Thanks for any consideration. Tim In reply to tim Payer ### Re: Passing GeoGebra values to WeBWorK as "correct" answers? by Danny Glin - I don't know anything about the GeoGebra embedding, but if you are able to pass the string back to WeBWorK, you should be able to convert that to a number and use that in a custom answer checker. I would expect it to work if you replaced "score => 0.60" with "score =>$s/100" in each of your cases to get the exact score.

In fact, you should be able to use the following checker to simply set the student's grade to the accuracy:

NAMED_ANS( 'answerBox' => String($cor)->cmp( checker=>sub { my($c, $s,$self) =@_;
$c =~ s/> //; ## Stripping "> " of "> 95%", leaving "95%"$c =~ s/%//; ## Stripping "%" of "95%", leaving "95"
$s =~ s/%//; ## Stripping "%" of the student accuracy, leaving an integer return$s/100;
}));

This still requires a custom answer checker since the student answer is passed to WeBWorK as a string, but it should get you around needing cases for each score.

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by tim Payer -
Thank you Danny,

The individual replacement suggestion of "score => 0.60" with "score => $s/100" did not work within the PostFilter AnswerHints. However your individual code block for the problem did work nicely, but only in our earlier versions. NAMED_ANS( 'answerBox' => String($cor)->cmp( checker=>sub {
my( $c,$s, $self) =@_;$c =~ s/> //; ## Stripping "> " of "> 95%", leaving "95%"
$c =~ s/%//; ## Stripping "%" of "95%", leaving "95"$s =~ s/%//; ## Stripping "%" of the student accuracy, leaving an integer
return $s/100; })); The later versions use a "Submit" button within the GeoGebra applet, but even if we take this out the "Check Answer" and "Correct Answer" box are non-responsive within WeBWorK. Thanks for your help but I think we have a new glitch to solve. Could it be the case of overlapping text that is the problem? Hopefully some one can see the glitch that we can not... Thanks, tim In reply to tim Payer ### Re: Passing GeoGebra values to WeBWorK as "correct" answers? by Michael Gage - I've put these examples up at: So you can see how it works. Login as guest. You can also view the source code. The most important point is that problems 2 and 3 have the value "debug" set to 1 (or 2). This makes the hidden answerBox visible, it also makes the hidden input box that stores the state of the geogebra applet visible (and supposedly resets it so that the geogebra applet is persistent from one viewing to another). The latter feature doesn't seem to be working -- I haven't investigated it. Having debug on allows you to more closely examine the output being created by the applet. By looking at the XML representing the state of the geogebra applet you can get a good idea of what objects it has and what the names of the objects are. Apparently it's not easy to get just a value from geogebra without the label. Instead of 48 you always get acc = 48 where acc is the label of the value. The promised fix for this getRHSValueString hasn't materialized. There was another reference that suggested a solution -- but it hasn't worked for me: I wasn't able to get Danny's solution to work either --$s/100 complained about dividing a string by a number. I think it is a message from the "ArbitraryString" context.

What did work for me was to trim the string in javaScript:

var D = applet.getValueString("acc"); // from ggb, accuracy to ww
D = D.match(/\d+/);
return(D);

this returns only the number in "acc = 79"

and then for the answer checker I used

NAMED_ANS( 'answerBox' => String($cor)->cmp( checker=>sub { my($c, $s,$self) =@_;
$c =~ s/> //; ## Stripping "> " of "> 95%", leaving "95%" $c =~ s/%//; ## Stripping "%" of "95%", leaving "95"
#$s =~ s/%//; ## Stripping "%" of the student accuracy, leaving an integer $s1 = Real("$s"); return$s1 > $c; # returns 1 or 0 })); I'm not sure whether the Real() operator is needed there. You can also add messages as you did in an earlier example.  Problem 3 in the site also illustrates how you could obtain all of the coordinants of the spline from the geogebra applet -- and then do all of the checking calculations in webwork. I'm not sure whether or not that would be easier than doing the checking in the applet but it would be easier to modify. That way you could have one all purpose applet and use it for many different problems -- checking the spline differently in each case. Still not sure why the geogebra app is not persistent from one viewing to the next -- are you generating randomness within the geogebra app without relying on the problem's seed? Do you want the app to behave that way? In reply to Michael Gage ### Re: Passing GeoGebra values to WeBWorK as "correct" answers? by tim Payer - Thank you Mike! We will pour over your detailed instructions. I am taking about a 10 day break from the office but will be back mid-July to work through this. We really want the GeoGebra-WeBWorK interface to be a workable solution. Thanks for giving us such detailed feedback! Tim In reply to tim Payer ### Re: Passing GeoGebra values to WeBWorK as "correct" answers? by Andrew Parker - Tim- I've got some suggestions for this problem, but I'll try to relay them in such a way as to provide broader assistance for working with GeoGebra embedding in WeBWorK more generally: 1) Make sure you have access to an editable GeoGebra file - the objects in the GeoGebra construction are vital to being able to "pull" data from the applet in order to grade student work. (This is irrelevant if you create your own applets, but crucial if you're using someone else's... I searched Marc Renault on geogebra and found his construction for this applet - without that, I wouldn't have been able to "fix" this particular applet to work with WeBWorK) 2) Looking at Marc's construction, he has a different context for his applet - so re-randomization only happens when a student explicitly clicks on "reset". In WeBWorK, every time a student submits their work, the function will be re-randomized and the student will have to start from scratch. We'd like to generate values for the function and use those - to maintain persistence on the part of repeated attempts by the student. Breaking down Marc's construction, he's fitting a curve to 9 randomly selected points with fixed x-values: {-12, -9, -6, ... 12} with integer-valued y-coordinates in [-2,3]. 3) I've made a copy of the original construction and revised it for use with WeBWorK: ( https://ggbm.at/j36pqyuk ) I've replaced his randomization of the points with fixed points (R through Z) for which WeBWorK can assign values. (You can get the ggbbase64 from the linked page, I believe) 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

// Replace the randomization on-load of the applet
applet.evalCommand("R = (-12, $y[0])"); applet.evalCommand("S = (-9,$y[1])");
applet.evalCommand("T = (-6, $y[2])"); applet.evalCommand("U = (-3,$y[3])");
applet.evalCommand("V = (0, $y[4])"); applet.evalCommand("W = (3,$y[5])");
applet.evalCommand("X = (6, $y[6])"); applet.evalCommand("Y = (9,$y[7])");
applet.evalCommand("Z = (12, $y[8])"); applet.evalCommand('SetVisibleInView[gRes,1,False]'); applet.evalCommand('SetVisibleInView[btnReveal,1,True]'); } else { setTimeout("setAppletCoefficients()", 1000); } } else { setTimeout("setAppletCoefficients()",1000); } } ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()};
</script>
END_SCRIPT

applet.evalCommand("..."); is going to be an important tool when working with GeoGebra applets in WeBWorK. By placing these commands in the setAppletCoefficients() subroutine, they get called whenever the applet is initially loaded. (This subroutine is _not_ called when a student submits their answer, but it _is_ called if a student uses the reinitialize_button)

In this case, I have set up a loop to generate the y-coordinates for these 9 points, and I'm assigning them to the points R through Z (which already exist in the geogebra construction, I'm just updating their values to match the WeBWorK randomization)

foreach my $i (0..8) {$y[$i] = random(-2,3,1); } Finally, there are two evalCommand statements at the end which 'reset' the visibility of the "reveal" button, and hide the visibility of the graph of f'(x). This ensures that students must completely reset the applet before they can receive credit for the problem. (i.e. they cannot reveal the graph of f'(x), then drag the points to match, then hide the graph of f'(x) before submitting...) I "borrowed" these two commands verbatim from the 'onClick' scripting of the "reset" button in the original GeoGebra construction. 4) The getAppletValues() subroutine is where you want to pull only the relevant information for assessing student work. If you do not know the names of the objects in the GeoGebra construction, you have no shot at being able to do this. In your early attempts, you were pulling some of the text strings from the construction - when what you really wanted to pull was the numeric variable "accuracy" HEADER_TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function getAppletValues() { console.log("getAppletValues() entered"); // get a handle for the applet object var applet =$appletName;
var accuracy = applet.getValue("accuracy");
var isVisible = applet.getVisible("btnReveal",1);
return( accuracy + "," + isVisible );
}
</script>
END_SCRIPT

Here, I am pulling the value of "accuracy", as well as the visibility of the "Reveal" button (boolean: true/false) - and then the return statement is a javascript string (using "+" instead of "." as in perl) to return a string containing my relevant information, separated by a comma.

In general, this is my preferred mode of retrieving values from a GeoGebra applet - assign javascript variables for everything I want, then return them as a comma separated list.

We now need a custom answer checker to split these relevant pieces of information and evaluate them:

$custom = sub { my ($correct, $student,$self) = @_;
my ($acc,$eligible) = split(/,/,$student,2); return ($eligible eq 'true' && $acc > 95); }; I have added both 'true' and 'false' to the problem Context() as strings, so that WeBWorK doesn't complain when receiving this input as the student answer. Notice that we're testing to make sure that the student hasn't revealed the graph of f'(x) when they submit their answer - this would be a rather easy problem otherwise... The use of split( /,/, <string>, max partitions ); turns our "return" string from the JavaScript into an array from which we can evaluate the pieces separately. As I mentioned above, this is my preferred method of passing information from GeoGebra to WeBWorK - the only change will be the maximum number of partitions (if I want to pass more parameters). The "correct" answer being passed to the checker is a list containing a numeric value and a string:$answer = List(Real(100),String('true'));

NAMED_ANS( 'answerBox'=>$answer->cmp(checkTypes=>0, checker=>$custom) );

Again, I added the strings 'true' and 'false' to the context.

Context("Numeric");

I hope all this has been enlightening, and best of luck as you continue working with GeoGebra and WeBWorK!

-Andrew

PS: I recommend using https://wiki.geogebra.org/en/Reference:GeoGebra_Apps_API as a reference for what you can do in both the setAppletCoefficients() and getAppletValues() subroutines.

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by Andrew Parker -

For example:

$custom = sub { my ($correct, $student,$self) = @_;
my ($acc,$eligible) = split(/,/,$student,2); Value::Error("You need to reset the construction and try the problem without looking at the graph of $$f'(x)$$.") if ($eligible eq 'false');

# set other messages for various ranges of accuracy

$partialCredit = ($acc > 95)? 1 : $acc/100; # full credit if > 95 accuracy return ($partialCredit );
};

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by Andrew Parker -
I've also attached my working version of this problem, if that's any further help.

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by tim Payer -
Thank you Andrew for the remaking of the "randomized-derivative-graph".

We will be spending the week digesting this and your previous post on this problem.

We are getting some warning messages with the version you posted though:

### ------auxiliary file line-intercepts-multians.png missing resource path ------The macro alias cannot find the file: |line-intercepts-multians.png| anywhere------The macro alias was unable to form a URL for the auxiliary file |line-intercepts-multians.png| used in this problem.

This does not seem to prevent the problem from working, but is there something we can/should do to address these warnings?

Thanks for the detailed feedback....Tim

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by tim Payer -
Andrew,

I understand that the warning message that I received is just for the lack of an image for this problem for where it is stored. But since each student would be receiving a randomized version of the parent function how would an image be created and then stored for the hard copy version of this problem?

This is only a secondary problem as we are still digesting your version of a persistent function for this problem. Thanks again for the work on this.

Tim

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by Andrew Parker -
Tim-

Yes, that is a leftover reference to a static image from a prior WeBWorK/GeoGebra problem that I used as a foundation for helping you with your question.

I've now updated this code to dynamically generate an image for each randomization via the AskSage functionality of WeBWorK. (This was actually my first attempt at using AskSage in WeBWorK, so thank you for the inspiration )

The code is attached here, but essentially the additions include querying Sage (to do what GeoGebra is also doing - ugh, redundancy) but I don't know how to retrieve the fitted polynomial from GeoGebra before the problem has even been attempted. So instead, Sage and some Python are used to retrieve (and reasonably format) our polynomial. That polynomial is then added to an image (for hardcopy), and its derivative is added to a second image that is displayed in the solution.

Let me know if you have any questions about the code, I'd be happy to clarify wherever necessary.

-Andrew

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by tim Payer -
In Response to your last Question of the embedded GeoGebra applet.

Our intention for the applet was for the student to submit a score for an attempt by first clicking on "Submit" within the applet, and have the resulting score passed to WeBWorK. But the applet should "persist" with its current function by showing the student the accuracy score that was just submitted and the sketch of the derivative. The student could then experiment with the placement of points to see how this improve the accuracy within the applet, but any improved scores would not be passed on to WeBWorK unless the "Reset: button was hit to re-attempt a new problem.

It seems that this is not working as intended now, but it was last week?

I am not sure how we can rely upon the "problem seed" value and how this permits the applet to persist until the "Reset" button is hit.

Tim

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by tim Payer -
Thank you Michael,

But we still have a problem running the code from the code source examples you posted. Specifically it is the overlapping text and "Check Answer" buttons that were created from the latest version of GeoGebra. The hot fix of #354 we were not sure of where to place to amend our code.
Given that we are subscribers, does limit us for applying this fix?
If not, how can we apply this fix for the GeoGebra overlap?

Thanks, Tim

### Re: Passing GeoGebra values to WeBWorK as "correct" answers?

by Michael Gage -
The hotfix #354 was merged into the master branch on May 31. (It was also merged into the develop version). If you update your server installation
using git (this usually can be done with some variation of