Forums

Search results: 163

WeBWorK Problems -> Accepting all varialbes

by Carl Yao -
Hello:

Is there a way to let WeBWorK accept any variable? For example, if the correct solution is {x|x>1}, and if a student typed in {Z|Z>1}, it would be considered correct?

Thank you!

Carl Yao
Math Instructor
Portland Community College

Sample code is here:

# WeBWorK problem written by Carl Yao
# Portland Community College
#
# Give a graph of an inequality, write the set notation and interval notation.
# Answer is like (3, inf).
#
# Last edited by Jordan 8/28/13; Carl Yao on 7/21/13
#
# ENDDESCRIPTION

## DBsubject('Algebra')
## DBchapter('Basic Algebra')
## DBsection('Inequalities')
## KEYWORDS('linear','inequality', 'number line','set notation','interval notation')
## DBCCSS('7.EE.4')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')
## Author('Alex Jordan, Carl Yao, Chris Hughes')
## Institution('PCC')

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

DOCUMENT();

loadMacros(
"PGgraphmacros.pl",
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserPopUp.pl",
"contextInequalitySetBuilder.pl",
"PGcourse.pl",
);

##############################################
TEXT(beginproblem());
Context("Numeric");

$a = random(-4,4,0.5);

$symbol = '>';

InequalitySetBuilder::UseVerticalSuchThat();
Context("InequalitySetBuilder-Only");
$setans = Compute("{ x | x $symbol $a}");

Context("Interval");
Context()->flags->set("formatStudentAnswer"=>'parsed');
$intans = Compute("($a,inf)");
Context("Numeric");

%answer = (leftType => 'open',
rightType => 'inf', #use 'inf' regardles of +/- inf
);


$aspectRatio = 1/8;
$horPixel = 400;
$verPixel = $horPixel*$aspectRatio;
$screenXSize = $horPixel;
$screenYSize = $screenXSize*$aspectRatio;
$reach = 5;
$verticalSpace = $reach*$aspectRatio;
$hardCopyPercent = 1000; #meaning 100%


#initializing...
@gr=();

#indices will be 0..$#gr in some order, with the index of the correct graph in the 0th position.
@indices=();


