Forums

Search results: 163

The most important thing is to set MaxConnectionsPerChild to something greater than 0 (i.e. not unlimited). I use 100, but 50 is also a good choice if you're running a lot of gateway quizzes.
With 32GB of RAM you can probably leave MaxRequestWorkers at 150, but if you continue to run into trouble that would be the value to lower.

In terms of students logging off, that should make no difference to WW performance. The server is only working when a page is loaded, so a student having an active session shouldn't have any effect.

The idle time before a student is logged out is controlled by the variable $sessionKeyTimeout, which defaults to 30 minutes. You can increase that by overriding this variable in localOverrides.conf. Just note that it is measured in seconds, so to set the timeout to 60 minutes you would use
$sessionKeyTimeout = 60*60;

It's worth noting that the timeout resets every time a page is loaded, so if a student clicks "preview answers" it will refresh their session. It's also worth encouraging the students to preview often when working on a gateway quiz because this saves their answers to the database, which means they can be restored if the student has computer problems, and also can be accessed if a student doesn't submit in time.
I tried the Gateway quiz with a short quiz I had used to test timing for students in class of 45 - to see if that many students wold slow the Webwork server. I had included an interactive graphics problem, (move vectors to the correct location on a graph).
The graphics part was coded using Geogebra. The problem was that the answers to the graphics part were not recorded. The answers to the submit a number and use the drop-down menu for multiple choice worked OK. But the answer was recorded as if the graphics were totally wrong. The problem worked well when given in a short timed test as a homework type. But the same problem as a Gateway quiz didn't record the graphics answers - it drew the graph and allowed movement of the vectors OK, but when the student submitted no record of the graphic input.

The code is below

## DESCRIPTION
# Problem for 'NCSU ECE451 Lu'.
# WeBWorK problem written by H. J. Trussell, <hjt@ncsu.edu>
# ENDDESCRIPTION

## DBsubject(Electrical Engineering)
## DBchapter(CHAPTER 3 The Synchronous Machine)
## DBsection(NA)
## Institution(North Carolina State University)
## Autho(H. J. Trussell)
## TitleText1('Fundamentals of Applied Electromagnetics')
## AuthorText1('John Grainger, Jr.', 'William Stevenson ')
## EditionText1('1')
## Problem1('3.3')
## Keywords('three-phase synchronous generator')
## Resources()

DOCUMENT();

loadMacros("PG.pl",
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"PGinfo.pl",
"AppletObjects.pl",
"PGcourse.pl", # Customization file for the course
"parserPopUp.pl",
"AnswerFormatHelp.pl",
"answerHints.pl",
);

TEXT(beginproblem());

Context("Complex");
Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);

Context()->variables->are(t=>'Real');
Context()->{format}{number} = "%.4f#";

#Initialize values, to be changed for each question
$Xd = Real(random(1,1.5,0.1)); # pu
#$Va_Mag = Real(random(1,2,0.2)); # V
$Va_Mag = Real(1.0); # V
$Va_Ang = 0;
$Ia1_Mag = Real(random(1,2,0.2)); # A
$Ia1_Ang = Real(random(20,40,5)); # degrees
$Ia2_Mag = Real(random(1,2,0.2)); # A
$Ia2_Ang = 0; # degrees
$Ia3_Mag = Real(random(1,2,0.2)); # A
$Ia3_Ang = -$Ia1_Ang; # degrees

# default values for checking
#$Xd = Real(1.65); $Va_Mag = Real(1); $Ia1_Mag = Real(1); $Ia1_Ang = Real(30); #$Ia2_Mag = Real(1); $Ia3_Mag = Real(1);

# Answer calculation
$Ia1_Ang_rad = Compute($Ia1_Ang*pi/180);
$Ei1 = Compute($Va_Mag*exp(j*$Va_Ang) + $Ia1_Mag*$Xd*exp(j* ($Ia1_Ang_rad + pi/2)));
$I_Xd_prod = Compute($Ia1_Mag*$Xd);
$I_Xd_Ang = Compute($Ia1_Ang + 90);
$Ei1_Mag = Compute(abs($Ei1));
$Ei1_Ang = Compute(arg($Ei1));
$Ei1_Ang_deg = Compute($Ei1_Ang*180/pi);

$Ia2_Ang_rad = Compute($Ia2_Ang*pi/180);
$Ei2 = Compute($Va_Mag*exp(j*$Va_Ang) + $Ia2_Mag*$Xd*exp(j* ($Ia2_Ang_rad + pi/2)));
$I_Xd_prod2 = Compute($Ia2_Mag*$Xd);
$I_Xd_Ang2 = Compute($Ia2_Ang + 90);
$Ei2_Mag = Compute(abs($Ei2));
$Ei2_Ang = Compute(arg($Ei2));
$Ei2_Ang_deg = Compute($Ei2_Ang*180/pi);

$Ia3_Ang_rad = Compute($Ia3_Ang*pi/180);
$Ei3 = Compute($Va_Mag*exp(j*$Va_Ang) + $Ia3_Mag*$Xd*exp(j* ($Ia3_Ang_rad + pi/2)));
$I_Xd_prod3 = Compute($Ia3_Mag*$Xd);
$I_Xd_Ang3 = Compute($Ia3_Ang + 90);
$Ei3_Mag = Compute(abs($Ei3));
$Ei3_Ang = Compute(arg($Ei3));
$Ei3_Ang_deg = Compute($Ei3_Ang*180/pi);

