Advertisement
Guest User

Bad PG Code

a guest
Mar 20th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.24 KB | None | 0 0
  1. # DESCRIPTION
  2. # Find the slope, intercept, and a point on a line.
  3. # This is just an example;
  4. # I'm well aware that the third part could be waiting for a "no"
  5. # when the correct answer would be "yes."
  6. # ENDDESCRIPTION
  7.  
  8. ## DBsubject('Algebra')
  9. ## DBchapter('Linear Equations')
  10. ## DBsection('Graphing')
  11. ## KEYWORDS('linear','graph')
  12. ## TitleText1('')
  13. ## EditionText1('')
  14. ## AuthorText1('')
  15. ## Section1('')
  16. ## Problem1('')
  17. ## Author('')
  18. ## Institution('')
  19.  
  20. DOCUMENT();
  21. loadMacros(
  22. "PGstandard.pl",
  23. "MathObjects.pl",
  24. "PGchoicemacros.pl",
  25. );
  26.  
  27. Context("Numeric");
  28.  
  29. $m=random(-10,10-1);
  30. $b=random(-10,10-1);
  31. $x=random(-10,10-1);
  32. if(random(0,1,1))
  33. {
  34.     $y=$m*$x+$b;
  35.     $c="Yes";
  36. }
  37. else
  38. {
  39.     $y=random(-10,10,1);
  40.     $c="No";
  41. }
  42. $line=Compute("$m x+$b");
  43. $m=Compute("$m");
  44. $b=Compute("$b");
  45.  
  46. $mc = new_multiple_choice();
  47. $mc->qa("Is the point \(P($x,$y)\) on this line?",$c);
  48. $mc->makeLast("Yes","No");
  49.  
  50. TEXT(beginproblem());
  51. Context()->texStrings;
  52. BEGIN_TEXT
  53. Given the line \(y=$line\),$BR
  54. What is the slope? \{ans_rule(2)\} $BR
  55. What is the y-intercept? \{ans_rule(2)\} $BR
  56. \{ $mc->print_q() \}
  57. $BR
  58. \{ $mc->print_a() \}
  59. END_TEXT
  60. Context()->normalStrings;
  61.  
  62. ANS($m->cmp());
  63. ANS($b->cmp());
  64. ANS( radio_cmp( $mc->correct_ans() ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement