<?php
//IMathAS Install initial examples library
require("init.php");
if ($myrights<100) {
	echo "No rights";
	exit;
}
$stm = $DBH->query("SELECT * FROM imas_libraries WHERE uniqueid = 1143581427433 ");
if ($stm->rowCount()>0) {
	echo "Library already exists; aborting";
	exit;
}
$stm = $DBH->query('INSERT INTO `imas_libraries` (`id`, `uniqueid`, `adddate`, `lastmoddate`, `name`, `ownerid`, `userights`, `parent`, `groupid`) VALUES (1, 1143581427433, 1227157541, 1227157541, \'Examples\', 1, 8, 0, 0);');

$query = 'INSERT INTO `imas_library_items` (`id`, `libid`, `qsetid`, `ownerid`) VALUES (1, 1, 1, 1),
(2, 1, 2, 1),
(3, 1, 3, 1),
(4, 1, 4, 1),
(5, 1, 5, 1),
(6, 1, 6, 1),
(7, 1, 7, 1),
(8, 1, 8, 1),
(9, 1, 9, 1),
(10, 1, 10, 1),
(11, 1, 11, 1),
(12, 1, 12, 1),
(13, 1, 13, 1),
(16, 1, 14, 1),
(17, 1, 15, 1),
(18, 1, 16, 1),
(20, 1, 17, 1),
(24, 1, 18, 1),
(25, 1, 19, 1),
(26, 1, 20, 1),
(27, 1, 21, 1),
(28, 1, 22, 1),
(29, 1, 23, 1),
(30, 1, 24, 1),
(32, 1, 25, 1),
(33, 1, 26, 1),
(34, 1, 27, 1),
(35, 1, 28, 1),
(36, 1, 29, 1),
(42, 1, 30, 1),
(43, 1, 31, 1),
(44, 1, 32, 1),
(46, 1, 33, 1),
(51, 1, 34, 1),
(58, 1, 35, 1);';
$DBH->query($query);