$Xd_Ang_rad_1 = Compute($Ia1_Ang_rad + pi/2);
$answer1 = Real(60*60/(4/2));
$popupA = PopUp(["?", "increase", "decrease","remain the same"], "decrease");

$popupB = PopUp(["?", "increase", "decrease","remain the same"], "increase");



$answer = Compute("($Ia1_Mag,$Ia1_Ang_rad,$Ei1_Mag,$Ei1_Ang)");
@tol=(0.5,pi/60); # Magnitude Tolerance 0.1, Angular Tolerance 3 degrees
@type=(0,1,0,1,0,1); #0 for magnitude value, 1 for angular value in degrees


######################################
# 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 => '', # default actionAlias
setStateAlias => 'setXML',
getStateAlias => 'getXML',
setConfigAlias => '',
getConfigAlias => '',
returnFieldName => '',
width => 700, # may want to modify width
height => 700, # 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() },
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

} else {
setTimeout("setAppletCoefficients()", 1000);
}
} else {
setTimeout("setAppletCoefficients()",1000);
}
}
ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()};

</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 Iam = applet.getValue("Iam");
var Iaang= applet.getValue("Iaang");
var Eim = applet.getValue("Eim");
var Eiang= applet.getValue("Eiang");
return(Iam + ',' +Iaang +','+Eim + ',' +Eiang);
}
</script>
END_SCRIPT


BEGIN_TEXT
Find the rotor speed of a 4-pole generator to generate 60Hz 3-phase power: $BR
a) Speed is \{ans_rule(10)\} \(RPM\) \{AnswerFormatHelp("numbers") \} $BR
b) A generator is supplying a 100 MW load. If we increase the load to 105MW, the system frequency (i.e., the rotor speed) will \{$popupA->menu()\} $BR
c)A generator is supplying a 100MW load with a power factor at 1.0. If the power factor drops to 0.9 lagging (power is still 100 MW), the excitation current (\( I_f\)) will \{$popupB->menu()\} $PAR
In the graph below, move point C (\(E_i\)) to (0.44,1.20). Move the red vector (\(Ia\)) to (1.09,0.51). You can move each phasor by clicking on its arrow head and dragging it around. The vector values indicated beside the vectors are represented in polar coordinates, as are the answers in the answer-checker. $BR
END_TEXT
Context()->normalStrings;

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

##############################
$showPartialCorrectAnswers = 1;
#ANS($Ei1->cmp());
#ANS($Ei2->cmp());
#ANS($Ei3->cmp());

ANS($answer1->cmp());
ANS($popupA->cmp());
ANS($popupB->cmp());

# NAMED_ANS( 'answerBox' => $answer->cmp(ordered=>1) );

NAMED_ANS( 'answerBox' =>$answer->
cmp(list_checker => sub {
my ($correct,$student,$ansHash,$value) = @_;
my $n = scalar(@$student); # number of student answers
my $score = 0; # number of correct student answers
my @errors = (); # stores error messages
my $i; # loop counters
#
# Loop though the student answers
##
for ($i = 0; $i < $n; $i++) {
my $err,$errt;
my $ith = Value::List->NameForNumber($i+1);
my $p = $student->[$i]; # i-th student answer
my $a = $p->value;
my $q = $correct->[$i]; # i-th student answer
my $b = $q->value;
if ($type[$i]==0){
$err=abs($a-$b)
}
if ($type[$i]==1){
$errt=abs($a-$b);
$err=min($errt,360-$errt);
}

if ($err<$tol[$type[$i]] ) {$score++} else {
push(@errors,"Your $ith point is not correct") unless $ansHash->{isPreview}
}
}
return ($score,@errors);
}));

##############################
# Solution

Context()->texStrings;
BEGIN_SOLUTION;

$PAR
$BBOLD SOLUTION $EBOLD
$PAR
\( E_i \angle 0^{ \circ } = V_a \angle 0^{ \circ } + I_a \angle \theta \times X_d \angle 90^{ \circ } \) $BR
\( = $Va_Mag \angle 0^{ \circ } + $Ia1_Mag \angle \theta \times $Xd \angle 90^{ \circ } \) $BR
\( = $Va_Mag \angle 0^{ \circ } + $I_Xd_prod \angle (90^{ \circ } + \theta) \) $PAR

a) \(\theta = $Ia1_Ang^{ \circ } \) $BR
\( E_i = $Va_Mag \angle 0^{ \circ } + $I_Xd_prod \angle $I_Xd_Ang ^{ \circ }\) $BR
\( E_i = $Ei1 = $Ei1_Mag \angle $Ei1_Ang_deg^{ \circ } \) per unit $PAR

b) \(\theta = $Ia2_Ang^{ \circ } \) $BR
\( E_i = $Va_Mag \angle 0^{ \circ } + $I_Xd_prod2 \angle $I_Xd_Ang2 ^{ \circ }\) $BR
\( E_i = $Ei2 = $Ei2_Mag \angle $Ei2_Ang_deg^{ \circ } \) per unit $PAR

c) \(\theta = $Ia3_Ang^{ \circ } \) $BR
\( E_i = $Va_Mag \angle 0^{ \circ } + $I_Xd_prod3 \angle $I_Xd_Ang3 ^{ \circ }\) $BR
\( E_i = $Ei3 = $Ei3_Mag \angle $Ei3_Ang_deg^{ \circ } \) per unit $PAR

END_SOLUTION
Context()->normalStrings;


sub GEOGEBRA_PARAMS {
my $result = {
showResetIcon=>"false" ,
enableRightClick=>"false" ,
enableLabelDrags=>"false",
showMenuBar=>"false" ,
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",
allowRescaling=>"false",
enableShiftDragZoom=>"false",
#geogebra work sheet link https://ggbm.at/stSsYPfV
ggbbase64=>"UEsDBBQACAgIAHJlUU0AAAAAAAAAAAAAAAAXAAAAZ2VvZ2VicmFfZGVmYXVsdHMyZC54bWztmltv2zYUx5/XT0HoaXuILcl27ARRirTAsAJpGixBsVdaOpa50KRGUrGcT1+KlHWpL3MUd04z5yHUkXkRf/+jw0NJF++zGUWPICThLHC8jusgYCGPCIsDJ1WTk5Hz/vLdRQw8hrHAaMLFDKvAGeQ1y3ba6vTPRvk5nCSBEwucTHUXDkooVnmbwOGTCSUMHIQySc4Zv8EzkAkO4S6cwgxf8xAr09lUqeS8253P553lsB0u4m4cq04mIwfpS2YycIqDc91do9G8Z6r7rut1//p8bbs/IUwqzEI9vp5OBBOcUiX1IVCYAVNILRIInIQTphxE8Rho4NzmFvp1IgB+c1DRSFNynct3v1zI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AAAAAAAAAAACEFAABnZW9nZWJyYV9kZWZhdWx0czNkLnhtbFBLAQIUABQACAgIAHJlUU3WN725GQAAABcAAAAWAAAAAAAAAAAAAAAAAE8IAABnZW9nZWJyYV9qYXZhc2NyaXB0LmpzUEsBAhQAFAAICAgAcmVRTSztpoXdBwAACxwAAAwAAAAAAAAAAAAAAAAArAgAAGdlb2dlYnJhLnhtbFBLBQYAAAAABAAEAAgBAADDEAAAAAA="
};

$result;
}
ENDDOCUMENT();
With help from my LMS specialist, I managed to get LTI enabled for WW this year. The link redirects nicely from Blackboard, and appears to create accounts properly for student-level users. However, on first login (first click on the link), a warning shows up, and spams a large amount of information to screen. Reading it, I don't see what the error actually is.

If the user then refreshes, the warning goes away, and the WW interface appears to work correctly. Assignments show up, and everything proceeds.

Warning reproduced here, with a few personal identifiers removed for privacy. Any thoughts on what might be happening?

WeBWorK Warnings

WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.

Warning messages

  • ===== parameters received =======
  • tool_consumer_instance_description => Trent University
  • oauth_timestamp => 1567178935
  • oauth_consumer_key => ########
  • ext_launch_id => f76487d2-c705-4eb0-b21b-6c0666c0398c
  • roles => urn:lti:role:ims/lis/Instructor
  • oauth_version => 1.0
  • resource_link_title => Assignments for MATH 1051H - Login to 2019FA-MATH-1051H
  • oauth_callback => about:blank
  • tool_consumer_info_product_family_code => BlackboardLearn
  • ext_launch_presentation_css_url => ####,####
  • tool_consumer_instance_name => Trent University
  • oauth_nonce => 238585042538122
  • custom_student_id => ######
  • tool_consumer_info_version => 3700.7.0-rel.27+ce363ca
  • lis_person_name_full => Wesley Burr
  • oauth_signature => u0vTAJcY9dTgA3PCsGUmiAtHlHc=
  • lti_version => LTI-1p0
  • tool_consumer_instance_contact_email => admin@trentu.blackboard.com
  • lti_message_type => basic-lti-launch-request
  • lis_person_name_given => Wesley
  • ext_lms => bb-3700.7.0-rel.27+ce363ca
  • user_id => ####
  • oauth_signature_method => HMAC-SHA1
  • context_label => MATH-1051H-A-2019FA-PTBO
  • context_id => 28567d5abc8848a1a8e1dd03c717ce51
  • launch_presentation_return_url => https://trentu.blackboard.com/webapps/blackboard/execute/blti/launchReturn?course_id=_21698_1&content_id=_567651_1&toGC=false&launch_id=f76487d2-c705-4eb0-b21b-6c0666c0398c&link_id=_567651_1&launch_time=1567178935193
  • launch_presentation_locale => en-US-Trent
  • lis_person_contact_email_primary => ####@trentu.ca
  • resource_link_id => _567651_1
  • lis_person_sourcedid => #####
  • custom_tc_profile_url => https://trentu.blackboard.com/learn/api/v1/lti/profile?lti_version=LTI-1p0
  • launch_presentation_document_target => window
  • custom_caliper_federated_session_id => https://caliper-mapping.cloudbb.blackboard.com/v1/sites/0282b138-ab98-4eb0-8f63-9568b4756247/sessions/46E65784B38F830C810350FB74351F76
  • tool_consumer_instance_guid => f15628e23538475ca69eab852cb80ef5
  • lis_person_name_family => Burr
  • custom_caliper_profile_url => https://trentu.blackboard.com/learn/api/v1/telemetry/caliper/profile/_567651_1
  • context_title => MATH-1051H-A-2019FA-PTBO Non-Calculus Statistics I:
  • =========== summary ============ at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 213.
  • User id is |wesleyburr|
  • User mail address is |####|
  • Student id is |#####|
  • preferred_source_of_username is |lis_person_contact_email_primary|
  • preferred_source_of_student_id is |undefined|
  • ================================
  • The following path was reconstructed by WeBWorK. It should match the path in the LMS: at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 380.
  • https://math.trentu.ca/webwork2/2019FA-MATH1051H/ at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 381.

