Forums

Search results: 133

Davide,
Thought I should let you know about this. When I changed my version of contextInequalitiesAllowStrings.pl to allow for answers like "No solution" for the empty set, I could not get it to work by "redefining" the constants. I got this error message:

ERROR in included file: Problems/setAlgebra_04_02_CompoundIneq/42IntAlg_03_CompoundIneq.pg No definition for constant 'NONE' in the given context at line 51 of [TMPL]/macros/contextInequalitiesAllowStrings.pl Died within main::_contextInequalitiesAllowStrings_init called at line 332 of (eval 232) from within main::loadMacros called at line 20 of [TMPL]/Problems/setAlgebra_04_02_CompoundIneq/42IntAlg_03_CompoundIneq.pg from within (eval) called at line 86 of [PG]/lib/WeBWorK/PG/IO.pm from within WeBWorK::PG::IO::includePGtext called at line 32 of [TMPL]/macros/unionInclude.pl from within main::includePGfile called at line 56 of [TMPL]/macros/unionInclude.pl from within main::includeRandomProblem called at line 15 of [TMPL]/Problems/setAlgebra_04_02_CompoundIneq/42aRandomizer_Problems_03_to_07.pg

However, when I used the second of your suggestions -- where the constant was added -- it worked as desired.

I was wondering why the error happened when I used the "redefine" method.
--rac

WeBWorK Problems -> clutter in graphmacros?

by Kenneth Appel -
I have been reviewing the results of some 7th grade problems and discovered that
extra information seems to cause many students to avoid trying problems. I am
afraid that I may have copped out in trying to keep the graph clean by just blaming
the system.

What should I have done to avoid showing the many numbers in black that seem to insert
information provided in the initgraph instruction.
Ken Appel

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
"PGgraphmacros.pl",
# "MathObjects.pl",
# "compoundProblem.pl",
"contextCurrency.pl",
#"unionLists.pl",
#"unionMacros.pl",
"contextLeadingZero.pl",
);
Context()->texStrings;
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$graph = init_graph(-.3,-.3,6.7,6.7,pixels=>[700,700],axes=>[.279,.279],grid=>[12,12]);

# the size is 700 by 700 pixels (200 by 200 is default)
# .72 is one unit on the graph
my $im = $graph->im;
$im->setPixel(0,7,0);
# $graph->moveTo(0,0);
# $graph->lineTo(2,0,'black');
$new_label1= new Label (3.14,.162,'5','red',('bottom','left'));
$graph -> lb($new_label1);
$label2= new Label (6,.162,'10','red',('bottom','left'));
$graph -> lb($label2);
$label3= new Label (.19,3.14,'5','red',('bottom','left'));
$graph -> lb($label3);
$label4= new Label (.15,6.07,'10','red',('bottom','left'));
$graph -> lb($label4);
$label5= new Label (.19,.166,'0','red',('bottom','left'));
$graph -> lb($label5);
$label6= new Label (1.45,1.97,'B','blue',('bottom','left'));
$graph -> lb($label6);
$label7= new Label (2.03,.2,'A','blue',('bottom','left'));
$graph -> lb($label7);
$label8= new Label (4.33,4.9,'C','blue',('bottom','left'));
$graph -> lb($label8);

TEXT(image(insertGraph($graph),width=>700,height=>700));

$ansa1=3;
$ansa2=0;
$ansb1=2;
$ansb2=3;
$ansc1=7;
$ansc2=8;

BEGIN_TEXT
$PAR
A flaw in the graphing software puts some small black numbers to the below
and to the left of the axes. For this reason, all numbers on the graph
related to problems will be in colors other than black and the black numbers
should be ignored.
$PAR
The coordinates of the point labelled A are (\{ans_rule(1)\},\{ans_rule(1)\}).
$PAR
The coordinates of the point labelled B are (\{ans_rule(1)\},\{ans_rule(1)\}).
$PAR
The coordinates of the point labelled C are (\{ans_rule(1)\},\{ans_rule(1)\}).

END_TEXT
Context("LeadingZero");
ANS(Real($ansa1)->cmp);
ANS(Real($ansa2)->cmp);
ANS(Real($ansb1)->cmp);
ANS(Real($ansb2)->cmp);
ANS(Real($ansc1)->cmp);
ANS(Real($ansc2)->cmp);

ENDDOCUMENT()



I tried to emulate Gavin LaRose's Sample Problem 2. But the question was
apparently interpreted as using part2 twice (althougn the solutions worked
correctly. ) I do not know whether the difficulty arises from using two parts
which are both multiple choice or a missing separator of some sort. I can't
find such a separator in the sample problem.
The problem was correct when it only included Part 1.
Ken Appel

DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
#"PGgraphmacros.pl",
"MathObjects.pl",
# "compoundProblem.pl",
"contextCurrency.pl",
#"contextInequalities.pl",
#"unionTables.pl",
# "unionLists.pl",
#"unionMacros.pl",
#"contextLeadingZero.pl",
#"answerHints.pl",

);
Context("Numeric");
# set up for a multiple choice problem.
#Initialization for Part 1
$radio = new_multiple_choice();
$radio->qa("1. Write an inequality for the phrase: two more than three times a number is at most 40", "\(2m+3\le 40\)");
$radio->extra("\(3m+2\ge 40\)", "\(3m+2\le 40\)");
$radio->makeLast("\(2m+3\ge 40\)" );
#Initialization for Part 2
$a = random(2100,2900,100);
$b=random(500,900,100);
$c=$a+$b;
$d=$a-$b;
$radio = new_multiple_choice();
$radio->qa("2. John wants to buy a car. He has $DOLLAR$a in his bank account. He needs to pay $DOLLAR$b for insurance. How many dollars can John spend for the car
? ", "\(c\le $d\)");
$radio->extra("\(c \le $c\)", "\(c\ge $c\)");
$radio->makeLast("\(c\ge $d\)" );

TEXT(beginproblem());
Context()->texStrings;
BEGIN_TEXT
${BBOLD}Part 1$EBOLD
$BR
\{ $radio->print_q() \}
\{ $radio->print_a() \}

$PAR
${BBOLD}Part 2$EBOLD
$BR
\{ $radio->print_q() \}
\{ $radio->print_a() \}
$PAR
END_TEXT
ANS( radio_cmp( $radio->correct_ans() ) );
ANS( radio_cmp( $radio->correct_ans() ) );
Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION $PAR
${BBOLD}Part 1 $EBOLD
$BR
If a number is at most 40 it can be less than 40 or equal to 40.$BR
If we use m for a number then three times the number is 3m
$PAR
${BBOLD}Part 2 $EBOLD
$BR
He must start by planning to use $DOLLAR$b from his bank account to pay for
insurance. This will leave $DOLLAR$d which he can spend on the car But
he does not have to spend all of that.
$PAR
END_SOLUTION
ENDDOCUMENT();





The problem is really at line 662, not 641. It is the extra "Real(" on that line.

The reason that the line number is reported incorrectly is that the PG translator is stripping out blank lines before BEGIN_TEXT and after END_TEXT before processing the code, but it uses the original PG file in the error output. That means the line numbers don't match up between the error message and the listed code.

I have modified the PG Translator to not remove the blank lines, and that should make it report the proper error lines in the future. You will need to get the latest version of /pg/lib/WeBWorK/PG/Translator.pm for that.

Davide
I am in the process of writing a compound problem. When I finish each part I move
an ENDDOCUMENT() from the end of the previous part to test what I have done
so far. When the ENDDOCUMENT() was at the end of section 7 the
problem up to that point worked fine. So I added a section 8. When I tried to
run it I was told that I had a syntax error which was located at a line number in
the text section of
section 8. So I essentially moved the the entire text section of section 8 past
an ENDDOCUMENT() at the end of the problem (sections past 8 are ghosts
from a template). Now it claimed that I had a syntax error at the first answer
in section 7. So I moved the ENDDOCUMENT() back to the end of section 7.
Everything then worked fine so clearly the insult to section 7 was a lie. I have
removed the ENDDOCUMENT() from section 7 and we are back with the lie.
Here is the code.

##DESCRIPTION
## powers extended
##ENDDESCRIPTION
##KEYWORDS('Powers')

## DBsubject('')
## DBchapter('')
## DBsection('')
## Date('')
## Author('')
## Institution('')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')

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

DOCUMENT();

loadMacros(
"PGstandard.pl", # Standard macros for PG languag
"PGgraphmacros.pl",
"MathObjects.pl",
"compoundProblem.pl",
"unionLists.pl",
#"source.pl", # allows code to be displayed on certain sites.
#"PGcourse.pl", # Customization file for the course
);

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

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

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

$isProfessor = ($studentLogin eq 'kia' || $studentLogin eq 'professor');

#
# Start a compound problem. See the compoundProblem.pl
# file for more details about the parameters you
# can supply.
#
$cp = new compoundProblem(
parts => 10, # the total number of parts in this problem
totalAnswers => 40, # total answers in all parts combined
parserValues => 1, # make parser objects from student answers
allowReset => $isProfessor, # professors get Reset button for testing
);
$part = $cp->part; # look up the current part

##############################################
#
# Part 1
#

if ($part == 1) {

##############################################
##############################################################
#
# Setup
#
#
Context("Numeric");
Context()->flags->set(reduceConstants=>0);

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

#Context()->texStrings;
$graph = init_graph(-.1,-.1,7.1,2.1,pixels=>[700,200] );

# the size is 700 by 200 pixels (200 by 200 is default)

my $im = $graph->im;
$im->setPixel(0,7,0);
$graph->moveTo(0,1);
$graph->lineTo(7,1,'black');
$graph->moveTo(1.5,1.10);
$graph->lineTo(1.5,1.01,'red');
$graph->moveTo(.75,1.10);
$graph->lineTo(.75,1.01,'green');
$graph->moveTo(1,1.10);
$graph->lineTo(1,1.01,'blue');
$graph->moveTo(4.5,1.10);
$graph->lineTo(4.5,1.01,'black');


$new_label1= new Label (-.025, .86,'0','black',('bottom','left'));
$graph -> lb($new_label1);
$label2= new Label (2.975, .86,'1','black',('bottom','left'));
$graph -> lb($label2);
$label3= new Label (5.975, .86,'2','black',('bottom','left'));
$graph -> lb($label3);


TEXT(image(insertGraph($graph),width=>700,height=>400));

BEGIN_TEXT
THIS PROBLEM USES A SYSTEM TO PERMIT PROBLEMS IN WHICH A STUDENT CANNOT SEE
LATER PARTS OF THE PROBLEM UNTIL EARLIER PARTS ARE SATISFACTORILY COMPLETED.
THE SYSTEM IS NOT YET FULLY DEVELOPED AND SEVERAL PEOPLE AT DIFFERENT UNIVERSITIES ARE WORKING ON ELIMINATING THE DIFFICULTIES. THEY EXPECT THAT THE DIFFICULTIES
WILL BE ELIMINATED THIS SUMMER. UNTIL THEN THE PRINCIPAL ANNOYANCE WILL BE THAT
IN LATER PARTS YOU DO NOT HAVE THE OPPORTUNITY TO SUBMIT ANSWERS UNTIL AFTER
BEING TOLD THAT YOU ARE WRONG FOR NOT HAVING SUBMITTING THEN. IF YOU IGNORE THIS
TEMPORARY DIFFICULTY, PROBLEMS OF THIS TYPE WILL BE OTHERWISE CORRECT.
$PAR
$PAR
The picture above shows a part of the number line with the numbers 0, 1, and
2 marked (below the number line)by the longer vertical lines.$BR There are four short colored lines. Each
of these corresponds to a fraction and is put at the point on the number
line that represents that fraction. $BR The four short colored lines correspond to the factions \( \frac{1}{3}, \frac
{3}{2}, \frac{1}{2}, \frac{1}{4}\)


$PAR
The red line corresponds to the fraction \{ans_rule(3)\}
$PAR
The blue line corresponds to the fraction \{ans_rule(3)\}
$PAR
The green line corresponds to the fraction \{ans_rule(3)\}
$PAR
The black line corresponds to the fraction \{ans_rule(3)\}

$PAR

END_TEXT

##############################################################
#
# Answers
#
ANS(Real(1/2)->cmp);
ANS(Real(1/3)->cmp);
ANS(Real(1/4)->cmp);
ANS(Real(3/2)->cmp);


} # End of Part 1

##############################################
#
# Part 2
#


if ($part == 2) {
$graph = init_graph(-.1,-.1,6.1,2.1,pixels=>[600,200] );

# the size is 600 by 200 pixels (200 by 200 is default)

my $im = $graph->im;
$im->setPixel(0,7,0);
$graph->moveTo(0,1);
$graph->lineTo(6,1,'black');
$graph->moveTo(1.5,1);
$graph->lineTo(1.5,1.1,'red');
$graph->lineTo(1.5,1.2,'green');

$graph->moveTo(3,1);
$graph->lineTo(3,1.1,'red');
$graph->lineTo(3,1.2,'green');
$graph->lineTo(3,1.3,'blue');
$graph->moveTo(6,1);
$graph->lineTo(6,1.1,'red');
$graph->lineTo(6,1.2,'green');
$graph->lineTo(6,1.3,'blue');

$graph->moveTo(4.5,1);
$graph->lineTo(4.5,1.1,'red');
$graph->lineTo(4.5,1.2,'green');
$graph->moveTo(3.75,1);
$graph->lineTo(3.75,1.10,'green');
$graph->moveTo(5.25,1);
$graph->lineTo(5.25,1.10,'green');
$graph->moveTo(.75,1);
$graph->lineTo(.75,1.10,'green');
$graph->moveTo(2.25,1);
$graph->lineTo(2.25,1.10,'green');
$graph->moveTo(1,1);
$graph->lineTo(1,1.1,'blue');
$graph->moveTo(2,1);
$graph->lineTo(2,1.1,'blue');
$graph->moveTo(4,1);
$graph->lineTo(4,1.1,'blue');
$graph->moveTo(5,1);
$graph->lineTo(5,1.1,'blue');
$new_label1= new Label (-.025, .86,'0','black',('bottom','left'));
$graph -> lb($new_label1);
$label2= new Label (2.975, .86,'1','black',('bottom','left'));
$graph -> lb($label2);
$label3= new Label (5.975, .86,'2','black',('bottom','left'));
$graph -> lb($label3);


TEXT(image(insertGraph($graph),width=>600,height=>400));
BEGIN_TEXT
Part 2:
$PAR
The picture above shows a part of the number line with the numbers 0, 1, and
2 marked (below the number line) by the longer vertical lines.$BR Here some
points on the number line are marked with shorter colored lines (one or more
of them).
$PAR
All of the point with a line of the same color above them correspond to fractions that can be written with the same denominator.
$PAR

The smallest number which can be the denominator of all fractions with red lines above them is \{ans_rule(1)\}
$PAR
The smallest number which can be the denominator of all fractions with blue lines above them is \{ans_rule(1)\}
$PAR
The smallest number which can be the denominator of all fractions with green lines above them is \{ans_rule(1)\}

END_TEXT

##############################################################
#
# Answers
#
#
ANS(Real(2)->cmp);
ANS(Real(3)->cmp);
ANS(Real(4)->cmp);





} # End of Part 2

##############################################
#
# Part 3
#


if ($part == 3) {
$graph = init_graph(-.1,-.1,6.1,2.1,pixels=>[600,200] );

# the size is 600 by 200 pixels (200 by 200 is default)

my $im = $graph->im;
$im->setPixel(0,7,0);
$graph->moveTo(0,1);
$graph->lineTo(6,1,'black');
$graph->moveTo(1.5,1);
$graph->lineTo(1.5,1.1,'red');
$graph->lineTo(1.5,1.2,'green');

$graph->moveTo(3,1);
$graph->lineTo(3,1.1,'red');
$graph->lineTo(3,1.2,'green');
$graph->lineTo(3,1.3,'blue');
$graph->moveTo(6,1);
$graph->lineTo(6,1.1,'red');
$graph->lineTo(6,1.2,'green');
$graph->lineTo(6,1.3,'blue');

$graph->moveTo(4.5,1);
$graph->lineTo(4.5,1.1,'red');
$graph->lineTo(4.5,1.2,'green');
$graph->moveTo(3.75,1);
$graph->lineTo(3.75,1.10,'green');
$graph->moveTo(5.25,1);
$graph->lineTo(5.25,1.10,'green');
$graph->moveTo(.75,1);
$graph->lineTo(.75,1.10,'green');
$graph->moveTo(2.25,1);
$graph->lineTo(2.25,1.10,'green');
$graph->moveTo(1,1);
$graph->lineTo(1,1.1,'blue');
$graph->moveTo(2,1);
$graph->lineTo(2,1.1,'blue');
$graph->moveTo(4,1);
$graph->lineTo(4,1.1,'blue');
$graph->moveTo(5,1);
$graph->lineTo(5,1.1,'blue');
$new_label1= new Label (-.025, .86,'0','black',('bottom','left'));
$graph -> lb($new_label1);
$label2= new Label (2.975, .86,'1','black',('bottom','left'));
$graph -> lb($label2);
$label3= new Label (5.975, .86,'2','black',('bottom','left'));
$graph -> lb($label3);
$label4= new Label (1.49, .86,"1",'red',('bottom','left'));
$graph -> lb($label4);
$label5= new Label (1.49, .76,"2",'green',('bottom','left'));
$graph -> lb($label5);
$label6= new Label (.74,.86 ,"1",'green',('bottom','left'));
$graph -> lb($label6);
$label7= new Label (2.24,.86 ,"3",'green',('bottom','left'));
$graph -> lb($label7);
$label8= new Label (2.975,.76 ,"2",'red',('bottom','left'));
$graph -> lb($label8);
$label9= new Label (2.975,.66 ,"4",'green',('bottom','left'));
$graph -> lb($label9);
$label9a= new Label (2.975,.56 ,"3",'blue',('bottom','left'));
$graph -> lb($label9a);
$label10= new Label (.975,.86 ,"1",'blue',('bottom','left'));
$graph -> lb($label10);
$label11= new Label (1.975,.86 ,"2",'blue',('bottom','left'));
$graph -> lb($label11);
$label12= new Label (3.975,.86 ,"4",'blue',('bottom','left'));
$graph -> lb($label12);
$label13= new Label (4.975,.86 ,"5",'blue',('bottom','left'));
$graph -> lb($label13);
$label14= new Label (4.49,.86 ,"3",'red',('bottom','left'));
$graph -> lb($label14);
$label15= new Label (5.975,.76 ,"4",'red',('bottom','left'));
$graph -> lb($label15);
$label16= new Label (3.749,.86 ,"5",'green',('bottom','left'));
$graph -> lb($label16);
$label17= new Label (4.475,.76 ,"6",'green',('bottom','left'));
$graph -> lb($label17);
$label18= new Label (5.249,.86 ,"7",'green',('bottom','left'));
$graph -> lb($label18);
$label19= new Label (5.975,.66 ,"8",'green',('bottom','left'));
$graph -> lb($label19);
$label20= new Label (5.975,.56 ,"6",'blue',('bottom','left'));
$graph -> lb($label20);

TEXT(image(insertGraph($graph),width=>600,height=>400));

BEGIN_TEXT
Part 3:
$PAR
Now, to make the situation more clear, we have taken the previous picture
and added all the fraction values. However we have done it in an unusual way.$BR
We have used colors to indicate the denominators. The color green means that
the denominator 4 (that is a green 1 means \(\frac {1}{4}\)). The color red $BR
means that the denominator is 2 and the color blue means that the denominator
is 3. Notice that since \(\frac {2}{4} = \frac{1}{2} \) the third marked point $BR has both a red 1 and a green 2 beneath it.
$PAR
Now there is another (very useful) way of thinking about this. If we think of
the part of the number line as a sort of ruler, then its length is 2. That $BR
means that it is two units long, where a unit is measured by the distance from the
0 at the left we have to go to reach 1. Thus its end is 2 units from 0 and is marked by a black 2. $BR
$PAR
But suppose we thought of our unit as being the distance we had to go from the
left to reach \(frac {1}{3}\). Since thirds are represented by the blue color$BR
we will call these blue units. Then the end is 6 blue units from 0 and is marked by a blue 6.
$PAR
Our ruler is \{ans_rule(1)\} green units long.
$PAR
It takes \{ans_rule(1)\} green units to equal 3 blue units.
END_TEXT
##############################################################
#
# Answers
ANS(Real(8)->cmp);
ANS(Real(4)->cmp);

} #end of part 3






##############################################
#
# Part 4
#


if ($part == 4) {
$graph = init_graph(-.1,-.1,6.1,2.1,pixels=>[600,200] );

# the size is 600 by 200 pixels (200 by 200 is default)

my $im = $graph->im;
$im->setPixel(0,7,0);
$graph->moveTo(0,1);
$graph->lineTo(6,1,'black');
$graph->moveTo(1.5,1);
$graph->lineTo(1.5,1.1,'red');
$graph->lineTo(1.5,1.2,'green');

$graph->moveTo(3,1);
$graph->lineTo(3,1.1,'red');
$graph->lineTo(3,1.2,'green');
$graph->lineTo(3,1.3,'blue');
$graph->moveTo(6,1);
$graph->lineTo(6,1.1,'red');
$graph->lineTo(6,1.2,'green');
$graph->lineTo(6,1.3,'blue');

$graph->moveTo(4.5,1);
$graph->lineTo(4.5,1.1,'red');
$graph->lineTo(4.5,1.2,'green');
$graph->moveTo(3.75,1);
$graph->lineTo(3.75,1.10,'green');
$graph->moveTo(5.25,1);
$graph->lineTo(5.25,1.10,'green');
$graph->moveTo(.75,1);
$graph->lineTo(.75,1.10,'green');
$graph->moveTo(2.25,1);
$graph->lineTo(2.25,1.10,'green');
$graph->moveTo(1,1);
$graph->lineTo(1,1.1,'blue');
$graph->moveTo(2,1);
$graph->lineTo(2,1.1,'blue');
$graph->moveTo(4,1);
$graph->lineTo(4,1.1,'blue');
$graph->moveTo(5,1);
$graph->lineTo(5,1.1,'blue');
$new_label1= new Label (-.025, .86,'0','black',('bottom','left'));
$graph -> lb($new_label1);
$label2= new Label (2.975, .86,'1','black',('bottom','left'));
$graph -> lb($label2);
$label3= new Label (5.975, .86,'2','black',('bottom','left'));
$graph -> lb($label3);
$label4= new Label (1.49, .86,"1",'red',('bottom','left'));
$graph -> lb($label4);
$label5= new Label (1.49, .76,"2",'green',('bottom','left'));
$graph -> lb($label5);
$label6= new Label (.74,.86 ,"1",'green',('bottom','left'));
$graph -> lb($label6);
$label7= new Label (2.24,.86 ,"3",'green',('bottom','left'));
$graph -> lb($label7);
$label8= new Label (2.975,.76 ,"2",'red',('bottom','left'));
$graph -> lb($label8);
$label9= new Label (2.975,.66 ,"4",'green',('bottom','left'));
$graph -> lb($label9);
$label9a= new Label (2.975,.56 ,"3",'blue',('bottom','left'));
$graph -> lb($label9a);
$label10= new Label (.975,.86 ,"1",'blue',('bottom','left'));
$graph -> lb($label10);
$label11= new Label (1.975,.86 ,"2",'blue',('bottom','left'));
$graph -> lb($label11);
$label12= new Label (3.975,.86 ,"4",'blue',('bottom','left'));
$graph -> lb($label12);
$label13= new Label (4.975,.86 ,"5",'blue',('bottom','left'));
$graph -> lb($label13);
$label14= new Label (4.49,.86 ,"3",'red',('bottom','left'));
$graph -> lb($label14);
$label15= new Label (5.975,.76 ,"4",'red',('bottom','left'));
$graph -> lb($label15);
$label16= new Label (3.749,.86 ,"5",'green',('bottom','left'));
$graph -> lb($label16);
$label17= new Label (4.475,.76 ,"6",'green',('bottom','left'));
$graph -> lb($label17);
$label18= new Label (5.249,.86 ,"7",'green',('bottom','left'));
$graph -> lb($label18);
$label19= new Label (5.975,.66 ,"8",'green',('bottom','left'));
$graph -> lb($label19);
$label20= new Label (5.975,.56 ,"6",'blue',('bottom','left'));
$graph -> lb($label20);

TEXT(image(insertGraph($graph),width=>600,height=>400));


BEGIN_TEXT
Part 4:
$PAR
Now we will do something that seems very strange but will help explain something
that many people find difficult. We will give the lengths names in an unusual way
$PAR
We will just say that the black units are "units" since they measure
our ruler by the number of 1's.
$BR
We will call our red units are "half-units" since they measure our ruler by the
number of \(\frac {1}{2}\)'s.
$BR
We will call our blue units are "one-third-units" since they measure our ruler by the
number of \(\frac {1}{3}\)'s.
$BR
We will call our red units are "quarter-units" since they measure our ruler by the
number of \(\frac {1}{4}\)'s.
$PAR
Nothing unusual yet. But now suppose we know the number of units of one color
for a certain length and want to know the number of units of another color for
the same length. $BR Well, let's experiment with an example.
We will compare various lengths in green units and black units. Some we
will take from our ruler and some from a longer ruler that we can imagine.$BR
We will make a table with the first row for green units and the second
row for black units. I will fill in some numbers and you will fill in others.$BR
Remember that a number in the first row is some length in green units and the
number below it is the same length in black units.
(Ignore the little dots which were needed for spacing.)
$PAR
\(Green \ \ \ \ \ \ \ 4\ \ \ \ \ \ \.\) \{ans_rule(1)\}\(\ .\ \ \ \ 12\)
$BR
\(Black\ \ \ \ \ \ \ 1 \ \ \ \ \ \ \ 2 \ \ \ \ \ \ \ \ \ \ \. \) \{ans_rule(1)\}
$BR



END_TEXT
##############################################################
#
# Answers

ANS(Real(8)->cmp);
ANS(Real(3)->cmp);

} #end of part 4

##############################################
#
# Part 5
#


if ($part == 5) {


BEGIN_TEXT
Part 5:
Well, if you have gotten here you have filled out the table correctly. Now let's look at it a bit more closely.
$PAR
\(Green \ \ \ \ \ \ \ 4 \ \ \ \ \ \ \ 8 \ \ \ \ \ \ \ 12\)
$BR
\(Black \ \ \ \ \ \ \ 1 \ \ \ \ \ \ \ 2 \ \ \ \ \ \ \ \ 3\)
$PAR
First lets notice that every number in the second row is equal to the
number in the number above it divided by four, or, said in another way,$BR
every number in the first row is four times the number below it. Should
this be surprising?$PAR
If you think it over, it should not be surprising. Since it takes four green
units to make a black unit, the number of green units it takes to add
up to a certain length$BR should be four times the number of black units. or, in
other words, the number of black units it takes to add up to that length should be one quarter of the number of green units.
$PAR
Now lets talk about this example in one more way, replacing our "color"
language by "unit" language$BR
It takes four times as many quarter-units to make a number as it takes units.
It takes one quarter the number of units to make a number as it takes quarter-units.
$PAR
Let's see if you are comfortable with these ideas.
$PAR
It takes \{ans_rule(1)\} quarter-units to make 4 units.
$PAR
It takes 24 quarter-units to make \{ans_rule(1)\} units.


$PAR
END_TEXT
##############################################################
#
# Answers


ANS(Real (16)-> cmp);
ANS(Real (6)-> cmp);
} #end of part 5

##############################################
#
# Part 6
#

if ($part == 6) {


BEGIN_TEXT
Part 6:
You have been very patient to do all this thinking without knowing why we were
doing all this. Now you will see the reason.
$PAR
In the work in the last two parts we have only compared numbers of units and
quarter units that were integers (whole numbers). If we change our language
a bit $BR we can say what we have said in Part 5 in another way.
$PAR
What your answers to the last two questions said can be explained as$BR
\(16\times \frac{1}{4} =4\) and \(24\times \frac{1}{4}=6\), or more simply
\(\frac{16}{4} =4\) and \(\frac{24}{6}=4\).
$PAR
This probably does not surprise you too much but what comes next might be
a surprise. We will use the same reasoning to extend our table and see
what happens.
$PAR
\(Green \ \ \ \ \ \ \ 4 \ \ \ \ \ \ \ 8 \ \ \ \ \ \ \ 12\ \ \ \ \ \ 1\ \ \ \ \ \ \ . \)\{ans_rule(1)\}
$BR
\(Black \ \ \ \ \ \ \ 1 \ \ \ \ \ \ \ 2 \ \ \ \ \ \ \ \ 3\ \ \ \ \ . \)\{ans_rule(2)\}\(.\ \ \frac{3}{4}\)
$PAR


END_TEXT
##############################################################
#
# Answers


ANS( Real(3)->cmp,Real(1/4)->cmp);

} #end of part 6

##############################################
#
# Part 7
#


if ($part == 7) {

BEGIN_TEXT
Part 7:
Now remember that from the fact that 24 was above 6 in our table and that
there are 4 green units in each black unit, we deduced
that $BR
\(\frac{24}{6}=4\)
$PAR Now if we use the fact that 1 is above \(\frac{1}{4}\) in our table and
there are 4 green units in each black unit, we see that
$PAR
\(\frac{1}{(\frac{1}{4})}=4\).
$PAR
Looking again at our table, we see that \(\frac{3}{(\frac{3}{4})}=4\).
$PAR
This illustrates the fact that we can divide by a fraction by inverting
(turning over) the fraction in the denominator and multipying it by the
numerator.$BR For example, since \(\frac{3}{(\frac{3}{4})}=4\) we can
dividing both sides by 3 to see that \(\frac{1}{(\frac{3}{4})}=\frac{4}{3}\)
$PAR
So, for example, if we wanted to divide \(\frac{9}{4}\) by \(\frac {3}{8}\)
and wanted to end up with a reduced fraction $BR
(no integer greater than 1 dividing
both numerator and denominator) we would proceed as follows:
$PAR
\( \frac{(\frac {9}{4})}{(\frac{3}{8})}= \frac {9}{4}\times \frac{8}{3}=\frac{72}{12}=6\)
$PAR
Now you can try a few:

$PAR
\(\frac{(\frac {9}{4})}{(\frac {27}{8})}}=\) \{ans_rule(1)\}
$PAR
\(\frac{(\frac {11}{9})}{(\frac {77}{45})}=\) \{ans_rule(1)\}
$PAR
\(\frac{100}{(\frac {75}{4})}=\) \{ans_rule(1)\}
END_TEXT
##############################################################
#
# Answers


ANS(Real (2/3)-> cmp);
ANS(Real (5/7)-> cmp);
ANS(Real (16/3)-> cmp);

} #end of part 7

##############################################
#
# Part 8

if ($part == 8) {

BEGIN_TEXT



END_TEXT
##############################################################
#
# Answers
ANS( Real(1)->cmp);

ANS(Real (Real (102)->cmp);
} #end of part 8
ENDDOCUMENT()
##############################################
#
# Part 9
#


if ($part == 9) {

Context()->texStrings;

BEGIN_TEXT
Part 9: Here we get the next digit of the quotient
$PAR
=\{ans_rule(1)\}
END_TEXT
##############################################################
#
# Answers

Context("LimitedNumeric");
ANS( Real(46)->cmp,Real(109)->cmp,Real(102 )->cmp ,Real(7 )->cmp) ;

} #end of part 9
##############################################
#
# Part 10
#


if ($part == 10) {
##############################################
#
# Part 9
#


if ($part == 9) {

Context()->texStrings;

BEGIN_TEXT
Part 9: Here we get the next digit of the quotient
$PAR
=\{ans_rule(1)\}
END_TEXT
##############################################################
#
# Answers

Context("LimitedNumeric");
ANS( Real(46)->cmp,Real(109)->cmp,Real(102 )->cmp ,Real(7 )->cmp) ;

} #end of part 9
##############################################
#
# Part 10
#


if ($part == 10) {

Context()->texStrings;

BEGIN_TEXT
Part 10: Here we finish the problem.
$PAR
\{ans_rule(1)\}
END_TEXT
##############################################################
#
# Answers

Context("LimitedNumeric");
ANS( Real(464)->cmp,Real(72)->cmp,Real(68) ->cmp ,Real(4 ) ->cmp ) ;

} #end of part 10
##############################################
#

ENDDOCUMENT()

Part 8:
Now that you have gotten this far, we can mention one more
interesting thing that you can do with what you have learned. $BR
Sometimes it is important to know which of two fractions is larger.
When the fractions are ugly, this can look difficult. $BR. For
example, you might be asked which of \(\frac{203}{307}\) and
\(\frac{29}{44}\) is larger.

$PAR
Here is an easy way to think about this kind of problem. Suppose a number a
is less than a number b. Which of the three statements below is true:
$PAR
1) \(\frac{a}{b} <1\)
$PAR
2) \(\frac{a}{b} =1\)
$PAR
3) \(\frac{a}{b} >1\)
$PAR The true statement is the one with label \{ans_rule(1)\})

