[npl] / trunk / NationalProblemLibrary / Rochester / setAlgebra14Lines / lh2-1_1.pg Repository:
ViewVC logotype

View of /trunk/NationalProblemLibrary/Rochester/setAlgebra14Lines/lh2-1_1.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 202 - (download) (annotate)
Mon May 8 17:05:32 2006 UTC (7 years, 1 month ago) by jjholt
File size: 4190 byte(s)
Added tags.

    1 ##DESCRIPTION
    2 ##   Algebra: Lines
    3 ##ENDDESCRIPTION
    4 
    5 ##KEYWORDS('Algebra', 'Lines')
    6 ##Tagged by up2p
    7 
    8 ##DBsubject('Algebra')
    9 ##DBchapter('Coordinates and Graphs')
   10 ##DBsection('Lines')
   11 ##Date('')
   12 ##Author('')
   13 ##Institution('Rochester')
   14 ##TitleText1('')
   15 ##EditionText1('')
   16 ##AuthorText1('')
   17 ##Section1('')
   18 ##Problem1('')
   19 
   20 DOCUMENT();        # This should be the first executable line in the problem.
   21 
   22 loadMacros(
   23 "PG.pl",
   24 "PGbasicmacros.pl",
   25 "PGchoicemacros.pl",
   26 "PGanswermacros.pl",
   27 "PGauxiliaryFunctions.pl",
   28 "PGgraphmacros.pl",
   29 "extraAnswerEvaluators.pl"
   30 
   31 );
   32 
   33 TEXT(beginproblem());
   34 $showPartialCorrectAnswers = 0;
   35 
   36 # Define the graph
   37 $graph = init_graph(-10,-10,10,10,'axes'=>[0,0],'grid'=>[20,20],'size'=>[300,300]);
   38 
   39 # create a scrambled list of colors and letters.
   40 # Here are the basic colors
   41 @colors = ("blue", "red", "green");
   42 # Slice will contain the numbers 1,2,3 in some permuted order
   43 @slice = NchooseK(3,3);
   44 # The slice of the color list (sc) contains the colors in a new order defined by the ordering in @slice.
   45 # This construction @array[@slice] is the way to apply a permutation to a list.
   46 @sc = @colors[@slice];  #scrambled colors
   47 
   48 # Now we scrambel the letters labeling the graphs using the same permutation.
   49 # These list will contain the correct answers in the proper order.
   50 @sa = ('L1','L2','L3')[@slice];
   51 
   52 # Now that we have permuted colors in @sc and permuted letters in @sa we are ready to define the function.
   53 $dom = 10;
   54 $a=random(0.2,2, .1);
   55 $b=random(-4, -2, .5);
   56 $c=random(-2,-0.2,0.1);
   57 $d=random(4,7, .5);
   58 $e=random($b-$a+1, -.5);
   59 
   60 $f = FEQ("$a x + $b for x in <-$dom,$dom> using color:$sc[0] and weight:2");
   61 $f1 = FEQ("$c x+$d   for x in <-$dom,$dom> using color=$sc[1] and weight:2");
   62 $f2 = FEQ("$e for x in <-$dom,$dom> using color=$sc[2] and weight=2");
   63 
   64 # Install the functions into the graph object.
   65 # Plot_functions converts the string to a subroutine which performs the necessary calculations and
   66 # asks the graph object to plot the functions.
   67 ($fRef,$f1Ref,$f2Ref) = plot_functions( $graph, $f,$f1,$f2
   68                            );
   69 # The output of plot_functions is a list of pointers to functions which contain the appropriate data and methods.
   70 # So $fpRef->rule points to the method which will calculate the value of the function.
   71 # &{$fpRef->rule}(3) calculates the value of the function at 3.  See Fun.pm for more details.
   72 
   73 # create labels for each function
   74 # The 'left' tag determines the justification of the label to the defining point.
   75 
   76 $label_point=-1;
   77 $label_f = new Label ( $label_point,&{$fRef->rule}($label_point),$sa[0],$sc[0],'left')        ;
   78 
   79 # NOTE: $fRef->ruleis a reference to the subroutine which calculates the
   80 # function.  It was defined in the output of plot_functions. It is used here to calculate the y value of the label corresponding to the function,
   81 # and below to find the y values for the labels corresponding to the
   82 # first and second derivatives.
   83 
   84 $label_f1 = new Label ( $label_point,&{$f1Ref->rule}($label_point),$sa[1],$sc[1],'left','bottom')      ;
   85 
   86 # Place the second letter in the permuted letter list at the point (-.75, f1(-.75)) using
   87 # the second color in the permuted color list.
   88 
   89 $label_f2 = new Label ( $label_point,&{$f2Ref->rule}($label_point),$sa[2],$sc[2],'left');
   90 
   91 # insert the labels into the graph
   92 $graph->lb($label_f,$label_f1,$label_f2);
   93 
   94 
   95 # Make a new match list
   96 $ml = new_match_list();
   97 
   98 # enter questions and matching answers
   99 $ml -> qa (
  100 "The slope of line \($sa[0]\)",
  101 "\( m=$a \)",
  102 "The slope of line \($sa[1]\)",
  103 "\( m=$c \)",
  104 "The slope of line \($sa[2]\)",
  105 "\( m=0 \)"
  106 );
  107 
  108 # Choose four of the question and answer pairs at random.
  109 $ml ->choose(3);
  110 
  111 # Now print the text using $ml->print_q for
  112 # the questions and $ml->print_a to print the answers.
  113 
  114 
  115 BEGIN_TEXT
  116 $BR
  117 
  118 \{ image(insertGraph($graph), width=>300, height=>300) \} $PAR
  119 Match the Lines L1 (blue), L2 ( red) and L3 (green) with the slopes
  120 by placing the letter of the slopes next to each set listed below: $BR
  121 \{ $ml -> print_q \}
  122 $PAR
  123 \{$ml -> print_a \}
  124 END_TEXT
  125 ANS(str_cmp( $ml->ra_correct_ans )   ) ;
  126 
  127 ENDDOCUMENT();        # This should be the last executable line in the problem.

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9