Request information

Time Fri Aug 30 15:28:55 2019
Method POST
URI /webwork2/2019FA-MATH1051H/
Canvas to Webwork Authentication Failure Resolved!

The issue was a new security feature that Canvas has added to their LTI connection. In years past an instructor could renew their Webwork subscription and then copy their Canvas course content over and re-use the same Consumer Key and consumer secret without any consequence of repeated use of the same names.

Now, with this Canvas security feature, copies of course content that are re-used by the same instructor or shared with another instructor will have the word "Fake" overwritten on the key, and "Secret has not changed" on the consumer secret.

To refresh the LTI connection one can either change the name of both, or one could use the same name again, provided that a new name is put in place and saved, then followed up with the old names for Key and Consumer secret and saved again.

What makes it tough for the instructor is that we are not permitted to access to see all this, so you might need to prompt your local Canvas tech to make the change for re-used course content using an LTI.

Whew, Tim

WeBWorK Problems -> Custom Error Messages Issue

by Brittni Lorton -
I am attempting to add a custom error message to a specific problem and I seem to be running into an issue. The answer to this is the string "None" but I want to allow students to be able to enter points without a strange error message throwing them off. Ideally what I want is:

  • If student enters a number -> an error message saying "Your answer is not a point"
  • If a student enters a point -> no extra error message, just "Incorrect"
Below is what I have so far. When I type a number in I get the desired message of "Your answer isn't a point", but the problem is that when I enter a point, the error message that still pops up is "Your answer isn't a number (it looks like a point)".
Any help would be greatly appreciated.

Thanks,
*Brittni


###########################
# Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",,
"parserAssignment.pl",
"AnswerFormatHelp.pl",
"PGML.pl",
"PGcourse.pl",
"contextLimitedPoint.pl",
);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

$refreshCaschedImages = 1;

##########################
# Setup
Context("Numeric");
Context()->variables->add(t => 'Real');

##Random variables for slope ##
$a=list_random(0,1);

##formulas for x(t) and y(t)##
Context()->noreduce('(-x)-y','(-x)+y');
$x_t=Formula("t+(1/t)")->reduce;
$y_t=Formula("t-(1/t)")->reduce;

Context("LimitedPoint"); ## Maybe this is needed to allow students to enter a point without an error message, even though the answer is "none" here.
$blank = Point("(1,2)");

$pointChecker = sub {
my ($correct,$student,$ansHash) = @_;
Value->Error("Your answer isn't a point.") unless $student->class eq "Point";
return 1;
};


#################################
##Main text##

BEGIN_PGML
Given the parametric curve

[` \displaystyle x(t)=[$x_t], \hspace{.25cm} y(t)=[$y_t] `].

Find all the points on the curve at which the slope of the tangent line is [`m=[$a] `].

Enter your solution as a comma separated list of ordered pairs [`(x,y)`] or if there are no points on the curve at which the slope of the tangent line is the given slope enter NONE.

[_______________________________] [@ AnswerFormatHelp("points") @]*


END_PGML

ANS(String("NONE")->cmp(checker=>$pointChecker)->withPostFilter(sub {
my $ans = shift;
$ans->{ans_message} = "Incorrect"
if $ans->{ans_message} eq "Your answer isn't a number (it looks like a point)";
return $ans;
}));


#################################
# Solution

#BEGIN_PGML_SOLUTION
#Solution explanation goes here.
#END_PGML_SOLUTION

COMMENT('Uses PGML.');

ENDDOCUMENT();
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/6RftOZ0bqyCpIDYLkTFAaErVUrV1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oWZ/IPTtm6vePiVXvd3W4R13oF06fJ4s1L2Ueq4sFHHmc0njOIqiILRvBpGbDKlggU8jKnwK418hCbmC8czWQ7uykY1k29WjfkT1WKpqjZzeKzUxKSxykj3bPfb/oqg08zIzcN5nzYlgv6q0lm+Hf6t1iv+ZQd4rYKsycraozlWiyaTS6gEDLPId95XXzvBOIeAeQGS2sfeHQXj+/eCIQQy+bZbpH8KtT//gjgOO3GuqnxYqrUySmblp9Dpa47p94jVnsbXYuA3YQ5P1W5OVcUD9wJdPDDyLpcmMqla7K5U7nFEMReOPF01+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
We are updating our WW very soon, so I can just wait until then to have the fix.

Now I am a bit curious about the problem level fix though (it certainly isn't a high priority though).

I did try including that snippet to inject the GeoGebra applet into the problem and it didn't seem to work. Below is the code with the change bold. Before the change, that bold snippet was:

TEXT($PAR, MODES(TeX=>$im,
HTML=>$applet->insertAll(
debug =>0,
reinitialize_button => 0,
includeAnswerBox=>1,
)));

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

DOCUMENT();

loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"PGgraphmacros.pl",
"AppletObjects.pl",
"parserImplicitEquation.pl",
"source.pl",
);

# Print problem number and point value (weight) for the problem
TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;

##############################################################
#
# Setup
#
#
Context("ImplicitEquation");
Context()->variables->are(x=>["Real", limits=>[-8,8]], y=>["Real", limits=>[-8,8]]);
Context()->noreduce('(-x)-y');

$a = non_zero_random(-3,7,1);
do{ $b = non_zero_random(-5,5,1); } until ( $a != 1 || $b != 1 );
$c = $a*$b;

$f = Formula("$b x+$a y")->reduce;

$answer = ImplicitEquation("$f = $c");

######################################
# 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 => 400, # may want to modify width
height => 400, # 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

);



###############################################
#
# PNG picture of GeoGebra applet for hardcopy

$im = init_graph(-8,-8,8,8,
size=>[400,400],
grid=>[16,16],
axes=>[0,0]
);

##################################
# 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
// Setup the grid, then establish values, points, then the line

applet.setPerspective("G");
applet.setPointCapture(1,2);
applet.setCoordSystem(-8,8,-8,8);
applet.setAxisSteps(1,1,1);
applet.setGridVisible('true');

applet.evalCommand("a = 1");
applet.evalCommand("b = 1");
applet.evalCommand("A = (a,0)");
applet.evalCommand("B = (0,b)");
applet.evalCommand("l = Line[A,B]");

//applet.setColor('A',228,27,23);
//applet.setColor('B',228,27,23);
//applet.setColor('l',228,27,23);


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

#######################################################
#
# For retrieving values from GeoGebra into WeBWorK
#

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 l = applet.getLaTeXString("l");
return( l );
}
</script>
END_SCRIPT

##############################################################
#
# Text
#
#

Context()->texStrings;
BEGIN_TEXT

Graph the line, and submit your answer.
\[$f = $c\]


END_TEXT
Context()->normalStrings;

###################################
# 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=>"<div class='enclose_ggb_obj'>".$applet->insertAll(
debug =>0,
reinitialize_button => 1,
includeAnswerBox=>1 )."</div>"
));


##############################################################
#
# Answers
#
#

NAMED_ANS( 'answerBox' => $answer->cmp() );

sub GEOGEBRA_PARAMS {
my $result = {
appName=>"classic", # instead of using ggbbase64
enableShiftDragZoom=>"false",
showResetIcon=>"false" ,
enableRightClick=>"false" ,
enableLabelDrags=>"false",
showMenuBar=>"false" ,
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",
#ggbbase64=>''
};

$result;
}



ENDDOCUMENT();

WeBWorK Main Forum -> geogebra javascript tutorial

by Joel Trussell -
I'm trying to modify the example in
I"ve copied that to my server. I can create scripts in my desktop Geogebra Classic 6 as in the tutorial
https://wiki.geogebra.org/en/Tutorial:Introduction_to_GeoGebraScript
I'd like to transfer the script approach to webwork and alter the example problem to use the buttons to set variables in the geobebra window in webwork.
I can do some simply things like changing colors and point sizes. I want to have the values of a vector set by the user via input of magnitude and angle/phase. I can do this in the desktop geogebra - inpt the magnitude and phase, compute the (x,y) coordinates of the vector and execute the vector command with the right values.

If I leave the input box in the gbb64 code and copy it to the webwork problem, I can set the vector. BUT I don't want the input boxes in the graph. I want the input to be in the position of the buttons and boxes in the example problem 6 at UofR.

This presents a problem for me - I don't know if I can use inputbox in the script of the example. I have tried to use button and set the coordinates with something like

<input type="button" value="set coords of V1: " onclick="setCoords('V1', setXfield.value, setYfield.value);">
<input type="text" name="setXfield" id="V1x" size="5" value="">
<input type="text" name="setYfield" id="V1y" size="5" value="">

this doesn't work.

I have searched and can't find a tutorial for interfacing the script commands of geogebra with the javescript used in the example. can you point me in the right direction for instruction?

for the record: my code is below
thanks

## DBsubject(Algebra)
## DBchapter(Conic sections)
## DBsection(Circles)
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGinfo.pl",
"AppletObjects.pl",
#"source.pl",
"PGcourse.pl",
);
TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

Context("Complex");
Context()->flags->set(
#tolerance => 0.15,
#tolType => "relative",
#zeroLevel=>10,
#zeroLevelTol=>0.2

);
#################################
# Set up problem
# Set parameters for a circle
#################################
$F= random(1,1.5,0.1);
$G = random(1,1.5,0.1);
$V1a=-($F+$G*i);
$V2a=-($F+$G*i)**2;
$V3a=-($F+$G*i)**3;
$V4a=-($F+$G*i)**4;


#$V1vr=re($V1v);
$V1ang=(arg($V1a)%(2*pi))/pi*180;
$V2ang=(arg($V2a)%(2*pi))/pi*180;
$V3ang=(arg($V3a)%(2*pi))/pi*180;
$V4ang=(arg($V4a)%(2*pi))/pi*180;


$V1abs=abs($V1a);
$V2abs=abs($V2a);
$V3abs=abs($V3a);
$V4abs=abs($V4a);
$xmax=ceil(1.25*(sqrt(2)*abs($V4a)));
$xmin=-$xmax;
$ymax=$xmax;
$ymin=$xmin;






$answer = Compute("($V1abs,$V1ang,$V2abs,$V2ang,$V3abs,$V3ang,$V4abs,$V4ang)");
@tol=(0.1,3); # Magnitude Tolerance 0.1, Angular Tolerance 3 degrees
@type=(0,1,0,1,0,1,0,1); #0 for magnitude value, 1 for angular value in degrees