Ken Appel
The compoundProblem.pl file was not keeping track of the necessary state information for on-the-fly graphics. I have modified it so that it will handle the graphics properly now. You should update your copy of compoundProblem.pl from the CVS repository (the Union library in the examples/compoundProblem directory).

Davide

WeBWorK Problems -> graphmacros in compound problems

by Kenneth Appel -
I made up a compound problem in which I created
graphs using graphmacros in several of the parts.
I made it up a part at a time and the appropriate
graphs appeared as I was making up the problem.

When I tried to run it, the graph from the first
part appeared again in the second part (in place
of the appropriate part. Is there something I should have done to clear things so that the appropriate graph would appear.
Ken Appel

WeBWorK Problems -> contextLimitedPolynomial

by Kenneth Appel -
Davide,
In revising some working problems that are written for rather stilted str_cmp
type answers I decided to try out contextLimitedPolynomial. I seem to have
done something quite wrong, but the warning message leaves me puzzled. In
particular, besides the error message, it gives me the answer of a number although I can't see anywhere that x is given a value.
Here is the code

#DESCRIPTION
##Type of
#ENDDESCRIPTION

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
#"PGgraphmacros.pl",
"MathObjects.pl",
# "compoundProblem.pl",
# "unionLists.pl",
#"unionMacros.pl",
"contextLimitedPolynomial.pl",

);
Context("Numeric");
Context()->variables->are(x=>'Real',y=>'Real');
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$a = random(6,9,1);
$b = random(3,7,1);


