diff --git a/StudentDrawFunction.php b/StudentDrawFunction.php
new file mode 100644
index 0000000000..d1b99ed2cd
--- /dev/null
+++ b/StudentDrawFunction.php
@@ -0,0 +1,67 @@
+setQuestionData($qn, $line);
+
+ $state = array(
+ 'seeds' => array($qn => $seed),
+ 'qsid' => array($qn => $qn),
+ 'stuanswers' => array(),
+ 'stuanswersval' => array(),
+ 'scorenonzero' => array(($qn+1) => -1),
+ 'scoreiscorrect' => array(($qn+1) => -1),
+ 'partattemptn' => array($qn => array()),
+ 'rawscores' => array($qn => array())
+ );
+
+ $a2->setState($state);
+
+ $toscoreqn = getPost("toscoreqn");
+ if ($toscoreqn != "") {
+ $toscoreqn = json_decode($toscoreqn, true);
+ $parts_to_score = array();
+ if (isset($toscoreqn[$qn])) {
+ foreach ($toscoreqn[$qn] as $pn) {
+ $parts_to_score[$pn] = true;
+ };
+ }
+ }
+
+ $result = $a2->scoreQuestion($qn, $parts_to_score);
+ $student_func = $a2->get_student_func();
+ $fin_function = array();
+
+ foreach ($student_func as $i => $value) {
+ $temp = new DrawResult($value[0], $value[1]);
+ $fin_function[] = $temp;
+ }
+
+ header('Content-Type: application/json');
+ echo json_encode($fin_function);
+
+} else {
+ header('HTTP/1.0 405 Method Not Allowed');
+ header('Content-Type: application/json');
+ echo json_encode(['status' => false, 'message' => 'Method Not Allowed']);
+}
\ No newline at end of file
diff --git a/assess2/AssessStandalone.php b/assess2/AssessStandalone.php
index 42b31d0653..06aeba168a 100644
--- a/assess2/AssessStandalone.php
+++ b/assess2/AssessStandalone.php
@@ -39,6 +39,11 @@ class AssessStandalone {
private $qdata = array();
private $now = 0;
private $question = null;
+ private $student_func;
+
+ public function get_student_func() {
+ return $this->student_func;
+ }
/**
* Construct object
@@ -303,6 +308,7 @@ public function scoreQuestion($qn, $parts_to_score = true) {
->setQnpointval(1);
$scoreResult = $scoreEngine->scoreQuestion($scoreQuestionParams);
+ $this->student_func = $scoreEngine->get_temp_func();
$scores = $scoreResult['scores'];
$rawparts = $scoreResult['rawScores'];
diff --git a/assess2/questions/ScoreEngine.php b/assess2/questions/ScoreEngine.php
index b21a304dff..e9d37fb7dd 100644
--- a/assess2/questions/ScoreEngine.php
+++ b/assess2/questions/ScoreEngine.php
@@ -64,6 +64,11 @@ class ScoreEngine
private $randWrapper;
private $userRights;
private $errors = array(); // Populated by this class' error handlers.
+ private $temp_func = array();
+
+ public function get_temp_func() {
+ return $this->temp_func;
+ }
public function __construct(PDO $dbh, Rand $randWrapper)
{
@@ -674,8 +679,11 @@ private function scorePartMultiPart(ScoreQuestionParams $scoreQuestionParams,
$raw[$partnum] = 0;
try {
- $scorePart = ScorePartFactory::getScorePart($scoreQuestionParams);
- $scorePartResult = $scorePart->getResult();
+ $scorePart = ScorePartFactory::getScorePart($scoreQuestionParams);
+ $scorePartResult = $scorePart->getResult();
+ //TESTING---------------------------------------------
+ $this->temp_func[] = array($inputReferenceNumber,$scorePart->get_student_function());
+
} catch (\Throwable $t) {
$this->addError(
_('Caught error while scoring parts in this question: ')
@@ -786,6 +794,9 @@ private function scorePartNonMultiPart(ScoreQuestionParams $scoreQuestionParams,
$scorePartResult = $scorePart->getResult();
$score = $scorePartResult->getRawScore();
+ //TESTING---------------------------------------------
+ $this->temp_func[] = array(27,$scorePart->get_student_function());
+
if (isset($scoremethod) && $scoremethod == "allornothing") {
if ($score < .98) {
$score = 0;
diff --git a/assess2/questions/scorepart/DrawingScorePart.php b/assess2/questions/scorepart/DrawingScorePart.php
index ec7433ad13..0dbaebe200 100644
--- a/assess2/questions/scorepart/DrawingScorePart.php
+++ b/assess2/questions/scorepart/DrawingScorePart.php
@@ -4,6 +4,7 @@
require_once __DIR__ . '/ScorePart.php';
require_once __DIR__ . '/../models/ScorePartResult.php';
+require_once 'convert_ans_to_str.php';
use IMathAS\assess2\questions\models\ScorePartResult;
use IMathAS\assess2\questions\models\ScoreQuestionParams;
@@ -11,6 +12,11 @@
class DrawingScorePart implements ScorePart
{
private $scoreQuestionParams;
+ private $stu_func_ans =[];
+
+ public function get_student_function(){
+ return $this->stu_func_ans;
+ }
public function __construct(ScoreQuestionParams $scoreQuestionParams)
{
@@ -129,6 +135,9 @@ public function getResult(): ScorePartResult
$xtopix = my_create_function('$x',"return ((\$x - ({$settings[0]}))*($pixelsperx) + ($imgborder));");
$ytopix = my_create_function('$y',"return (({$settings[7]}) - (\$y- ({$settings[2]}))*($pixelspery) - ($imgborder));");
+ $pixtox = my_create_function('$px', "return ((\$px - ($imgborder)) / ($pixelsperx) + ({$settings[0]}));");
+ $pixtoy = my_create_function('$py', "return (({$settings[7]} - (\$py + ($imgborder))) / ($pixelspery) + ({$settings[2]}));");
+
$anslines = array();
$ansdots = array();
$ansodots = array();
@@ -185,6 +194,14 @@ public function getResult(): ScorePartResult
foreach ($line as $j=>$pt) {
$line[$j] = explode(',',$pt);
}
+
+ $temp = "";
+ for($i = 0; $i < count($line) - 1; $i++){
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $temp .= implode("",fans_polygons($line[$i][0],$line[$i][1],$line[$i+1][0],$line[$i+1][1],$answerformat[0], $pixtox, $pixtoy));
+ }
+ $this->stu_func_ans[] = array($temp);
+
if ($isclosed && ($line[0][0]-$line[count($line)-1][0])*($line[0][0]-$line[count($line)-1][0]) + ($line[0][1]-$line[count($line)-1][1])*($line[0][1]-$line[count($line)-1][1]) <=25*max(1,$reltolerance)) {
array_pop($line);
$stuclosed = true;
@@ -243,7 +260,6 @@ public function getResult(): ScorePartResult
if ($extrapolys>0) {
$totscore = $totscore/(1+$extrapolys);
}
- //echo "Vals score: $vals, adj score: $adjv.
";
if ($abstolerance !== '') {
if ($totscore<$abstolerance) {
@@ -738,11 +754,23 @@ public function getResult(): ScorePartResult
$lines[] = array('y',$slope,$pts[2]+($x2p-$pts[1])*$slope);
}
}
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_lines($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
} else if ($pts[0]==5.2) {
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_vecs($pts[1],$pts[2],$pts[3],$pts[4],'r', $pixtox, $pixtoy);
+
$vecs[] = array($pts[1],$pts[2],$pts[3],$pts[4],'r');
} else if ($pts[0]==5.3) {
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_vecs($pts[1],$pts[2],$pts[3],$pts[4],'ls', $pixtox, $pixtoy);
+
$vecs[] = array($pts[1],$pts[2],$pts[3],$pts[4],'ls');
} else if ($pts[0]==5.4) {
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_vecs($pts[1],$pts[2],$pts[3],$pts[4],'v', $pixtox, $pixtoy);
+
$vecs[] = array($pts[1],$pts[2],$pts[3],$pts[4],'v');
} else if ($pts[0]==6 || $pts[0] == 6.2) {
$leftrightdir = '';
@@ -760,6 +788,10 @@ public function getResult(): ScorePartResult
$a = ($pts[4]-$pts[2])/(($pts[3]-$pts[1])*($pts[3]-$pts[1]));
$y = $pts[2]+$a*400;
$x = $pts[1]+sign($a)*sqrt(abs(20/$a));
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_parabs($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$parabs[] = array($pts[1],$pts[2],$y,$x,$leftrightdir);
}
} else if ($pts[0]==6.1) {
@@ -770,6 +802,10 @@ public function getResult(): ScorePartResult
$a = ($pts[3]-$pts[1])/(($pts[4]-$pts[2])*($pts[4]-$pts[2]));
$x = $pts[1]+$a*400;
$y = $pts[2]+sign($a)*sqrt(abs(20/$a));
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_hparabs($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$hparabs[] = array($pts[1],$pts[2],$y,$x);
}
} else if ($pts[0]==6.5) {//sqrt
@@ -779,6 +815,10 @@ public function getResult(): ScorePartResult
$secxp = $pts[1] + ($x4p-$x0p)/5*$flip; //over 1/5 of grid width
$secyp = $stretch*sqrt($flip*($secxp - $pts[1]))+($pts[2]);
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_sqrts($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$sqrts[] = array($pts[1],$pts[2],$secyp,$flip);
}
} else if ($pts[0]==6.3) {
@@ -788,6 +828,10 @@ public function getResult(): ScorePartResult
} else if ($pts[3]!=$pts[1]) {
//this is the cube root of the stretch factor
$a = safepow($pts[4]-$pts[2], 1/3)/($pts[3]-$pts[1]);
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_cubics($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$cubics[] = array($pts[1],$pts[2], $a);
}
} else if ($pts[0]==6.6) {
@@ -796,21 +840,40 @@ public function getResult(): ScorePartResult
$lines[] = array('y',0,$pts[4]);
} else if ($pts[3]!=$pts[1]) {
$a = safepow($pts[4]-$pts[2],3)/($pts[3]-$pts[1]);
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_cuberoots($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$cuberoots[] = array($pts[1],$pts[2],$a);
}
} else if ($pts[0]==7) {
//circle
$rad = sqrt(($pts[3]-$pts[1])*($pts[3]-$pts[1]) + ($pts[4]-$pts[2])*($pts[4]-$pts[2]));
//$circs[] = array($pts[1],$pts[2],$rad);
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_circs($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$ellipses[] = array($pts[1],$pts[2],$rad,$rad);
} else if ($pts[0]==7.2) {
//ellipse
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_ellipses($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$ellipses[] = array($pts[1],$pts[2],abs($pts[3]-$pts[1]),abs($pts[4]-$pts[2]));
} else if ($pts[0]==7.4) {
//vert hyperbola
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_vhyperbolas($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$hyperbolas[] = array($pts[1],$pts[2],abs($pts[3]-$pts[1]),abs($pts[4]-$pts[2]),'vert');
} else if ($pts[0]==7.5) {
//horiz hyperbola
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_hhyperbolas($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$hyperbolas[] = array($pts[1],$pts[2],abs($pts[3]-$pts[1]),abs($pts[4]-$pts[2]),'horiz');
} else if ($pts[0]==8) {
//abs
@@ -826,6 +889,9 @@ public function getResult(): ScorePartResult
$slope *= -1;
}
}
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_abs($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
$abs[] = array($pts[1],$pts[2], $slope);
} else if ($pts[0]==8.3 || $pts[0]==8.5) {
if ($pts[0]==8.3) {
@@ -850,6 +916,14 @@ public function getResult(): ScorePartResult
$str = $adjy2/safepow($base,$Lx2p-$xop);
}
//$exps[] = array($str,$base);
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ if ($pts[0]==8.5) {
+ $this->stu_func_ans[] = fans_exps($pts[1],$pts[2],$pts[3],$pts[4],$pts[5],$pts[6],$pts[0], $xop, $yop, $pixtox, $pixtoy);
+ }
+ else {
+ //Does not use $pts[5] ans $pts[6]
+ $this->stu_func_ans[] = fans_exps($pts[1],$pts[2],$pts[3],$pts[4],0,0,$pts[0], $xop, $yop, $pixtox, $pixtoy);
+ }
$exps[] = array($Lx1p-$xop, $adjy1, $Lx2p-$xop, $adjy2, $base, $horizasy);
}
} else if ($pts[0]==8.4 || $pts[0]==8.6) {
@@ -873,12 +947,25 @@ public function getResult(): ScorePartResult
} else {
$str = $adjx2/safepow($base,$Ly2p-$yop);
}
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ if ($pts[0]==8.6) {
+ $this->stu_func_ans[] = fans_logs($pts[1],$pts[2],$pts[3],$pts[4],$pts[5],$pts[6],$pts[0], $xop, $yop, $pixtox, $pixtoy);
+ }
+ else {
+ //Does not use $pts[5] ans $pts[6]
+ $this->stu_func_ans[] = fans_logs($pts[1],$pts[2],$pts[3],$pts[4],0,0,$pts[0], $xop, $yop, $pixtox, $pixtoy);
+ }
+
$logs[] = array($Ly1p-$yop, $adjx1, $Ly2p-$yop, $adjx2, $base, $vertasy);
}
} else if ($pts[0]==8.2) { //rational
if ($pts[1]!=$pts[3] && $pts[2]!=$pts[4]) {
$stretch = ($pts[3]-$pts[1])*($pts[4]-$pts[2]);
$yp = $pts[2]+(($stretch>0)?1:-1)*sqrt(abs($stretch));
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_rats($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
$rats[] = array($pts[1],$pts[2],$yp);
}
@@ -887,9 +974,18 @@ public function getResult(): ScorePartResult
$pts[1] -= ($pts[3] - $pts[1]);
$pts[2] -= ($pts[4] - $pts[2]);
}
+ $this->stu_func_ans[] = fans_coss($pts[1],$pts[2],$pts[3],$pts[4], $pixtox, $pixtoy);
+
if ($pts[4]>$pts[2]) {
+ // //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ // $this->stu_func_ans[] = convert_to_str_ans(array($pts[1],$pts[2],$pts[3],$pts[4]), $pixtox, $pixtoy, "coss");
+
$coss[] = array($pts[3],$pts[1],$pts[4],$pts[2]);
} else {
+ // //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ // $this->stu_func_ans[] = convert_to_str_ans(array($pts[3],$pts[4],$pts[1],$pts[2]), $pixtox, $pixtoy, "coss");
+
+
$coss[] = array($pts[1],$pts[3],$pts[2],$pts[4]);
}
}
@@ -901,6 +997,8 @@ public function getResult(): ScorePartResult
$dots = explode('),(', substr($dots,1,strlen($dots)-2));
foreach ($dots as $k=>$pt) {
$dots[$k] = explode(',',$pt);
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_dots($dots[$k][0], $dots[$k][1], $pixtox, $pixtoy);
}
}
if ($odots=='') {
@@ -909,6 +1007,8 @@ public function getResult(): ScorePartResult
$odots = explode('),(', substr($odots,1,strlen($odots)-2));
foreach ($odots as $k=>$pt) {
$odots[$k] = explode(',',$pt);
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_odots($odots[$k][0], $odots[$k][1], $pixtox, $pixtoy);
}
}
@@ -1256,6 +1356,7 @@ public function getResult(): ScorePartResult
break;
}
}
+
$usedcubic = [];
foreach ($anscubics as $key=>$anscubic) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1275,8 +1376,7 @@ public function getResult(): ScorePartResult
break;
}
}
- //print_r($anscuberoots);
- //print_r($cuberoots);
+
$usedcuberoot = [];
foreach ($anscuberoots as $key=>$anscuberoot) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1296,6 +1396,7 @@ public function getResult(): ScorePartResult
break;
}
}
+
$usedsqrt = [];
foreach ($anssqrts as $key=>$anssqrt) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1318,6 +1419,7 @@ public function getResult(): ScorePartResult
break;
}
}
+
$usedrat = [];
foreach ($ansrats as $key=>$ansrat) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1337,8 +1439,8 @@ public function getResult(): ScorePartResult
break;
}
}
- $usedexp = [];
+ $usedexp = [];
foreach ($ansexps as $key=>$ansexp) {
$scores[$scoretype[$key]][$key] = 0;
for ($i=0; $i$anslog) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1393,6 +1496,7 @@ public function getResult(): ScorePartResult
break;
}
}
+
$usedcos = [];
foreach ($anscoss as $key=>$anscos) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1421,6 +1525,7 @@ public function getResult(): ScorePartResult
break;
}
}
+
$usedabs = [];
foreach ($ansabs as $key=>$aabs) {
$scores[$scoretype[$key]][$key] = 0;
@@ -1442,6 +1547,7 @@ public function getResult(): ScorePartResult
break;
}
}
+
//extra stuff is total count of drawn items - # of scored items - # of correct optional items
$extrastuffpenalty = max((count($tplines)+count($dots)+count($odots)-count($scores[0])-array_sum($scores[1]))/(max(count($scores[0]),count($tplines)+count($dots)+count($odots))),0);
// don't need optional scores anymore
@@ -1540,6 +1646,8 @@ public function getResult(): ScorePartResult
$ineqlines = explode('),(', substr($ineqlines,1,strlen($ineqlines)-2));
foreach ($ineqlines as $k=>$val) {
$pts = explode(',',$val);
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_ineqlines($pts[1],$pts[2],$pts[3],$pts[4],$pts[5],$pts[6],$pts[0], $pixtox, $pixtoy);
if($pts[0]<10.3){//linear
if ($pts[3]==$pts[1]) {
$slope = 10000;
@@ -1578,6 +1686,7 @@ public function getResult(): ScorePartResult
} else {
$dir = '>';
}
+
$ineqlines[$k] = array('y',$dir,$pts[0],$aUser,$pts[1],$pts[2]);
}
} else { //abs
@@ -1660,6 +1769,7 @@ public function getResult(): ScorePartResult
}
}
}
+
$extrastuffpenalty = max((count($ineqlines)-count($answers))/(max(count($answers),count($ineqlines))),0);
} else if ($answerformat[0]=='numberline') {
@@ -1718,6 +1828,10 @@ public function getResult(): ScorePartResult
$lines[$k] = explode('),(',substr($line,1,strlen($line)-2));
$minp = explode(',', $lines[$k][0]);
$maxp = explode(',', $lines[$k][count($lines[$k])-1]);
+
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_line1d($minp[0], $maxp[0], $pixtox, $pixtoy);
+
$lines[$k] = array(min($minp[0], $maxp[0]), max($minp[0], $maxp[0]));
}
$newlines = array($lines[0]);
@@ -1751,6 +1865,8 @@ public function getResult(): ScorePartResult
$dots = explode('),(', substr($dots,1,strlen($dots)-2));
foreach ($dots as $k=>$pt) {
$dots[$k] = explode(',',$pt);
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_dots1d($dots[$k][0], $pixtox, $pixtoy);
}
//remove duplicate dots
for ($k=count($dots)-1;$k>=0;$k--) {
@@ -1773,6 +1889,8 @@ public function getResult(): ScorePartResult
$odots = explode('),(', substr($odots,1,strlen($odots)-2));
foreach ($odots as $k=>$pt) {
$odots[$k] = explode(',',$pt);
+ //ADD TO ANSWER AS FUNCTION------------------------------------------------------------
+ $this->stu_func_ans[] = fans_odots1d($odots[$k][0], $pixtox, $pixtoy);
}
//remove duplicate odots, and dots below odots
for ($k=count($odots)-1;$k>=0;$k--) {
@@ -1795,6 +1913,7 @@ public function getResult(): ScorePartResult
}
}
}
+
$scores = array();
if ((count($dots)+count($odots))==0) {
$extradots = 0;
@@ -1811,6 +1930,7 @@ public function getResult(): ScorePartResult
}
}
}
+
foreach ($ansodots as $key=>$ansodot) {
$scores[$key] = 0;
foreach ($odots as $i=>$godot) {
diff --git a/assess2/questions/scorepart/convert_ans_to_str.php b/assess2/questions/scorepart/convert_ans_to_str.php
new file mode 100644
index 0000000000..a9208795b5
--- /dev/null
+++ b/assess2/questions/scorepart/convert_ans_to_str.php
@@ -0,0 +1,512 @@
+= 0) {
+ $sign = "+";
+ } else {
+ $sign = "-";
+ $num = abs($num);
+ }
+ return [$num, $sign];
+}
+
+function minus_sign($num, $sign) {
+ if ($num >= 0) {
+ $sign = "-";
+ } else {
+ $sign = "+";
+ $num = abs($num);
+ }
+ return [$num, $sign];
+}
+
+function clean_up($marray) {
+ foreach ($marray as $key => $value) {
+ $marray[$key] = preg_replace("/[^0-9.\-]/", "", $value);
+ }
+ return $marray;
+}
+
+function change_to_math($xarray, $yarray, $pixtox, $pixtoy) {
+ foreach ($xarray as $key => $value) {
+ $xarray[$key] = $pixtox(floatval($value));
+ }
+ foreach ($yarray as $key => $value) {
+ $yarray[$key] = $pixtoy(floatval($value));
+ }
+ return [$xarray, $yarray];
+}
+
+
+function fans_polygons($mh, $mk, $mx, $my, $type, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = ($my - $mk) / ($mx - $mh);
+ $mb = $mk - ($ma * $mh);
+ $l_range = sprintf("x = %f -> %f. ", $mh, $mx);
+ if($type == "closedpolygon"){
+ $l_type = "closed polygon";
+ }
+ else {
+ $l_type = "polygon";
+ }
+
+ list($mb, $sign1) = add_sign($mb, $sign1);
+
+ $ans = sprintf("This %s includes a line: y = %f * x %s %f from %s", $l_type, $ma, $sign1, $mb, $l_range);
+
+ return array($ans);
+}
+
+function fans_vecs($mh, $mk, $mx, $my, $type, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ if($type === 'r') {
+ $v_type = "ray";
+ $v_range = sprintf("x = %f, ", $mh);
+ }
+ elseif ($type === 'ls') {
+ $v_type = "line segment";
+ $v_range = sprintf("x = %f -> %f, ", $mh, $mx);
+ }
+ else {
+ $v_type = "vector";
+ $v_range = sprintf("x = %f -> %f, ", $mh, $mx);
+ }
+ $ma = ($my - $mk) / ($mx - $mh);
+ $mb = $mk - ($ma * $mh);
+
+ list($mb, $sign1) = add_sign($mb, $sign1);
+
+ $ans = sprintf("This includes a %s function: y = %f * x %s %f from %s", $v_type, $ma, $sign1, $mb, $v_range);
+
+ return array($ans);
+}
+
+function fans_circs ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(($mx - $mh)*($mx - $mh) + ($my-$mk)*($my-$mk));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = minus_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: (x %s %f)^2 + (y %s %f)^2 = %f", $sign1, $mh, $sign2, $mk, $ma);
+
+ return array($ans);
+}
+
+function fans_parabs ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(($my - $mk) / (($mx-$mh)*($mx-$mh)));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y = %f * (x %s %f)^2 %s %f", $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+}
+
+function fans_hparabs ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(($my - $mk) / (($mx-$mh)*($mx-$mh)));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: x = %f * (y %s %f)^2 %s %f", $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+}
+
+function fans_sqrts ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $flip = ($mx < $mh) ? -1 : 1;
+ $ma = floatval(($my - $mk) / sqrt($flip * ($mx - $mh)));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y = %f * sqrt(x %s %f) %s %f", $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+}
+
+function fans_cubics ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(safepow($my-$mk, 1/3)/($mx-$mh));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y = (%f * (x %s %f))^3 %s %f", $ma, $sign1, $mh, $sign2, $mk);
+ return array($ans);
+}
+
+function fans_cuberoots ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(safepow($my-$mk, 3)/($mx-$mh));
+
+ list($mh, $sign1) = add_sign($mh, $sign1);
+ list($mk, $sign2) = minus_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: x = (1 / %f) * (y %s %f)^3 %s %f", $ma, $sign2, $mk, $sign1, $mh);
+ return array($ans);
+}
+
+function fans_ellipses ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(abs($mx - $mh));
+ $mb = floatval(abs($my - $mk));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = minus_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: ((1 / %f) * (x %s %f))^2 + ((1 / %f) * (y %s %f))^2 = 1", $ma, $sign1, $mh, $mb, $sign2, $mk);
+
+ return array($ans);
+}
+
+function fans_hhyperbolas ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(abs($mx - $mh));
+ $mb = floatval(abs($my - $mk));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = minus_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: ((1 / %f) * (x %s %f))^2 - ((1 / %f) * (y %s %f))^2 = 1", $ma, $sign1, $mh, $mb, $sign2, $mk);
+
+ return array($ans);
+}
+
+function fans_vhyperbolas ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = floatval(abs($mx - $mh));
+ $mb = floatval(abs($my - $mk));
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = minus_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: ((1 / %f) * (y %s %f))^2 - ((1 / %f) * (x %s %f))^2 = 1", $mb, $sign2, $mk, $ma, $sign1, $mh);
+
+ return array($ans);
+}
+
+function fans_abs ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ if ($mh==$mx) {
+ $ma = 0;
+ } else {
+ $ma = ($my-$mk)/($mx-$mh);
+ if ($mh > $mx) {
+ $ma *= -1;
+ }
+ }
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y = %f * abs(x %s %f) %s %f", $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+}
+
+function fans_exps ($mh, $mk, $mx, $my, $m4, $m5, $type, $xop, $yop, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my, $m4, $m5, $xop, $yop) = clean_up(array($mh, $mk, $mx, $my, $m4, $m5, $xop, $yop));
+ list(list($mh, $mx, $m4, $xop), list($mk, $my, $m5, $yop)) = change_to_math(array($mh, $mx, $m4, $xop), array($mk, $my, $m5, $yop), $pixtox, $pixtoy);
+
+ if ($type == 8.3) {
+ $horizasy = $yop;
+ $adjy2 = $horizasy - $my;
+ $adjy1 = $horizasy - $mk;
+ $Lx1p = $mh;
+ $Lx2p = $mx;
+ } else if ($type ==8.5) {
+ $horizasy = $mk;
+ $adjy2 = $horizasy - $m5;
+ $adjy1 = $horizasy - $my;
+ $Lx1p = $mx;
+ $Lx2p = $m4;
+ }
+ if ($adjy1*$adjy2>0 && $Lx1p!=$Lx2p) {
+ $base = safepow($adjy2/$adjy1,1/($Lx2p-$Lx1p));
+ if (abs($Lx1p-$xop)0 && $Ly1p!=$Ly2p) {
+ $base = safepow($adjx2/$adjx1,1/($Ly2p-$Ly1p));
+ if (abs($pts[2]-$yop) $my) - ($mk < $my)) * ($mh - $mx)) / 2;
+ $md = ($my + $mk) / 2;
+
+ list($mc, $sign1) = minus_sign($mc, $sign1);
+ list($ma, $sign2) = add_sign($ma, $sign2);
+
+ $ans = sprintf("This includes function: y = %f %s %f * cos(%f * (x %s %f))", $md, $sign2, $ma, $mb, $sign1, $mc);
+
+ return array($ans);
+}
+
+function fans_lines ($mh, $mk, $mx, $my, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my) = clean_up(array($mh, $mk, $mx, $my));
+ list(list($mh, $mx), list($mk, $my)) = change_to_math(array($mh, $mx), array($mk, $my), $pixtox, $pixtoy);
+
+ $ma = ($my - $mk) / ($mx - $mh);
+ $mb = $mk - ($ma * $mh);
+
+ list($mb, $sign1) = add_sign($mb, $sign1);
+
+ $ans = sprintf("This includes function: y = %f * x %s %f", $ma, $sign1, $mb);
+
+ return array($ans);
+}
+
+function fans_dots ($mh, $mk, $pixtox, $pixtoy) {
+
+ list($mh, $mk) = clean_up(array($mh, $mk));
+ list(list($mh), list($mk)) = change_to_math(array($mh), array($mk), $pixtox, $pixtoy);
+
+ list($mh, $mk) = clean_up(array($mh, $mk), $pixtox, $pixtoy);
+
+ $ans = sprintf("There is a dot at: (%f, %f)", $mh, $mk);
+
+ return array($ans);
+}
+
+function fans_odots ($mh, $mk, $pixtox, $pixtoy) {
+
+ list($mh, $mk) = clean_up(array($mh, $mk));
+ list(list($mh), list($mk)) = change_to_math(array($mh), array($mk), $pixtox, $pixtoy);
+
+ $ans = sprintf("There is an open dot at: (%f, %f)", $mh, $mk);
+
+ return array($ans);
+}
+
+function fans_ineqlines ($mh, $mk, $mx, $my, $mx2, $my2, $type, $pixtox, $pixtoy) {
+
+ list($mh, $mk, $mx, $my, $mx2, $my2) = clean_up(array($mh, $mk, $mx, $my, $mx2, $my2));
+ list(list($mh, $mx, $mx2), list($mk, $my, $my2)) = change_to_math(array($mh, $mx, $mx2), array($mk, $my, $my2), $pixtox, $pixtoy);
+
+ $in_type = floatval($type);
+ if($in_type < floatval(10.3)) {
+ if ($in_type === floatval(10)) {
+ $l_drt = '=';
+ }
+ if ($mx === $mh) {
+ if ($mx2 > $mh) {
+ $l_dir = '<';
+ }
+ else {
+ $l_dir = '>';
+ }
+ $ans = sprintf("This includes function: x %s%s %f", $l_dir, $l_drt, $mh);
+
+ return array($ans);
+ }
+
+ $ma = ($my - $mk) / ($mx - $mh);
+ $ynew = $ma * ($mx2 - $mh) + $mk;
+ if ($my2 < $ynew) {
+ $l_dir = '<';
+ }
+ else {
+ $l_dir = '>';
+ }
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y %s%s %f * (x %s %f) %s %f", $l_dir, $l_drt, $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+ }
+ elseif ($in_type < floatval(10.5)) {
+ $ma = ($my - $mk) / (($mx - $mh) * ($mx - $mh));
+ $ynew = $ma * ($mx2 - $mh) * ($mx2 - $mh) + $mk;
+ if($my2 < $ynew) {
+ $l_dir = '<';
+ }
+ else {
+ $l_dir = '>';
+ }
+ if($in_type === floatval(10.3)) {
+ $l_drt = '=';
+ }
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y %s%s %f * (x %s %f)^2 %s %f", $l_dir, $l_drt, $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+ }
+ else {
+ $ma = ($my - $mk) / ($mx - $mh);
+ if ($mx < $mh) {
+ $ma *= -1;
+ }
+
+ $ynew = $ma * abs($mx2 - $mh) + $mk;
+ if($my2 < $ynew) {
+ $l_dir = '<';
+ }
+ else {
+ $l_dir = '>';
+ }
+ if($in_type === floatval(10.5)) {
+ $l_drt = '=';
+ }
+ else {
+ $l_drt = '';
+ }
+
+ list($mh, $sign1) = minus_sign($mh, $sign1);
+ list($mk, $sign2) = add_sign($mk, $sign2);
+
+ $ans = sprintf("This includes function: y %s%s %f * abs(x %s %f) %s %f", $l_dir, $l_drt, $ma, $sign1, $mh, $sign2, $mk);
+
+ return array($ans);
+ }
+}
+
+function fans_line1d ($mh, $mx, $pixtox, $pixtoy) {
+ list($mh, $mx) = clean_up(array($mh, $mx), $pixtox, $pixtoy);
+
+ list($mh, $mx) = clean_up(array($mh, $mx));
+ list(list($mh, $mx), ) = change_to_math(array($mh, $mx), array(), $pixtox, $pixtoy);
+
+
+ $head = min($mh, $mx);
+ $tail = max($mh, $mx);
+ $ans = sprintf("There is a line from: %f to %f", $head, $tail);
+
+ return array($ans);
+}
+
+function fans_dots1d ($mh, $pixtox, $pixtoy) {
+
+ list($mh) = clean_up(array($mh));
+ list(list($mh), ) = change_to_math(array($mh), array(), $pixtox, $pixtoy);
+
+ $ans = sprintf("There is a dot at: %f", $mh);
+
+ return array($ans);
+}
+
+function fans_odots1d ($mh, $pixtox, $pixtoy) {
+
+ list($mh) = clean_up(array($mh));
+ list(list($mh), ) = change_to_math(array($mh), array(), $pixtox, $pixtoy);
+
+ $ans = sprintf("There is an open dot at: %f", $mh);
+
+ return array($ans);
+}
+
diff --git a/assessment/config.php b/assessment/config.php
new file mode 100644
index 0000000000..36fb2c3004
--- /dev/null
+++ b/assessment/config.php
@@ -0,0 +1,89 @@
+setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
+ $GLOBALS["DBH"] = $DBH;
+ } catch(PDOException $e) {
+ die("Could not connect to database: " . $e->getMessage() . "