######################################
# 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 => '', # default actionAlias
setStateAlias => 'setXML',
getStateAlias => 'getXML',
setConfigAlias => '',
getConfigAlias => '',
returnFieldName => '',
width => 700, # may want to modify width
height => 700, # 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() },
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
applet.setValue("xmin", $xmin);
applet.setValue("xmax", $xmax);
applet.setValue("ymin",$ymin);
applet.setValue("ymax", $ymax);






} else {
setTimeout("setAppletCoefficients()", 1000);
}
} else {
setTimeout("setAppletCoefficients()",1000);
}
}
ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()};

</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 V1m = applet.getValue("V1m");
var V1ang= applet.getValue("V1ang");
var V2m = applet.getValue("V2m");
var V2ang= applet.getValue("V2ang");
var V3m = applet.getValue("V3m");
var V3ang= applet.getValue("V3ang");
var V4m = applet.getValue("V4m");
var V4ang= applet.getValue("V4ang");
return(V1m + ',' +V1ang +','+V2m + ',' +V2ang +','+ V3m + ',' +V3ang +','+V4m + ',' +V4ang);
}
</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
$test;
Given \(y = -($F + $G j) ^n\), $BR
Plot the graph of this function in polar coordinates with n = 1, 2, 3, and 4
Please drag the four vectors to the correct positions in the figure below. The red, green, blue and magenta vectors correspond to the cases of n=1, 2, 3 and 4 respectively. Note: WeBWork and MATLAB adopt different conventions for the phase angles, namely \([0^{\circ},360^{\circ}) \) and \((-180,180]\) respectively. However, this should not affect the geometry relationship between the vectors in your plot. Considering the difficulties in operating on the screen, your vector magnitude will be checked to \(\pm $tol[0]\) and your angle will be checked to \(\pm $tol[1] ^{\circ}\).
Click the submit answers button when you are done.
@{correct}

END_TEXT

#TEXT($PAR, "foostate |", $inputs_ref->{ "${appletName}_state"}, "|");

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

TEXT(MODES( TeX => "GeoGebra Applet",
HTML =><<"END_APPLET" ) ); # " " means interpolate variables

<input type="button" value="Hide V1" onclick="getApplet('$appletName').setVisible('V1', false);">
<input type="button" value="Show V1" onclick="getApplet('$appletName').setVisible('V1', true);">
<input type="button" value="V1 red" onclick="getApplet('$appletName').setColor('V1', 255, 0, 0);">
<input type="button" value="V1 blue" onclick="getApplet('$appletName').setColor('V1', 0, 0, 255);">
<input type="button" value="Delete V1" onclick="getApplet('$appletName').deleteObject('V1');">
<input type="button" value="Reset" onclick="getApplet('$appletName').reset();">
 
$PAR
<input type="button" value="get coords of V1: " onclick="getCoords('V1');">
<input type="text" name="getXfield" id="V1x" size="5">
<input type="text" name="getYfield" id="V1y" size="5">
$PAR

<input type="button" value="set coords of V1: " onclick="setCoords('V1', setXfield.value, setYfield.value);">
<input type="text" name="setXfield" id="V1x" size="5" value="">

<input type="text" name="setYfield" id="V1y" size="5" value="">

 


END_APPLET

#########################################
# ANSWER section
#########################################
#$test=List('answerBox');
#NAMED_ANS( 'answerBox' => $answer->cmp(ordered=>1) );

NAMED_ANS( 'answerBox' =>$answer->
cmp(list_checker => sub {
my ($correct,$student,$ansHash,$value) = @_;
my $n = scalar(@$student); # number of student answers
my $score = 0; # number of correct student answers
my @errors = (); # stores error messages
my $i; # loop counters
#
# Loop though the student answers
##
for ($i = 0; $i < $n; $i++) {
my $err,$errt;
my $ith = Value::List->NameForNumber($i+1);
my $p = $student->[$i]; # i-th student answer
my $a = $p->value;
my $q = $correct->[$i]; # i-th student answer
my $b = $q->value;
if ($type[$i]==0){
$err=abs($a-$b)
}
if ($type[$i]==1){
$errt=abs($a-$b);
$err=min($errt,360-$errt);
}

if ($err<$tol[$type[$i]] ) {$score++} else {
push(@errors,"Your $ith point is not correct") unless $ansHash->{isPreview}
}
}
return ($score,@errors);
}));