$e=random(2,6,2);
$f=random(3,7,2);

BEGIN_TEXT
$PAR
Simplify each of the following expressions

$PAR
\(($a+$b x^2+$e x^3)($f x-12(x+1))\)= \{ans_rule(15)\}
$PAR


END_TEXT
Context("LimitedPolynomial")->flags->set(singlePowers=>1);
Context()->variables->are(x=>'Real',y=>'Real');

ANS(Formula(($a+$b*x**2+$e*x**3)*($f*x-12*(x+1)))->cmp);

ENDDOCUMENT()

Warning messages (note that line numbers no longer

correspond since I have edited out some irrelevant text The line nmber is
referred to is the answer line.

  • Operator or semicolon missing before *x at line 43 of (eval 154932)
  • Ambiguous use of * resolved as operator * at line 43 of (eval 154932)
  • Operator or semicolon missing before *x at line 43 of (eval 154932)
  • Ambiguous use of * resolved as operator * at line 43 of (eval 154932)
  • Operator or semicolon missing before *x at line 43 of (eval 154932)
  • Ambiguous use of * resolved as operator * at line 43 of (eval 154932)


WeBWorK Problems -> Limiting operations allowed in formulas

by Kenneth Appel -
Davide,
This may be asking too much. I originally had this working with
str_cmp but realized that I wanted to allow alternative forms.
However, when I made the change to Context()->variables...
I forgot that unsimplified answers would be accepted. Is there
any way to modify Context()->variables to require answers without
sums of integers?
Ken

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
#"PGgraphmacros.pl",
# "MathObjects.pl",
# "compoundProblem.pl",
#"contextCurrency.pl",
#"contextInequalities.pl",
# "unionLists.pl",
#"unionMacros.pl",
"contextLeadingZero.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$a = random(6,9,1);
$b = random(3,7,1);
$c=$a+$b;

$e=random(2,6,2);
$f=random(3,7,2);
$c1=$e*$f;

$c2=$b*$f;


BEGIN_TEXT
$PAR
Simplify each of the following expressions

$PAR
\(($a+m)+$b\) \{ans_rule(5)\}
$PAR
\($e\cdot(k\cdot $f)\) \{ans_rule(5)\}
$PAR
\($b(x + $f)\) \{ans_rule(5)\}
END_TEXT
Context("Numeric");
Context()->variables->are(k=>'Real', m=>'Real', x=>'Real');


ANS(Formula("m+$c")->cmp);
ANS(Formula("$c1*k")->cmp);
ANS(Formula("$b*x+$c2")->cmp);



ENDDOCUMENT()