diff --git a/app/Controllers/Printables.php b/app/Controllers/Printables.php index f3d985f..89428da 100644 --- a/app/Controllers/Printables.php +++ b/app/Controllers/Printables.php @@ -17,9 +17,11 @@ class Printables extends BaseController public function show(string $printableCode) { + $data = []; //$mModel =new MathsModel(); $mModel =model('MathsModel'); // MathsModel(); - echo $mModel->PageData($printableCode); + $data['result'] = $mModel->PageData($printableCode); + /* @@ -41,7 +43,7 @@ class Printables extends BaseController 'databaseServerTemplates' => AuxPaceClient::getDatabaseServerTemplateList() ]); */ - return view('printables/index'); + return view('printables/index', $data); } } \ No newline at end of file diff --git a/app/Models/MathsModel.php b/app/Models/MathsModel.php index db13f2a..cc29be2 100644 --- a/app/Models/MathsModel.php +++ b/app/Models/MathsModel.php @@ -14,8 +14,209 @@ class MathsModel extends Model public function PageData($printableCode){ + // Check if function is available first + return $this->$printableCode(); + } + + private function SIMULTAN1(){ + $data = []; + for ($ii = 0; $ii < 50; $ii++) { + + $la1 = array("x","a","p","r","q","s"); // your choice for variale name + $la2 = array("y","z","n","m","u","f"); // your choice for variale name different from list la1 + + $let1 = $la1[rand(0,5)]; // pick a variale name to use + $let2 = $la2[rand(0,5)]; // pick a variale name to use + + $ans1 = rand(1,9); // generate the solution 1 + $ans2 = rand(2,11); // generate the solution 2 + if ($ans2 == $ans1) $ans2 = rand(2,11); // regenrate it + + $c1 = rand(1,6); + $c2 = rand(1,6); + $c3 = rand(1,6); if ($c3 == $c1) $c3 = rand(2,11); // regenrate it + $c4 = rand(1,6); if ($c4 == $c2) $c4 = rand(2,11); // regenrate it + + $mopt = array(1,-1); + $mp1 =$mopt[rand(0,1)]; + $mp2 =$mopt[rand(0,1)]; + + $tot1 = $c1*$ans1 + $mp1*$c2*$ans2; + $tot2 = $c3*$ans1 + $mp2*$c4*$ans2; + + $question1 = " $c1$let1" .( $mp1>0?"+":"-"). "$c2$let2 = $tot1 "; + $question2 = " $c3$let1" .( $mp2>0?"+":"-"). "$c4$let2 = $tot2 "; + $question3 = " What is $let1 and $let2 ?"; + + $realQ = array( + 'no'=>$ii+1, + 'l1'=>$question1, + 'l2'=>$question2, + 'l3'=>$question3, + 'q'=>$question1 ."
".$question2 ."
". $question3, + 'ans'=> $ans1.",".$ans2 + ); + $data[] = $realQ; + + } + + $result =array( + 'desc' =>'Basic Simultaneous Equations', + 'detail'=> 'Basic Simultaneous Equations Practice', + 'col' => 1, + 'frame'=>'line', + 'data'=>$data + ); + return $result; + } + + private function EQUATION1(){ + $data = []; + + $p1=['Apple','Banana','Gape']; + $p2=['Lemon','Mango','Orange']; + $txtL1 = $p1[rand(0,2)]; + $txtL2 = $p2[rand(0,2)]; + for ($ii = 0; $ii < 24; $ii++) { + + $xpart = rand(1, 2); + $xp = ""; + for ($i = 0; $i < $xpart; $i++) { + $xc = rand(1,4); + $xp .= ($xc>1?$xc:'')." ".$txtL1.($xc>1?"s":'').($i< $xpart-1?" + ":''); + // $i=$i+$xc; + } + + $ypart = rand(1, 2); + $yp = ""; + for ($iy = 0; $iy < $ypart; $iy++) { + $yc = rand(1,6); + $yp .= " + ". ($yc>1?$yc:'')." ".$txtL2.($yc>1?"s":''); + } + $question = $xp . $yp. " = "; + + $realQ = array( + 'no'=>$ii+1, + 'l1'=>$xp, + 'l2'=>$yp, + 'l3'=>'', + 'q'=>$question, + 'ans'=> '' + ); + $data[] = $realQ; + } + + + + $result =array( + 'desc' =>'Basic Equations Level 1', + 'detail'=> 'Basic Equations Level 1 Practice, Simplify the expressions', + 'col' => 1, + 'frame'=>'line', + 'data'=>$data + ); + return $result; + } + + private function EXPONENT1(){ + $data = []; + $la1 = array("x","a","p","r","q","s","y","z","n","m","u","f"); + + for ($ii = 0; $ii < 50; $ii++) { + $numV = rand(2,3); + + $var_list= array(); + + for ($i=0; $i<$numV; $i++){ + $var_list[$i] = $la1[rand(0,(count($la1)-1))]; + } + + $numQ = rand(4,8); + + $quest_list= array(); + $quest =""; + for ($i=0; $i<$numQ; $i++){ + $quest_list[$i] = $var_list[rand(0,(count($var_list)-1))]; + $quest .= ($i>0?" . ":'').$quest_list[$i]; + } + + $realQ = array( + 'no'=>$ii+1, + 'l1'=>'', + 'l2'=>'', + 'l3'=>'', + 'q'=>$quest." = ", + 'ans'=> '' + ); + $data[] = $realQ; + } + + $result =array( + 'desc' =>'Basic Exponential Expression', + 'detail'=> 'Basic Exponential Expression Level 1, Simplify the expressions', + 'col' => 1, + 'frame'=>'line', + 'data'=>$data + ); + return $result; + + } + + private function EQUATION4(){ + $data = []; + +$la1 = array("x","a","p","r","q","s","y","z","n","m","u","f"); + +for ($ii = 0; $ii < 50; $ii++) { + $numV = rand(2, 3); + + $var_list = array(); + + for ($i = 0; $i < $numV; $i++) { + $var_list[$i] = $la1[rand(0, (count($la1) - 1))]; + } + + $numQ = rand(4, 8); + $sign_arr = array("+", "-"); + + $quest_list = array(); + $quest = ""; + for ($i = 0; $i < $numQ; $i++) { + $quest_list[$i] = $var_list[rand(0, (count($var_list) - 1))]; + $sgn = $sign_arr[rand(0, 1)]; + if ($i == 0 && $sgn == "+") { + $sgn = ""; + } + $que = rand(1, 5); + if ($que == 1) { + $que = ""; + } + + $quest .= " ".$sgn . $que . $quest_list[$i]; + } + + $realQ = array( + 'no' => $ii + 1, + 'l1' => '', + 'l2' => '', + 'l3' => '', + 'q' => $quest . " = ", + 'ans' => '' + ); + $data[] = $realQ; + + + } + $result =array( + 'desc' =>'Equation Simplification IV', + 'detail'=> 'Basic Exponential Expression Level 1, Simplify the expressions', + 'col' => 1, + 'frame'=>'line', + 'data'=>$data + ); + return $result; + - return '93939393939'.$printableCode; } } \ No newline at end of file diff --git a/app/Views/layouts/homelayout2.php b/app/Views/layouts/homelayout2.php index f8e9154..e86fd83 100644 --- a/app/Views/layouts/homelayout2.php +++ b/app/Views/layouts/homelayout2.php @@ -97,14 +97,35 @@