#make the graphs
for $leftType ('open','closed', 'inf')
{
for $rightType ('open','closed', 'inf')
{
my $tempgr = init_graph(-$reach,-$verticalSpace,$reach,$verticalSpace,
axes=>[$reach+1,0],
size=>[$horPixel,$verPixel]
);
@ticks = ();
for my $j ((-$reach)..($reach)) {push(@ticks,$j);};

$tempgr->h_ticks(0,"black",@ticks);
$tempgr->lb( new Label(0,-$verticalSpace/5,0,'black','center','top'));

if (($leftType eq 'inf' or $rightType eq 'inf') and !(($leftType eq 'inf' and $rightType eq 'inf')))
{
$tempgr->lb( new Label($a,-$verticalSpace/5,$a,'blue','center','top'));
if ($leftType eq 'open' or $rightType eq 'open')
{
$tempgr->stamps( open_circle($a,0,'blue') )
}
else
{
$tempgr->stamps( closed_circle($a,0,'blue') )
};
$tempgr->moveTo($a,0);
if ($leftType eq 'inf') {$tempgr->arrowTo(-0.99*$reach,0,'blue',3)}
else {$tempgr->arrowTo(0.99*$reach,0,'blue',3)};
push(@gr,$tempgr);
if ($answer{leftType} ne $leftType or $answer{rightType} ne $rightType)
{push(@indices, $#gr);}
else {unshift(@indices, $#gr);}
}

}};

$alt = "Graph of an interval on a number line. There is a hollow circle at $a and everything right of that is shaded.";

##############################################
$refreshCachedImages = 1;

Context()->texStrings;
BEGIN_TEXT
Here is a graph of an interval.$PAR

$BCENTER
\{ image( insertGraph($gr[ $indices[0] ]), width=>$screenXSize, height=>$screenYSize, tex_size=>$hardCopyPercent,
extra_html_tags=>'title="$alt" alt= "$alt" align="top"' ) \}
$ECENTER
$PAR
END_TEXT
Context()->normalStrings;

BEGIN_PGML
Please type:

* *inf* for [`\infty`],
* *[$GTS]=* for [`\geq`],
* and *[$LTS]=* for [`\leq`]

Write this inequality in set-builder notation: [_____________________]


Write this inequality in interval notation: [_____________________]



END_PGML



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

ANS( $setans->cmp() );

ANS( $intans->cmp() );

BEGIN_PGML_SOLUTION

Since the given graph shades all the values greater than [`[$a]`] (but not equal to [`[$a]`]) the graph represents the inequality [`x [$symbol] [$a]`].

The corresponding set notation is [`[$setans]`].

The corresponding interval notation is [`[$intans]`].

END_PGML_SOLUTION

ENDDOCUMENT();


I would like the students to be able to always use the same notation for infinity in their answers, that is, I=infinity, -I=-Infinity. I know how to do this when the answer is just I or -I, but I am not able to get the answer evaluator to accept 
an interval in the form (-I,4] for example. In the problem below, the answer has to be entered as (-Infinity,2) or (-inf,2), but I would like the students to be able to enter (-I,2). Is this possible?
Thanks in advance.



DOCUMENT();       

loadMacros("PGstandard.pl",
"MathObjects.pl",
"PGgraphmacros.pl",
"PGML.pl",
"AnswerFormatHelp.pl",
"PGcourse.pl"
);




TEXT(beginproblem());


$showPartialCorrectAnswers = 1;
$refreshCachedImages=1;

Context("Point");

$pixels=400;

#create the canvas
$gr=init_graph(-10,-10,10,10,# xmin,ymin, xmax, ymax
axes=>[0,0],grid=>[20,20],size=>[$pixels,$pixels]);
$gr->lb('reset'); #remove default labels

# axes labels
$gr->lb(new Label(9.5,0,'x','black','center','bottom'));
$gr->lb(new Label(0.1,9.5,'y','black','left','middle'));

foreach my $i (-10..10){
$gr->lb( new Label($i,0,$i,'black','center','top'));
$gr->lb( new Label(-0.1,$i,$i,'black','right','middle'));
}
#plot a function
$e=0.1;
$t1=random(2,2,1);
$t11=$t1-$e;
$t12=$t1+$e;
$t2=$t1+2;
$t20=$t2-$e;
$t21=$t2+2*$e;
$t3=$t2+4;
$t30=$t3-$e;
$t31=$t3+$e/4;
$t22=$t2+2;


$L1=Formula("-1/(x-$t1)+2");
$L2=Formula("7/2");
$L3=Formula("3*sin(3*(x-$t3))+7/2");
$a=3*sin(3*(9-$t3))+7/2;

add_functions($gr, "$L1 for x in <-10,$t11> using color:blue and weight:2",
"$L1 for x in <$t12,$t20> using color:blue and weight:2",
"$L2 for x in <$t21,$t30> using color:blue and weight:2",
"$L3 for x in <$t31,9> using color:blue and weight:2");

$gr->stamps(
      new Circle($t2,2.5,4,'blue','blue'));
$gr->stamps(
      new Circle($t2,1.5,4,'blue',''));
$gr->stamps(
      new Circle($t2,3.5,4,'blue',''));
$gr->stamps(
      new Circle($t3,1,4,'blue','blue'));

$gr->stamps(
      new Circle($t3,3.5,4,'blue',''));

$gr->stamps(
      new Circle(9,$a,4,'blue','blue'));


$ans=Interval("(-inf,$t1)");


BEGIN_PGML
The graph of [` f(x)`] is shown in the picture. 

>>[@image(insertGraph($gr),width=>$pixels, height=>$pixels, tex_size=>900) @]*<<
The function is continuous on [_____]{$ans}
END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*
END_PGML_SOLUTION

ENDDOCUMENT();       
I have can show old answers by default set to student - this is set in global.conf and it is also set in simple.conf in the course I am working. When an answer is submitted the answer is shown in the blank after the page refreshes and the problem is graded.
If you migrate away from the page the answer is no longer there when you come back.
Glad you have the first problem solved.  You've pretty much identified the second problem.  The alias "Library" in each course/template directory is currently pointing to the location of the old NationalProblemLibrary and you need to make it point to the new one:  ..../webwork-open-problem-library/OpenProblemLibrary.

Deleting the link AND then visiting the library browser  will refresh the Library link properly. (Sometimes people still see error messages until they make that first click on the library browser which resets the Library link.)

I couldn't find a script but this is what I use. Put it in bin/changeLibraryLink.pl.
#!/usr/bin/env perl

# utility script
# usage:  ls  /opt/webwork/courses | changeLibraryLink.pl


while (<>) {
        next if $_ =~/tar\.gz/;
        chomp;
        ` sudo ln -sf /opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary  /opt/webwork/courses/$_/templates/Library`;
        ` sudo ln -sf /opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary/Rochester /opt/webwork/courses/$_/templates/rochesterLibrary`;
        ` sudo ln -sf /opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary/Union  /opt/webwork/courses/$_/templates/unionLibrary`;
         print " /opt/webwork/courses/$_/templates/Library relinked \n";

}

You will want to read and understand the script first.  It accepts each courseName and creates a new link for Library, rochesterLibrary, and unionLibrary.  You probably only want the Library link so comment out the

lines with unionLibrary and rochesterLibrary. 

ls /opt/webwork/courses |changeLibraryLink.pl  pipes every course name that is found in /op/webwork/courses into changeLibraryLink.pl which then creates the appropriate Library link in that course.


Hope this helps.



WeBWorK Problems -> graph images are not displaying

by tim Payer -
Hello,

About 25% of my students are not having the graph images displayed in their homework assignment. Combinations of Mac Pro laptops and Safari browsers are a common denominator, but some PC are also having problems.
Most of the class are getting the intended images though.

I have included a sample problem below.

Is there something I can do for these students beside direct them to campus computer labs?
A preferred browser? a change in the pg code that would make the problems more accessible? 

Thanks for any guidance...
Tim

## DBsubject(Algebra)
## DBchapter(Functions)
## DBsection(Piecewise functions)
## Date(01/01/10)
## Institution(Fort Lewis College)
## Author(Paul Pearson)
## MLT(piecewise_graph_looks_like_this)
## Level(3)
## MO(1)
## TitleText1('Functions Modeling Change')
## TitleText2('Functions Modeling Change')
## TitleText3('Functions Modeling Change')
## AuthorText1('Connally')
## AuthorText2('Connally')
## AuthorText3('Connally')
## EditionText1('3')
## EditionText2('4')
## EditionText3('5')
## Section1('2.3')
## Section2('2.3')
## Section3('2.3')
## Problem1('3')
## Problem2('3')
## Problem3('3')
## KEYWORDS('functions','piecwise')

DOCUMENT();

loadMacros(
"PGstandard.pl",
"PGunion.pl",
"PGgraphmacros.pl",
"PGcourse.pl",
"PGchoicemacros.pl",
"parserPopUp.pl",
);

TEXT(beginproblem());


$refreshCachedImages=1;

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


$a = random(1,2,1);
$vshift = random(0,2,1);
while ($vshift==$a) { $vshift = random(0,2,1); }
$s = random(-1,1,2);

$amv = $a - $vshift;
$vma = $vshift - $a;

if ($s == 1) {
$f1 = Formula("-x+$vma")->reduce;
$f2 = $vshift;
$f3 = Formula("x+$vma")->reduce;
} else {
$f1 = Formula("x-$vma")->reduce;
$f2 = -$vshift;
$f3 = Formula("$amv - x");
}

#
#  make graphs
#
foreach my $i (0..3) {
  $G[$i] = init_graph(-4,-4,4,4,grid=>[8,8],axes=>[0,0],size=>[200,200]);
}


plot_functions($G[0],"$s*(abs(x)-$a+$vshift) for x in <-4,-$a> using color:blue and weight=2"); # correct answer
plot_functions($G[0],"$s*($vshift) for x in <-$a,$a> using color:blue and weight=2"); # correct answer
plot_functions($G[0],"$s(abs(x)-$a+$vshift) for x in <$a,4> using color:blue and weight=2"); # correct answer
$G[0] -> stamps( closed_circle(-$a,$s*$vshift,'blue') );
$G[0] -> stamps( closed_circle( $a,$s*$vshift,'blue') );
$G[0] -> lb(new Label ( 3.5,0,'x','black','left','bottom'));
$G[0] -> lb(new Label ( -0.5,3.5,'y','black','middle','center'));

plot_functions($G[1],"$s*(abs(x)-$a+$vshift) for x in <-4,-$a> using color:blue and weight=2"); # correct answer
plot_functions($G[1],"$s*($vshift) for x in <-$a,$a> using color:blue and weight=2"); # correct answer
plot_functions($G[1],"$s(abs(x)-$a+$vshift) for x in <$a,4> using color:blue and weight=2"); # correct answer
$G[1] -> stamps( open_circle(-$a,$s*$vshift,'blue') );
$G[1] -> stamps( open_circle( $a,$s*$vshift,'blue') );
$G[1] -> lb(new Label ( 3.5,0,'x','black','left','bottom'));
$G[1] -> lb(new Label ( -0.5,3.5,'y','black','middle','center'));

$bogus = random(-1,1,2);

plot_functions($G[2],"$s*(abs(x)-$a+$vshift) for x in <-4,-$a> using color:blue and weight=2"); # correct answer
plot_functions($G[2],"$s*($vshift)+$bogus for x in <-$a,$a> using color:blue and weight=2"); # correct answer
plot_functions($G[2],"$s(abs(x)-$a+$vshift) for x in <$a,4> using color:blue and weight=2"); # correct answer
$G[2] -> stamps( closed_circle(-$a,$s*$vshift,'blue') );
$G[2] -> stamps( closed_circle( $a,$s*$vshift,'blue') );
$G[2] -> stamps( open_circle(-$a,$s*$vshift+$bogus,'blue') );
$G[2] -> stamps( open_circle( $a,$s*$vshift+$bogus,'blue') );
$G[2] -> lb(new Label ( 3.5,0,'x','black','left','bottom'));
$G[2] -> lb(new Label ( -0.5,3.5,'y','black','middle','center'));

plot_functions($G[3],"$s*(abs(x)-$a+$vshift) for x in <-4,-$a> using color:blue and weight=2"); # correct answer
plot_functions($G[3],"$s*($vshift)+$bogus for x in <-$a,$a> using color:blue and weight=2"); # correct answer
plot_functions($G[3],"$s(abs(x)-$a+$vshift) for x in <$a,4> using color:blue and weight=2"); # correct answer
$G[3] -> stamps( open_circle(-$a,$s*$vshift,'blue') );
$G[3] -> stamps( open_circle( $a,$s*$vshift,'blue') );
$G[3] -> stamps( closed_circle(-$a,$s*$vshift+$bogus,'blue') );
$G[3] -> stamps( closed_circle( $a,$s*$vshift+$bogus,'blue') );
$G[3] -> lb(new Label ( 3.5,0,'x','black','left','bottom'));
$G[3] -> lb(new Label ( -0.5,3.5,'y','black','middle','center'));



foreach my $i (0..3) {
  $graph[$i] = image(insertGraph($G[$i]),width=>"200",height=>"200",tex_size=>"210");
}


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

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

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



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

BEGIN_TEXT
On a piece of paper, sketch a graph of the piecewise-defined function below.
\[
f(x) =
\left\lbrace
\begin{array}{lcl}
$f1, &&  x \leq -$a, \\
$f2, && -$a < x < $a, \\
$f3, && x \geq $a.
\end{array}
\right.
\]
$PAR
Which graph A-D below most closely matches
the graph you drew?
\{ $popup->menu() \}
$PAR
$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
END_TEXT

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

$showPartialCorrectAnswers = 0;
install_problem_grader(~~&std_problem_grader);

ANS($popup->cmp() );

SOLUTION(EV3(<<'END_SOLUTION'));
$PAR
$BBOLD SOLUTION $EBOLD
$PAR
The correct graph is \{ $popup->correct_ans \}.

END_SOLUTION

ENDDOCUMENT();

WeBWorK Problems -> GeoGebra Object Listerner

by Eric Gilson -
In looking through the GeoGebra applet examples I came across an automated checking example for constructions. I was playing around with trying to embed this problem in a WeBWork question, but I can't figure out how to make it work right. My goal is to create a selection of construction problems for the Euclidean Geometry section of a course I teach.

In tinkering with the code, it seems like the applet listener for the addition of objects in GeoGebra is not triggering properly. I am not sure what I need to do get this to trigger. I looked though the OPL questions using GeoGebra and didn't find any with an object listener, so I was just operating off the template on the wiki.

Here is my code:

## DESCRIPTION
## Using a GeoGebra applet to check a basic Geometric Construction
## ENDDESCRIPTION


## DBsubject()
## DBchapter()
## DBsection()
## Date(07/01/2015)
## Institution(Park School of Baltimore)
## Author(Eric Gilson)
## MO()
## KEYWORDS('GeoGebra applet')

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"AppletObjects.pl",
"unionTables.pl",
"PGcourse.pl",
);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

##########################################
# Setup
# This problem is entirely contained in GeoGebra.
# No additional setup is needed

Context("Point");


######################################
# 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 => 700, # may want to modify width
height => 500, # 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 = image( "AF7-c".$c."-d".$d.".png", width=>486, height=>335, tex_size=>900 );


##################################
# 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);
}

var applet=getApplet("$appletName");
applet.registerAddListener("newObjectListener");

}
</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">
var applet=getApplet("$appletName");
function setAppletCoefficients() {
// 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()};

function newObjectListener (obj) {
if (obj != "finished") {
var cmd = "finished = ("+obj+"== target)";
applet.debug(cmd);
applet.evalCommand(cmd);
finished = applet.getValueString("finished");
if (finished.indexOf("true") > -1) {
applet.setVisible("wellDone",true);
}
}
}
</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

$BCENTER Construct the midpoint of the points \(A\) and \(B\).
$PAR
\{
MODES(HTML=>$applet->insertAll(debug=>0, reinitialize_button=>1, includeAnswerBox=>0,), TeX=>$im)
\}
$ECENTER
END_TEXT
Context()->normalStrings;


#########################################
# ANSWER section
#########################################


TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) );
<script language="javascript">
var applet=getApplet("$appletName");