sub GEOGEBRA_PARAMS {
my $result = {
showResetIcon=>"false" ,
enableRightClick=>"false" ,
enableLabelDrags=>"false",
showMenuBar=>"false" ,
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",
allowRescaling=>"false",
enableShiftDragZoom=>"false",
#geogebra work sheet link https://ggbm.at/stSsYPfV
ggbbase64=>"UEsDBBQACAgIAPiKvUwAAAAAAAAAAAAAAAAXAAAAZ2VvZ2VicmFfZGVmYXVsdHMyZC54bWztml9z2ygQwJ+vn4Lh6e4htpAl28lE6aSdubnMpGnmkuncK5awzAWDTqBYzqcvAlmSazv1v9ROLnkIWryA+O1qWZDOP+ZjBh5JKqngAUQtBwLCQxFRHgcwU8OTPvx48eE8JiImgxSDoUjHWAXQLzSrdlpqed1+UYeTJIAhw1LSEIKEYVU0CaAYDhnlBAKQS3rGxQ0eE5ngkNyFIzLG1yLEyvQ1Uio5a7cnk0lr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T0XvdOD9bdukJjFvHnEYCPJLrSCC3nLNQaFhzVKhiLdgBbvn9uOUPX2/7c9v7T1pOPbH82El73Sb9pL1mli/C6oF9N593+27IH56e8eP21/zQgWIIUYRxyGxCDDnyrgPGT3WQIHYAieMAiQOAhI4BUchjKahk9EsdjMgdPPI4PPIQQZTjb3BioWispA6/EB6+Ocp0n2T+ccb/SUbkv/85zvMOnGvy8ERHVEuhOK6aMtZfyvX2oIl7QBOHjmwZP4mZpoJrxoSQXwqZ3EMm74FMHkDGVAz5DRUask8V81B8DmS7Ue0Hs2zPrcmza4ENv5dcj1nf4ttX5fKOfLNdq+zBbxoeEcSORXpk7FI+dkl+OCnpvwfjdvD6l7NksbS5TerV9RfT6cR/3PIv1gHswmR/MqV3kbUBc1NM25mX7Fw3TSq3H3R1neDHUIQudRNJd+QXN5N0VKbx2CRxTxIkereQhD/AaG21qeefjry1aXc/n7JjOe3ab7M62v7E6X5w0P3G9cX/AVBLBwjHVHkcWQkAALUrAABQSwECFAAUAAgICAD4ir1MYKrbFOsEAABUJgAAFwAAAAAAAAAAAAAAAAAAAAAAZ2VvZ2VicmFfZGVmYXVsdHMyZC54bWxQSwECFAAUAAgICAD4ir1MELnUiuUCAADYDAAAFwAAAAAAAAAAAAAAAAAwBQAAZ2VvZ2VicmFfZGVmYXVsdHMzZC54bWxQSwECFAAUAAgICAD4ir1M1je9uRkAAAAXAAAAFgAAAAAAAAAAAAAAAABaCAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc1BLAQIUABQACAgIAPiKvUzHVHkcWQkAALUrAAAMAAAAAAAAAAAAAAAAALcIAABnZW9nZWJyYS54bWxQSwUGAAAAAAQABAAIAQAAShIAAAAA"};
$result;
}
ENDDOCUMENT();
Thanks - the weighted parts looks like a good first approach. If you make the multiple choice parts sufficiently small, they will figure out that thye shouldn't waste attempts on them. The multipart problem look intriguing and we'll investigate.
I tried the weighted part method unsuccessfully. I tried a weighting of 80/10/10 and got parts b and c correct - but Webwork said the test student got 67%, not 80% as I'd expected.
WEIGHTED_ANS($F5->cmp(), 80 );
WEIGHTED_ANS( $popup->cmp(), 10 );
WEIGHTED_ANS( $popupc->cmp(), 10 );


the problem is copied below

# DESCRIPTION
# Problem from 'Mathematics: The Language of Electrical and Computer Engineering', Viniotis and Trussell, 3rd ed.
# WeBWorK problem written by Joel Trussell, <hjt@ncsu.edu>
# ENDDESCRIPTION

## DBsubject(Electrical Engineering)
## DBchapter(Fourier Series)
## DBsection(Problems)
## Institution(North Carolina State University)
## Author(H. J. Trussell)
## TitleText1('Mathematics: The Language of Electrical and Computer Engineering')
## AuthorText1('Viniotis and Trussell')
## EditionText1('3')
## Problem1('9.31')


#################################
# Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
"PGgraphmacros.pl",
"parserPopUp.pl",
"unionTables.pl",
"weightedGrader.pl"
);

$refreshCachedImages=1;

TEXT(beginproblem());


################################
# Setup

Context("Numeric");
Context()->flags->set( reduceConstants=>0 );
Context()->variables->are( t=> "Real" );
Context()->flags->set(
tolerance => 0.001,
tolType => "absolute",
);

#
# Part A
#

$T = random(1,6,1);
$w0 = 2*pi/$T;
$f = random(2,8,1);
$f2 = 2 * $f;
$Ymax = 1.5*$f;
$Ymin = -1.5*$f;

$F1 = Compute("$f/2 + $f2/pi cos($w0 t)");
$F3 = Compute("$f/2 + $f2/pi cos($w0 t) - $f2/(3 pi) cos(3 $w0 t) ");
$F5 = Compute("$f/2 + $f2/pi cos($w0 t) - $f2/(3 pi) cos(3 $w0 t) + $f2/(5 pi) cos(5 $w0 t)");

#
# Part B
#

$g1 = $F3;
$g2 = Compute("$f/2 + $f2/pi sin($w0 t) - $f2/(3 pi) sin(3 $w0 t)");
#$g2 = Compute("$f/2 + $f2/pi cos($w0 t) - $f2/(3 pi) cos(3 $w0 t) ");;
$g3 = -($F5);

$g[0] = "$F5 for t in <-$T,$T> using color:red and weight:2";
$gr[0] = init_graph(-$T,$Ymin,$T,$Ymax,'axes'=>[0,0]);
$gr[0]->lb('reset');
$gr[0]->lb(new Label(5.25,0.25,'t','black','center','middle'));
$gr[0]->lb(new Label(0.25,5.25,'y','black','center','middle'));

$g[1] = "$g1 for t in <-$T,$T> using color:red and weight:2";
$gr[1] = init_graph(-$T,$Ymin,$T,$Ymax,'axes'=>[0,0]);
$gr[1]->lb('reset');
$gr[1]->lb(new Label(5.25,0.25,'t','black','center','middle'));
$gr[1]->lb(new Label(0.25,5.25,'y','black','center','middle'));

$g[2] = "$g2 for t in <-$T,$T> using color:red and weight:2";
$gr[2] = init_graph(-$T,$Ymin,$T,$Ymax,'axes'=>[0,0]);
$gr[2]->lb('reset');
$gr[2]->lb(new Label(5.25,0.25,'t','black','center','middle'));
$gr[2]->lb(new Label(0.25,5.25,'y','black','center','middle'));

$g[3] = "$g3 for t in <-$T,$T> using color:red and weight:2";
$gr[3] = init_graph(-$T,$Ymin,$T,$Ymax,'axes'=>[0,0]);
$gr[3]->lb('reset');
$gr[3]->lb(new Label(5.25,0.25,'t','black','center','middle'));
$gr[3]->lb(new Label(0.25,5.25,'y','black','center','middle'));


for $i (0..3) {
# use ($fin) to make graphs smooth - note you need the parentheses
($f1n) = plot_functions( $gr[$i], $g[$i]);
$f1n->steps(100);
$fig[$i]=image(insertGraph($gr[$i]),
width=>200,height=>200,tex_size=>450);
}

$k = 0;

@perm = shuffle(4);
@fig = @fig[@perm];
@inv = invert(@perm);

@letter = ("A", "B", "C", "D");

$popup = PopUp(["?","A","B","C","D"], $letter[$inv[$k]]);

#
# Part C
#

@ftex = ();

$ftex[0] =
"
\left\lbrace
\begin{array}{rrr}
0, && -T/2 \leq t < -T/4,
\\
$f, && -T/4 \leq t \leq T/4,
\\
0, && T/4 < t \leq T/2.
\end{array}
\right.
";


$ftex[1] =
"
\left\lbrace
\begin{array}{rrr}
0, && -T/2 \leq t < -T/4,
\\
-$f, && -T/4 \leq t \leq T/4,
\\
0, && T/4 < t \leq T/2.
\end{array}
\right.
";

$ftex[2] =
"
\left\lbrace
\begin{array}{rrr}
-$f, && -T/2 \leq t < 0,
\\
$f, && 0 \leq t \leq T/2.
\end{array}
\right.
";

$ftex[3] =
"
\left\lbrace
\begin{array}{rrr}
$f, && -T/2 \leq t < 0,
\\
-$f, && 0 \leq t \leq T/2.
\end{array}
\right.
";


$k = 0;

@permc = shuffle(4);
@ftex = @ftex[@permc];
@invc = invert(@permc);

@functionname = ("s1(t)", "s2(t)", "s3(t)", "s4(t)");

$popupc = PopUp(["?","s1(t)","s2(t)","s3(t)","s4(t)"], $functionname[$invc[$k]]);



Context()->texStrings;
BEGIN_TEXT
This problem is related to Problem 9.31 in the text
(a) A signal, \( s(t) \), with period \( T = $T\), is approximated by using the first few terms in the frequency domain by the following non-zero (complex) Fourier coefficients (all others are zero):
\( \displaystyle S(0) = \frac{$f}{2} \),
\( \displaystyle S(1) = S(-1) = \frac{$f}{\pi} \),
\( \displaystyle S(3) = S(-3) = -\frac{$f}{3 \pi} \),
\( \displaystyle S(5) = S(-5) = \frac{$f}{5 \pi} \).
Find the approximation \( \hat{s}(t) \), where $BR
\[\hat{s}(t) = \sum_{n = -5}^5 S(n) e^{jn\omega_0 t} = \sum_{n = 0}^5 C(n) cos(n\omega_0 t + \theta_n).\] (See Section 9.1.2 of the text.)
$BR
Write the answer as the sum of cosines with phase. There should be no complex numbers in your formula.
$PAR
\( \hat{s}(t) = \) \{ ans_rule(70) \}
$BR
$BR
(b) Using a MATLAB, graph the Fourier approximation
\( \hat{s}(t) \) and then select the letter of the graph which
most closely resembles your graph. \{ $popup->menu() \}
$BR
Note that the scales on the graphs below are not needed to answer this question. You may use any \( \omega_0 \) that you desire for your plot.
$BR
\{
$BCENTER.
BeginTable().
AlignedRow([$fig[0],$fig[1],$fig[2],$fig[3]]).
TableSpace(5,0).
AlignedRow(["A","B","C","D"]).
EndTable().
$BR.
"(Click on a graph to enlarge it.)" .
$ECENTER
\}
$BR
$BR
(c) Which signal given below could the signal that is being approximated?
\( s(t) \) model? \{ $popupc->menu() \}
$BR
$BR
\{
$BCENTER.
BeginTable().
AlignedRow([ "\( \displaystyle s_1(t) = $ftex[0] \)", "\( \displaystyle s_2(t) = $ftex[1] \)" ]).
TableSpace(25,0).
AlignedRow([ "\( \displaystyle s_3(t) = $ftex[2] \)", "\( \displaystyle s_4(t) = $ftex[3] \)" ]).
EndTable().
$ECENTER
\}
END_TEXT
Context()->normalStrings;

$showPartialCorrectAnswers = 1;


WEIGHTED_ANS($F5->cmp(), 80 );

WEIGHTED_ANS( $popup->cmp(), 10 );

WEIGHTED_ANS( $popupc->cmp(), 10 );

COMMENT('MathObject version');
ENDDOCUMENT();