$query = 'INSERT INTO `imas_questionset` (`id`, `uniqueid`, `adddate`, `lastmoddate`, `ownerid`, `author`, `userights`, `description`, `qtype`, `control`, `qcontrol`, `qtext`, `answer`, `extref`, `hasimg`, `ancestors`)
VALUES
(1, 11435814263779, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of function type\', \'numfunc\', \'$a,$b = nonzerodiffrands(-8,8,2)\\n//when using functions, define the variables in the\\n//function, including letter constants.  Defaults to x\\n$variables = "x"\\n\\n//this defines the domain on which the correct and given\\n//answers will be compared.  Defaults to -5 to 5\\n$domain = "-5,5"\\n\\n//this prepends the answer box with a string.\\n$ansprompt = "Ans="\\n\\n$p = $a - $b;\\n//the answer is a function, as a string\\n$answer = "x^($p)"\\n$showanswer = "`x^$a/x^$b = x^($a-($b)) = x^$p" if ($p>0)\\n$np = -1*$p\\n$showanswer = "`x^$a/x^$b = x^($a-($b)) = x^$p = 1/x^$np" if ($p<0)\\n\\n//to force a specific format, use $requiretimes.\\n//in this case, it is requiring "^" to appear less than\\n//twice, and "-" to appear no times.  This is preventing\\n//unsimplified answers and negative exponents\\n$requiretimes = "^,<2,-,=0,x,=1"\', \'\', \'Simplify `x^$a/x^$b`\\n<BR>\\nWrite your answer with positive exponents only.\', \'\', \'\', 0, \'\'),
(2, 11435814263780, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of Matching type 2\', \'matching\', \'$qarr = array("`sin x`","`cos x`","`x^2`","`x^3`","`e^x`","`log x`","`2^x`")\\n$aarr = array("`cos x`","`-sin x`","`2x`","`3x^2`","`e^x`","`1/x`","`2^x ln2`")\\n\\n//this jointly shuffles the arrays (retaining respective\\n//pairing), and picks 4 elements of the $qarr, and 5\\n//elements of the $aarr.\\n$questions,$answers = jointshuffle($qarr,$aarr,4,5)\\n\\n//this titles the list of questions and answers\\n$questiontitle = "`f(x)`"\\n$answertitle = "`f\\\'(x)`"\', \'\', \'Match each function with it\\\'s derivative.\', \'\', \'\', 0, \'\'),
(3, 11435814263782, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of calculated matrix type\', \'calcmatrix\', \'//if $answersize is specified, the user will be provided\\n//an array of boxes in which to enter their answer.  If\\n//not, they will be required to use ASCIIMath format for\\n//their answer, like ((1,2,3),(4,5,6))\\n$answersize="2,3"\\n\\n//load in matrix functions\\nloadlibrary("matrix")\\n//form the matrices\\n$a = rands(1,9,6)\\n$ma = matrix($a,2,3)\\n$b = rands(1,9,6)\\n$mb = matrix($b,2,3)\\n\\n//display forms\\n$mad = matrixformat($ma)\\n$mbd = matrixformat($mb)\\n\\n//calculate the answer\\n$mans = matrixsum($ma,$mb)\\n$answer = matrixformat($mans)\', \'\', \'Add: `$mad + $mbd`\', \'\', \'\', 0, \'\'),
(4, 11435814263784, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of using loadlibrary to access functions in a macro file (mean from stats library in this case)\', \'number\', \'//this loads the stats library.  Admins can load new macro\\n//libraries to extend IMathAS.  The Macro Library Help link\\n//will show what libraries are currently installed.\\nloadlibrary("stats")\\n\\n$a = nonzerodiffrands(1,10,5)\\n\\n//this is a standard display macro that creates\\n//a table display of the array $a with title "x"\\n$table = showarrays("x",$a)\\n\\n//here we are using the mean function from the stats\\n//library to determine the answer\\n$answer = mean($a)\', \'\', \'Find `bar x`\\n\\n$table\', \'\', \'\', 0, \'\'),
(5, 11435814263786, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of Matching type\', \'matching\', \'$a,$b,$c = rands(-3,3,3)\\n\\n//shuffles the list of colors\\n$cols = singleshuffle("red,green,blue")\\n\\n//this uses the showplot macro.  The first argument is a\\n//single function or an array of functions.  In this case,\\n//we\\\'re only specifying the function and the color.  There\\n//are other options available.\\n$graphs = array("$a*x^2+$b*x+$c,$cols[0]","2*$a*x+$b,$cols[1]","$a*x^3/3+$b*x^2/2+$c*x,$cols[2]")\\n\\n//these set titles for the list of questions and answers\\n$questiontitle = "Function"\\n$answertitle = "Graph Color"\\n\\n//this actually calls the showplot macro.  After the\\n//function, the window is specified, then the\\n//labels are off, and grid is set to false\\n$plot = showplot($graphs,-3,3,-5,5,off,false)\\n\\n//this defines the questions and answers.  Note that they\\n//are matched - the first entry in $answers is the answer\\n//the the first entry in $questions.\\n$answers[0] = "<span class=white style=\\\'color:$cols[0]\\\'>$cols[0]</span>"\\n$answers[1] = "<span class=white style=\\\'color:$cols[1]\\\'>$cols[1]</span>"\\n$answers[2] = "<span class=white style=\\\'color:$cols[2]\\\'>$cols[2]</span>"\\n$questions = array("`f(x)`","`f\\\'(x)`","`int f(x)dx`")\', \'\', \'Match each function with its graph\\n\\n$plot\', \'\', \'\', 0, \'\'),
(6, 114358142637105, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of multipart\', \'multipart\', \'//this defines that there will be two parts, both of\\n//type calculated.  Refer the help for valid anstypes.\\n$anstypes = array("calculated","calculated")\\n$a,$b = nonzerodiffrands(-8,8,2)\\n$c = nonzerorand(-30,30)\\n\\n$question = makeprettydisp("$a x + $b y=$c")\\n\\n//in some multipart questions, it might be useful to hide\\n//the preview button usually provided with calculated and\\n//function answer types.  You can set $hidepreview to\\n//hide the preview button.  Note that it is suffixed with\\n//a [1].  This specifies to apply the option to the\\n//second calculated type.  All options must be suffixed\\n//like this in a multipart problem.\\n$hidepreview[1] = true\\n\\n//Note the use of the $answerbox in the question text.  This places the\\n//answerboxes in the problem text.  Make sure you put the\\n//boxes in numerical order; entry tips are given assuming\\n//this.\\n\\n//like with other options, the $answer also needs to be\\n//suffixed with the question part.\\n$answer[0] = $c/$a\\n$answer[1] = $c/$b\', \'\', \'Find the x and y intercepts of $question\\n\\nx-int: `x=`$answerbox[0]\\n\\ny-int: `y=`$answerbox[1]\', \'\', \'\', 0, \'\'),
(7, 114358142637107, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of Number type.\', \'number\', \'//a nonzero random number between -5 and 5\\n$a = nonzerorand(-5,5)\\n\\n//a decimal number between -5 and 5, with one decimal\\n//we\\\'re going to ensure that $a and $b are different signs\\n//using the "if" conditional\\n$b = rrand(.1,5,.1) if ($a < 0)\\n$b = rrand(-5,-.1,.1) if ($a > 0)\\n\\n//two different, nonzero integers\\n$c,$d = nonzerodiffrands(-5,5,2)\', \'//this could show up as:  -4 + -2.3 + 3 + -1\\n//the backquotes (`) tell it to display as math\\n$prob = "`$a + $b + $c + $d`";\\n\\n//if we want to simplify it like: -4 - 2.3 + 3 - 1\\n$prob2 = makeprettydisp("$a + $b + $c + $d")\', \'Find: $prob\\n\\nor equivalently: $prob2\', \'//for number, we just need to specify the answer.  No\\n//quotes here because we\\\'re calculting, not creating\\n//a display string\\n$answer = $a + $b + $c + $d\\n\\n//by default, numbers are allowed a .001 relative error.\\n//$reltolerance = .0001 would require a higher accuracy\\n//$abstolerance = .01 would require an absolute error\\n//   under .01\\n//$answer = "[-10,8)" would accept any answer where\\n// -10 <= givenanswer < 8\', \'\', 0, \'\'),
(8, 114358142637108, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of calculated type.\', \'calculated\', \'//choose two numbers from a list.  Can also choose from\\n//an array\\n$a,$b = randsfrom("2,3,5,7,11",2)\\n\\n//the "where" statement is used with randomizers. It allows\\n//you to avoid a specific case.  In this case, we requiring\\n//that $a not divide evenly into $c.\\n$c = rand(1,10) where ($c % $a != 0)\\n$d = rand(1,10) where ($d % $b != 0)\\n\\n//note that the student could enter 2/5*6/7 and get the\\n//correct answer.  We can prevent this by adding this line\\n$answerformat = "reducedfraction"\\n\\n//like with the Number type, we supply a number as the\\n//answer.  The only difference is that the student can\\n//enter a calculation instead of a number\\n$answer = $c/$a * $d/$b\\n\\n//to get the answer to display as a fraction rather than a\\n//decimal, we need to define $showanswer\\n$showanswer = dispreducedfraction($c*$d,$a*$b)\', \'\', \'Multiply: `$c/$a * $d/$b`\\n\\nEnter your answer as a single, reduced fraction\', \'\', \'\', 0, \'\'),
(9, 114358142637109, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of multiple-choice\', \'choices\', \'//pick two different nonzero numbers that don\\\'t add to 0\\n//the numbers are important here to ensure that all the\\n//choices will be different.\\n$a,$b = nonzerodiffrands(-5,5,2)\\n\\n//we can either define the entire $questions array\\n//at once, or define each piece separately.  The former\\n//would look like:  $questions = array($a+$b,$a-$,...\\n$questions[0] = $a+$b\\n$questions[1] = $a-$b\\n$questions[2] = $a*$b\\n\\n//this will lay out the choices horizontally.  To do\\n//a standard vertical layout, just omit this line\\n$displayformat = "horiz"\\n\\n$text = makeprettydisp("$a+$b")\\n\\n//Here the answer is the INDEX into the questions array\\n//that holds the correct answer.  Arrays are zero-indexed,\\n//so the first entry is at index 0.\\n$answer = 0\', \'\', \'Find $text\', \'\', \'\', 0, \'\'),
(10, 114358142637110, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of Multiple-Answer type\', \'multans\', \'//the $questions array is a list of the options.\\n//The listtoarray macro converts a list of numbers or\\n//strings to an array.  Use calclisttoarray to convert\\n//a list of calculations to an array of numbers\\n$questions = listtoarray("`sin(x)`,`sin^-1(x)`,`tan(x)`,`csc(x)`,`x^2`");\\n\\n//the answer here is a list of indexes into the $questions\\n//array that contain correct answers.  Remember that\\n//arrays are 0-indexed\\n$answers = "0,2,3"\\n\\n//Normally, each part is given equal weight.  If you wish\\n//to divide the point score only by the number of correct\\n//answers, use this line:\\n//$scoremethod = "answers"\', \'\', \'Select all the functions that are periodic\', \'\', \'\', 0, \'\'),
(11, 114358142637111, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of graph capabilities\', \'multipart\', \'$anstypes = listtoarray("number,number,number,number")\\n\\n//for each graph, it\\\'s:\\n//function,color,xmin,xmax,startmark,endmark\\n$graphs[0] = "-x-5,black,-5,-1,,closed"\\n$graphs[1] = "-2x+3,black,-1,2,open"\\n$graphs[2] = "-2x+3,black,2,5,open"\\n//last one is really just a dot, but we define it as\\n//a function\\n$graphs[3] = "2,black,2,2,closed"\\n\\n//graphs,xmin,xmax,ymin,ymax,labels,grid\\n$plot = showplot($graphs,-5,5,-5,5,1,1)\\n\\n//the backslashes above add extra spacing between the\\n//limit and the f(x)\\n\\n//this question isn\\\'t randomized\\n$answer[0] = 5\\n$answer[1] = -4\\n$answer[2] = "DNE"\\n$answer[3] = -1\', \'\', \'The graph below is the function `f(x)`\\n\\n$plot\\n\\nFind `lim_(x-&gt;-1^+)\\\\ \\\\ f(x)`  $answerbox[0]\\n\\nFind `lim_(x-&gt;-1^-)\\\\ \\\\ f(x)`  $answerbox[1]\\n\\nFind `lim_(x-&gt;-1)\\\\ \\\\ f(x)`  $answerbox[2]\\n\\nFind `lim_(x-&gt;2)\\\\ \\\\ f(x)` $answerbox[3]\', \'\', \'\', 0, \'\'),
(12, 1144000847040400, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'plot3d example\', \'choices\', \'loadlibrary("plot3d")\\n\\n$graph = spacecurve("[cos(t),sin(t),t]",0,10,50)\\n\\n$plot = plot3d("x^2+y^2",-2,2,-2,2)\\n\\n$questions = array("A","B")\\n$answer = 0\', \'\', \'A: $graph\\n\\nB: $plot\\n\\nWhich of the graphs above is a spacecurve?\', \'\', \'\', 0, \'\'),
(13, 1151342979988855, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'labeling graphs example\', \'numfunc\', \'$a,$b = diffrands(1,5,2)\\n$eqns = array("$a*cos(pi/2*x)","$b*sin(pi/2*x)")\\n$m = max($a,$b)\\n$plot = showplot($eqns,-3,3,-1*$m-1,$m+1)\\n$plot = addlabel($plot,0,$a,"f(x)","black","above")\\n$plot = addlabel($plot,1,$b,"g(x)","black","above")\\n\\n$answer = "$a*cos(pi/2*x)+$b*sin(pi/2*x)"\\n$showanswer = makeprettydisp($answer)\', \'\', \'$plot\\n\\nLet `h(x)=f(x)+g(x)`\\n\\nWrite an equation for `h(x)`\\n\\n`h(x)`= $answerbox\', \'\', \'\', 0, \'\'),
(14, 1141954525122484, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Solve matrix equation\', \'matrix\', \'loadlibrary("matrix")\\n$mat = matrixidentity(3)\\n//silly approach to guarantee a nonsingular matrix\\n$a,$b,$c = nonzerorands(-3,3,3)\\n$mat = matrixrowcombine3($mat,0,$a,1,$b,2,$c,0)\\n$a,$b,$c = nonzerorands(-3,3,3)\\n$mat = matrixrowcombine3($mat,0,$a,1,$b,2,$c,1)\\n$a,$b,$c = nonzerorands(-3,3,3)\\n$mat = matrixrowcombine3($mat,0,$a,1,$b,2,$c,2)\\n\\n$x = matrix(rands(-3,7,3),3,1)\\n$rs = matrixprod($mat,$x)\\n\\n$md = matrixformat($mat)\\n$rsd = matrixformat($rs)\\n\\n$answer = matrixformat($x)\\n$answersize = "3,1"\', \'\', \'Solve: `$md \\\\ vec x = $rsd`\\n\\n`vec x` = $answerbox\', \'\', \'\', 0, \'\'),
(15, 1159820322266971, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Linear inequalities in 2 variables\', \'calculated\', \'loadlibrary("ineq")\\n\\n$eqns = array("-x+2,below","x^2-3,above,black,dash","x+1,below")\\n$graph = ineqbetweenplot($eqns ,-5,5,-5,5)\\n\\n$eqns = array("-x+2,abovediag,green,black,dash","2x+1,belowdiag,blue")\\n$graph2 = ineqplot($eqns,-5,5,-5,5)\', \'\', \'$graph\\n\\n$graph2\', \'\', \'\', 0, \'\'),
(16, 1173417960546095, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'List of numbers example\', \'number\', \'$answerformat = "list"\\n\\n$a,$b = nonzerodiffrands(-5,5,2)\\n\\nloadlibrary("polys")\\n\\n$p = formpoly(array(1,$a+$b,$a*$b),2)\\n$wp = writepoly($p)\\n\\n$answer = "$a,$b"\', \'\', \'Solve the equation `$wp = 0`\\n\\nEnter all solutions below as a list of numbers, separated with commas\', \'\', \'\', 0, \'\'),
(17, 1168537684869012, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Add polynomials: demo of polys macro library\', \'numfunc\', \'loadlibrary("polys")\\n//loads polynomial macro library.  See Macro Library Help for syntax info\\n$A=nonzerodiffrands(-12,12,6)\\n$B=nonzerodiffrands(-12,12,6)\\n\\n$r1,$r2=diffrands(0,5,2)\\n$s1,$s2=diffrands(0,5,2)\\n\\n$A[$r1]=0\\n$A[$r2]=0\\n$B[$s1]=0\\n$B[$s2]=0\\n\\n$p1 = formpoly($A,5)\\n$p2 = formpoly($B,5)\\n\\n$pd1 = writepoly($p1)\\n$pd2 = writepoly($p2)\\n\\n$answer = writepoly(addpolys($p1,$p2))\\n\\n\\n$answerboxsize=40\', \'\', \'Add the polynomials:\\n\\n`($pd1)+($pd2)`\', \'\', \'\', 0, \'\'),
(18, 1171578622923677, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of a Sets question\', \'multipart\', \'$anstypes = array("string","string","string","choices","choices")\\n$all = listtoarray("a,b,c,d,e,f,g,h,i,j,k,m")\\n\\n$a = diffrandsfrom($all,rand(5,7))\\n$a = sortarray($a)\\n$dispa = arraytolist($a)\\n$b = diffrandsfrom($all,rand(5,7))\\n$b = sortarray($b)\\n$dispb = arraytolist($b)\\n\\n$union = unionarrays($a,$b)\\n$intersect = intersectarrays($a,$b)\\n\\n$strflags = "ignore_case=1,remove_whitespace=1,ignore_order=1,ignore_commas=1"\\n\\n$answer[0] = arraytolist($union)\\n$answer[1] = arraytolist($intersect)\\n$answer[2] = arraytolist(diffarrays($union,$intersect))\\n\\n$r = rand(0,1)\\n$questions[3] = array("A","B","both A and B")\\n$answer[3]= $r\\n$elinset = randfrom(diffarrays($a,$intersect)) if ($r==0)\\n$elinset = randfrom(diffarrays($b,$intersect)) if ($r==1)\\n//this is failsafe if the intersection = the set\\n$answer[3] = 2 if ($elinset==null)\\n$elinset = randfrom($intersect) if ($elinset==null)\\n\\n$noshuffle[3] = "all"\\n$displayformat[3] = "select"\\n\\n$r = rand(0,1)\\n$subset = sortarray(diffrandsfrom($a,rand(2,3))) if ($r==0)\\n$subset = sortarray(diffrandsfrom($b,rand(2,3))) if ($r==1)\\n$dispsubset = arraytolist($subset)\\n//check if subset is also subset of other\\n$r = 2 if (intersectarrays($subset,$intersect)==$subset)\\n$questions[4] = array("A","B","both A and B")\\n$answer[4] = $r\\n\\n$noshuffle[4] = "all"\\n$displayformat[4] = "select"\', \'\', \'`A = { $dispa }`<br/>\\n`B = { $dispb }\\n\\nEnter the elements in each set, like: a,b,c\\n\\n`A uu B` = { $answerbox[0] }\\n\\n`A nn B` = { $answerbox[1] }\\n\\n`bar(A nn B)` = { $answerbox[2] }\\n\\n`$elinset in` $answerbox[3]\\n\\n`{ $dispsubset } sub` $answerbox[4]\', \'\', \'\', 0, \'\'),
(19, 1173048553489898, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of using hints\', \'calculated\', \'$a,$b,$c = diffrands(2,10,3)\\n\\n$answer = ($c-$a)/$b\\n\\n$hints[1] = "Subtract $b from both sides of the equation:  `$a x = $c - $b`"\\n$hints[2] = $hints[1]."<br/>Divide both sides of the equation by $a:  `x = ($c-$b)/$a`"\', \'\', \'Solve: `$a x + $b = $c`\\n\\nx = $answerbox\\n\\n$hintloc\', \'\', \'\', 0, \'\'),
(20, 1176587388361054, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'linegraph example using interval library and interval answer type\', \'interval\', \'loadlibrary("interval")\\n$ar = diffrands(-4,4,4)\\n$a,$b,$c,$d = sortarray($ar)\\n$ma,$mb,$mc,$md = rands(0,1,4) //markertypes - 0:open, 1:closed\\n\\n$intervals[0] = forminterval("-oo",$a,0,$ma)\\n$intervals[1] = forminterval($b,$c,$mb,$mc)\\n$intervals[2] = forminterval($d,"oo",$md,0)\\n\\n$plot = linegraph($intervals,-5,5)\\n\\n$answer = joinarray($intervals,\'\' U \'\')\', \'\', \'$plot\\n\\nWrite the intervals shown above.  Use oo for `oo`, -oo for `-oo`, U for union.\', \'\', \'\', 0, \'\'),
(21, 1176657334258688, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Domain question using Calculated Interval\', \'calcinterval\', \'$a,$b = nonzerodiffrands(-8,8,2) where (abs($a)>1)\\n\\n$inside = polymakepretty("$a x + $b")\\n\\n$ep = -1*$b/$a\\n$answer = "(-oo,$ep]" if ($a<0)\\n$answer = "[$ep,oo)" if ($a>0)\', \'\', \'Find the domain of `f(x) = sqrt($inside)`\\n\\n`x in` $answerbox\', \'\', \'\', 0, \'\'),
(22, 1177447790122431, 1227157541, 1227157816, 1, \'Lippman, David\', 2, \'Simple showplot Graphing Tutorial\', \'number\', \'$b = nonzerorand(-4,0)\\r\\n$end = rand(3,6)\\r\\n$plot = showplot("2*x-$b,red,-3,2,open,closed,1,nodash",-5,$end,-15,8,2,"1:2",400,300)\\r\\n\\r\\n//the input above graphs the following:\\r\\n//SPECIFIED INSIDE THE "  ", IS INFO ON THE GRAPHED FUNCTION\\r\\n//FROM LEFT TO RIGHT\\r\\n//2x - $b    y=2x+$b will be graphed\\r\\n//red        the line will be red\\r\\n//-3,2       The domain for the graph is (-3,2].\\r\\n//open       the left marker is open\\r\\n//closed     the right marker is closed\\r\\n//1          the pixel width of the graph is 1 (2 or higher produces thicker lines)\\r\\n//undashed   the line is not dashed. leaving this blank also provides a solid line. enter the word dash for a dashed line.\\r\\n//SPECIFIED OUTSIDE THE "   " BUT STILL INSIDE SHOWPLOT, IS INFO ON THE RECTANGULAR GRID.\\r\\n//FROM LEFT TO RIGHT\\r\\n//-5,$end      Horizontally, the grid starts at -5 and ends at the variable $end\\r\\n//-15,8        Vertically, the grid starts at -15 and ends at 8\\r\\n//2           means the x AND y axes has labels in increments of 2. If you want different increments, use "n:m" (see next parameter)\\r\\n\\r\\n//"1:2"     means the x axis has gridlines in increments of 1, the y axis in increments of 2\\r\\n//          Must be in quotes to specify different values.\\r\\n//          A single number WITHOUT quotes produces equal labeling\\r\\n//400       The graph is 400 pixels wide\\r\\n//300        The graph is 300 pixels high\\r\\n\\r\\n\\r\\n//addlabel(plot,x,y,"label",color,"location"])\\r\\n\\r\\n$plot = addlabel($plot,1,1,"(1,1)",red,"above")\\r\\n$plot = addlabel($plot,$end-.1,0,"t",blue,"above")\\r\\n$plot = addlabel($plot,0,7.5,"Population",green,"right")\\r\\n\\r\\n//HERE\\\'S HOW TO ADD LABELS. EACH ONE ADDS A DIFFERENT LABLE\\r\\n//FROM LEFT TO RIGHT INSIDE PARENS\\r\\n//$plot   is the name of the plot you add the label to\\r\\n//1,1     are the (x,y) coordinates where the label is to go\\r\\n//"(1,1)"  is the actual label. Put it in quotes\\r\\n//red     is the color of the label\\r\\n//"above"  specifies where the label goes relative to the label\\\'s coordinates. Can be\\r\\n//         "above" "below" "left" or "right"\', \'\', \'$plot\\r\\n\\r\\nSEE THE CODE FOR A SOMEWHAT DETAILED BREAKDOWN OF GRAPHING FUNCTIONS\', \'\', \'\', 0, \'\'),
(23, 1177459717818178, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Graphics using showasciisvg; geometric figures\', \'number\', \'//set border and window\\n$init = "setBorder(5); initPicture(-5,5,-5,5);"\\n\\n//set axes:  xscl, yscl, labels? (1 yes, null no), xgrid, ygrid\\n$axes = "axes(1,1,1,1,1);"\\n\\n//draw a line\\n$line = "line([-4,1],[-1,5]);"\\n\\n//draw a circle in red.  Note color changes apply to all future commands\\n$circ = "stroke=\\\\"red\\\\";circle([-4,-4],1);"\\n\\n//draw an ellipse in blue\\n$ellip = "stroke=\\\\"blue\\\\";ellipse([0,-2],3,2);"\\n\\n//draw a rectangle in green\\n$rect = "stroke=\\\\"green\\\\";rect([1,1],[3,2]);"\\n\\n//draw a filled triangle in cyan\\n$tri = "fill=\\\\"cyan\\\\";path([[4,5],[5,3],[2,4],[4,5]]);"\\n\\n//put some text in there\\n$a = rand(1,1000)\\n$text = "text([4,-2],\\\\"Hello$a\\\\");"\\n\\n//create our graphic by concatenating all the strings we just defined\\n$graphic = showasciisvg($init.$axes.$line.$circ.$ellip.$rect.$tri.$text)\\n\\n$answer =0\', \'\', \'Here\\\'s a graphic:\\n\\n$graphic\', \'\', \'\', 0, \'\'),
(24, 1177474350101005, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Graphics using showasciisvg; plots, vectors, line thickness\', \'number\', \'//set border and window\\n$init = "setBorder(5); initPicture(-5,5,-5,5);"\\n\\n//set axes:  xscl, yscl, labels? (1 yes, null no), xgrid, ygrid\\n$axes = "axes(1,1,1,1,1);"\\n\\n//make a function plot: plot("function",{xmin,xmax})\\n$fplot = "plot(\\\\"-x^2-2\\\\");"\\n\\n//make a parametric plot, thick\\n$pplot = "strokewidth=3;plot([\\\\"2*sin(t)\\\\",\\\\"cos(t)\\\\"],0,6.3);"\\n\\n//draw a line with an arrow\\n$vector = "strokewidth=2;marker=\\\\"arrow\\\\";stroke=\\\\"blue\\\\";line([4,4],[3,2]);"\\n\\n//draw a dashed line\\n$dash = "marker=\\\\"none\\\\";strokedasharray=\\\\"5 2\\\\";stroke=\\\\"red\\\\";line([-2,1],[-4,2]);"\\n\\n//create our graphic by concatenating all the strings we just defined\\n$graphic = showasciisvg($init.$axes.$fplot.$pplot.$vector.$dash)\\n\\n$answer =0\', \'\', \'Here\\\'s a graphic:\\n\\n$graphic\', \'\', \'\', 0, \'\'),
(25, 1179458805125719, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Drawing entry: draw x^2-a\', \'draw\', \'$a = rand(1,4)\\n\\n//define grid to draw on\\n$grid = "-5,5,-5,5"\\n//define answer lines\\n$answers = "x^2-$a"\\n//limit to line entry\\n$answerformat = "line"\', \'\', \'Sketch a graph of `y = x^2-$a`\', \'\', \'\', 0, \'\'),
(26, 1179461229278560, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Drawing entry: draw tangent line to parabola\', \'draw\', \'$a = randfrom("-.5,-.25,.25,.5")\\n$b = rand(1,3)\\n$b = -1*$b if ($a>0)\\n\\n$c = nonzerorand(-2,2)\\n\\n//define grid to draw on\\n$grid = "-5,5,-5,5"\\n//define background parabola\\n$background = "$a*x^2+$b,red"\\n//define answer lines:  y = mx + bb\\n$m = 2*$a*$c\\n$bb = $a*$c^2+$b - $m*$c\\n$answers = "$m*x+$bb"\\n//limit to line entry\\n$answerformat = "line"\', \'\', \'Sketch a tangent line to the function below at `x = $c`\', \'\', \'\', 0, \'\'),
(27, 1181541976814733, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Drawing entry: Draw a scatterplot\', \'draw\', \'$x = diffrands(1,8,5)\\n$y = diffrands(1,8,5)\\n$dots = arraystodots($x,$y)\\n\\n$sa = showarrays("x",$x,"y",$y)\\n\\n//define grid to draw on\\n$grid = "-1,10,-1,10"\\n\\n$answers = $dots\\n//limit to dot entry\\n$answerformat = "dot"\', \'\', \'Plot these points:\\n\\n$sa\', \'\', \'\', 0, \'\'),
(28, 1179462018509057, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Drawing entry: draw piecewise function\', \'draw\', \'$a = rand(-3,-1)\\n$b = rand(1,3)\\n\\n$y = rand(1,4)\\n\\n//we\'\'ll use the default grid, so won\\\'t define it here\\n//let\\\'s define the answer functions:\\n$answers[0] = "0,-5,$a"    //first line\\n$answers[1] = "$y,$a,$b"   //second line\\n$answers[2] = "0,$b,5"     //third line\\n$answers[3] = "$a,0"       //closed dot\\n$answers[4] = "$a,$y,open" //open dot\\n$answers[5] = "$b,$y"      //closed dot\\n$answers[6] = "$b,0,open"  //open dot\\n\\n//let\\\'s assign weights:  20% for each line segment, 10% for each dot\\n$partweights = array(.2,.2,.2,.1,.1,.1,.1)\', \'\', \'Sketch a graph of `f(x) = {(0,"if",x le $a),($y,"if",$a lt x le $b),(0,"if",x gt $b):}`\', \'\', \'\', 0, \'\'),
(29, 1180116746185373, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of essay question using editor\', \'essay\', \'//enable editor - otherwise a basic text area is used\\n$displayformat = "editor"\\n\\n//number of text rows.\\n$answerboxsize = "10"\\n\\n//no $answer is required for essay questions\\n//the computer can not self-grade essay questions\', \'\', \'This is an essay question.  Type your answer here.\', \'\', \'\', 0, \'\'),
(30, 1190232049844508, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of N-tuple (points)\', \'ntuple\', \'$a,$b = nonzerodiffrands(-5,5,2)\\n\\n\\n$m = $a+$b\\n$l = $a*$b\\n\\n$eqn = makepretty("x^2 - $m x + $l")\\n\\n$answer = "($a,0),($b,0)"\\n$displayformat = "pointlist"\', \'\', \'Find the points at which the curve `y = $eqn` crosses the x-axis\', \'\', \'\', 0, \'\'),
(31, 1190232225090913, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Example of Calculated N-tuple (vector)\', \'calcntuple\', \'$a,$b = nonzerodiffrands(-5,5,2)\\n\\n$m = $a^2+$b^2\\n\\n$showanswer = "`(: $a/sqrt($m), $b/sqrt($m) :)`"\\n\\n$ux = $a/sqrt($m)\\n$uy = $b/sqrt($m)\\n\\n$answer = "<$ux,$uy>"\\n$displayformat = "vector"\', \'\', \'Find the unit vector in the direction of `lt $a,$b gt`\', \'\', \'\', 0, \'\'),
(32, 1191778907331724, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Drawing Entry: Mark vertex of parabola\', \'draw\', \'$h,$k = nonzerodiffrands(-3,3,2)\\n\\n$answers = "$h,$k"\\n$grid = "-5,5,-5,5"\\n$background = "(x-$h)^2+$k"\\n$answerformat = "dot"\', \'\', \'Place a dot at the vertex of the parabola shown below\', \'\', \'\', 0, \'\'),
(33, 1193679368434747, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Stuanswers example; answer meeting a condition\', \'multipart\', \'$anstypes = "number,number"\\n$a = rand(3,9)\\n$as = $a^2\\n\\n$answerboxsize = 2\\n\\n$x = $stuanswers[$thisq][0] //the answer to this question, part 0\\n$y = $stuanswers[$thisq][1]\\n\\n$x = 9999 if ($x===null) //define to crazy value if student didn\\\'t answer\\n$y = 9999 if ($y===null) //define to crazy value if student didn\\\'t answer\\n\\n$answer[0] = $x+100   //by default the answer is something different than what they typed\\n$answer[0] = $x if (abs($x^2+$y^2 -$as) < .000001)  //if they meet our condition, set answer to what they entered\\n\\n$answer[1] = $y+100\\n$answer[1] = $y if (abs($x^2+$y^2 -$as) < .000001)\\n\\n//it\\\'s always best to define showanswer here; otherwise the wrong answers above may display as the answer\\n$showanswer = "Any point on the circle will be acceptable"\', \'\', \'Enter a point on the circle `x^2+y^2 = $as`\\n\\n($answerbox[0],$answerbox[1])\', \'\', \'\', 0, \'\'),
(34, 1197605392402294, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Drawing entry: polygons\', \'draw\', \'//y=a-x,  y=b-2x    a-x=b-2x    x=b-a\\n\\n$b = rrand(6,10,2)\\n$a = rand(3,$b-1) where ($b-$a<$b/2)\\n$hb = $b/2\\n$x = $b-$a\\n$y = $a-$x\\n\\n$grid = "-1,10,-1,10"\\n$answers = array("0,0","0,$a","$x,$y","$hb,0","0,0")\\n$answerformat = "polygon"\', \'\', \'Draw the boundary to the feasible region corresponding to the constraints\\n\\n`{(y+x le $a),(y+2x le $b),(x ge 0),(y ge 0):}`\', \'\', \'\', 0, \'\'),
(35, 1206685650334340, 1227157541, 1227157541, 1, \'Lippman, David\', 2, \'Graphing: axis labeling\', \'number\', \'$h = rand(50,80)\\n$v = rand(5,30)\\n\\n$g = showplot("$h+$v*x-9.8*x^2",0,5,0,100,"1:20","1:20",300,300)\\n\\n//adds border around main graph, in pixels: left, bottom, right, top\\n$g = addplotborder($g,55,40,5,10)\\n\\n//normal addlabel function, uses x,y location relative to graph coordinates\\n$g = addlabel($g,2,$h+2*$v-4*9.8,"f(x)","blue","aboveright")\\n\\n//new addlabelabs, uses pixel x,y location; 0,0 in bottom left\\n$g = addlabelabs($g,175,0,"Time (sec)","red","above")\\n\\n//addlabel and addlabelabs get new argument: text rotation angle\\n$g = addlabelabs($g,0,170,"Height (m)","red","right",90)\', \'\', \'$g\', \'\', \'\', 0, \'\');';
$DBH->query($query);
?>
<html>
<body>
<p>Example library installed.  You can now delete setupdb.php, install.php, and installexamples.php if you want.</p>

<p>Install is <a href="index.php">Done</a>.</p>

</body>
</html>