applet.registerAddListener("newObjectListener");

function newObjectListener (obj) {
if (obj != "finished") {
var cmd = "finished = ("+obj+"== target)";
applet.debug(cmd);
applet.evalCommand(cmd);
finished = applet.getValueString("finished");
if (finished.indexOf("true") > -1) {
applet.setVisible("wellDone",true);
}
}
</script>
END_SCRIPT


#########################################
# The applet as a base64 string
#########################################

sub GEOGEBRA_PARAMS {
my $result = {
showToolBar=>"true",
CustomToolbar=>" 1 | 5 | 2 | 10 | 15 | 6 | 40 41 42",
ggbbase64=>"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"

};

$result;
}

COMMENT('Uses GeoGebraWeb (JavaScript), so it should work on computers and tablets.');

ENDDOCUMENT();
The problem --- as described above --- is that the javaScript call backs to the server to refresh the library browser page are not getting through.  A mismatch between the site_url variable and the actual url used to call webwork could be one culprit but there might be others. (Something as simple as using http in one location and https in another can cause this problem.)

To trouble shoot use two tools.  Choosing "web console" or "developer tools" (depends on the browser) will give you a console with error messages emitted by the java script on the page.   Viewing the apache error log will give you the server error messages. Between the two of them you will at least have more information about why the connection can't be made. 

Hope that helps
Hi Regina,

PopUps use string comparison, so if you set $c = random(2,4,0.5); and $popup2 = PopUp(["choose","0","1","2","2.5","3","3.5","4.0"],"$c",); it is possible to have $c equal to the (numerical) scalar 4, which is not the same as "4.0" when the comparison between "4" and "4.0" is done as strings (not numbers), thus the correct answer is not one of the PopUp choices.  I would suggest using 

$c = list_random("2","2.5","3","3.5","4");
$popup2 = PopUp(["choose","0","1","2","2.5","3","3.5","4"],$c);

so that the value for $c will always be a string that is one of the choices for $popup2.  If you use the scalar $c in any computations, Perl will be smart enough to interpret $c as a numerical scalar rather than a string.

Also, you had multiple Context("Numeric") and $showPartialCorrectAnswers statements in your problem, and removing such things will make the problem into a better template that is easier to maintain.  I have included pg source code below.

Also, you should look in the Open Problem Library directory LoyolaChicago/Precalc for problems from the Connally textbook you are using, as Adam Spiegler and I have written / co-written a bunch of problems for that book already.

https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/LoyolaChicago/Precalc

Best regards,

Paul Pearson


###### pg code below #############


# DESCRIPTION
# Recognizing values of the parameters k and p from the graph of y=k x^p (with p<0)
# ENDDESCRIPTION
#Right now stored at MAA-PREP2015
# Homework/Workshop3/Souza/problem4.pg
## DBsubject(’Precalculus’)
## DBchapter(’’)
## DBsection(’’)
## Date(’mm/dd/15’)
## Level(’’)
## Keywords(’’)
## Author(’Regina Souza’)
## Institution(’University of Montana, Missoula’)
## TitleText1(’Functions Modeling Change’)
## EditionText1(5)
## AuthorText1(’Connally’)
## Section1(11.1)
## Problem1()

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGgraphmacros.pl",
"parserPopUp.pl",
"PGML.pl",
"PGcourse.pl"
);

TEXT(beginproblem()); 
$showPartialCorrectAnswers = 1;
$refreshCachedImages = 1;


Context("Numeric");

$pixels = 200;
# Create the canvas 
$gr = init_graph(-1,-1,6,6, # xmin, ymin, xmax, ymax
axes=>[0,0], grid=>[7,7], size=>[$pixels, $pixels]);
$gr -> lb('reset'); # remove default labels
# axes labels
$gr->lb( new Label(5.5,0,'x', 'black', 'center', 'bottom'));
$gr->lb( new Label(0.1,5.5,'y', 'black', 'left', 'middle'));
# axes labels
foreach my $i (1..5) {
$gr->lb( new Label($i,0, $i, 'black', 'center', 'top'));
$gr->lb( new Label(-0.1,$i, $i, 'black', 'right', 'middle'));
}

# randomize the graph
#$c = random(2,4,0.5);
$c = list_random("2","2.5","3","3.5","4");

# plot a function
$f = Formula("$c/x");
add_functions($gr, "$f for x in <0,6> using color:blue and weight:2");
install_problem_grader(~~&std_problem_grader);

$popup1 = PopUp(
["choose","a linear function","a quadratic function","an exponential function","a power function"],
"a power function",
);

$popup2 = PopUp(
["choose","0","1","2","2.5","3","3.5","4"],
$c
);

$popup3 = PopUp(
["choose","d is less than 0", "d is between 0 and 1", "d is greater than 1"],
"d is less than 0",
);


BEGIN_PGML
Consider the function given by the following graph:
>> [@ image(insertGraph($gr), width=>$pixels, height=>$pixels, tex_size=>900,extra_html_tags=>'alt="Graph of a decreasing, concave up function in quadrant I, which passes through (1,'.$c.') " ' ) @]* 
[` f(x)=c\cdot x^d `] <<
a. Which type of function is this? This is [_________]{$popup1}
b. What is the value of [` c `] ? [` c = `][____]{$popup2}
c. Choose the best option for [` d `]: [_________]{$popup3}
END_PGML


BEGIN_PGML_SOLUTION
*SOLUTION*
a. This is [@ $popup1->correct_ans() @]* .
b. [` c = [$c] `], the value of the function at 1, and 
c. [@ $popup3->correct_ans() @]* , since [` c>0 `] and the power function is decreasing when [` x>0 `].
END_PGML_SOLUTION

ENDDOCUMENT();