QuestionGenerator.php 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  1. <?php
  2. class timekeeper_Question_Engine {
  3. public $yearlevel;
  4. public $subjectSelector;
  5. private $FormattedQuestionForm;
  6. public function GetRandomQuestion() {
  7. $this->FormattedQuestionForm = e107::getForm()->open('questionForm', 'post', '', ['autocomplete' => 'off', 'class' => 'formclass']) . "\n";
  8. //$tmp = new EnglishYearTwo;
  9. //$tmp->RandomQuestion();
  10. $Years = [
  11. 'YearOne',
  12. 'YearTwo',
  13. 'YearThree',
  14. 'YearFour',
  15. 'YearFive',
  16. 'YearSix',
  17. 'YearSeven',
  18. 'YearEight',
  19. 'YearNine',
  20. 'YearTen',
  21. 'YearEleven',
  22. 'YearTwelve',
  23. ];
  24. $Function = $Years[($this->yearlevel) - 1];
  25. $this->FormattedQuestionForm .= e107::getForm()->hidden('yearLevel', $this->yearlevel) . "\n";
  26. $this->$Function();
  27. $this->FormattedQuestionForm .= '</br>';
  28. $this->FormattedQuestionForm .= e107::getForm()->button('Answered', 'Check answer') . "\n";
  29. $this->FormattedQuestionForm .= e107::getForm()->close();
  30. $this->FormattedQuestionForm .= '</br>';
  31. //print_a(['GetRandomQuestion', $this->FormattedQuestionForm]);
  32. return $this->FormattedQuestionForm;
  33. }
  34. private function YearOne() {
  35. $subjects = [
  36. 'english' => new EnglishYearOne(),
  37. //'languages' => $this->MathQuestions(),
  38. 'mathematics' => new MathYearOne(),
  39. //'science' => $this->MathQuestions(),
  40. ];
  41. $Class = $subjects[$this->subjectSelector];
  42. $this->FormattedQuestionForm .= e107::getForm()->hidden('subject', $this->subjectSelector) . "\n";
  43. $Class->RandomQuestion();
  44. $this->FormattedQuestionForm .= $Class->FormattedQuestionForm;
  45. }
  46. private function YearTwo() {
  47. $subjects = [
  48. 'english' => new EnglishYearTwo(),
  49. //'languages' => $this->MathQuestions(),
  50. 'mathematics' => new MathYearTwo(),
  51. //'science' => $this->MathQuestions(),
  52. ];
  53. $Class = $subjects[$this->subjectSelector];
  54. $this->FormattedQuestionForm .= e107::getForm()->hidden('subject', $this->subjectSelector) . "\n";
  55. $Class->RandomQuestion();
  56. $this->FormattedQuestionForm .= $Class->FormattedQuestionForm;
  57. }
  58. private function YearThree() {
  59. }
  60. private function YearFour() {
  61. }
  62. private function YearFive() {
  63. }
  64. private function YearSix() {
  65. }
  66. private function YearSeven() {
  67. }
  68. private function YearEight() {
  69. }
  70. private function YearNine() {
  71. }
  72. private function YearTen() {
  73. }
  74. private function YearEleven() {
  75. }
  76. private function YearTwelve() {
  77. $subjects = [
  78. 'english' => $this->MathQuestions(),
  79. 'pePd' => $this->MathQuestions(), //health-and-physical-education
  80. 'socialStudies' => $this->MathQuestions(), //humanities-and-social-sciences
  81. 'languages' => $this->MathQuestions(),
  82. 'mathematics' => $this->MathQuestions(),
  83. 'science' => $this->MathQuestions(),
  84. 'technologies' => $this->MathQuestions(),
  85. 'art' => $this->MathQuestions()
  86. ];
  87. $subjects[$this->subjectSelector];
  88. }
  89. }
  90. //////////////////////////////////////////////////////////////
  91. //////////////////////////////////////////////////////////////
  92. //////// Mathematics
  93. //////////////////////////////////////////////////////////////
  94. //////////////////////////////////////////////////////////////
  95. class MathYearOne {
  96. // Todo finish questions
  97. public $enabled = true;
  98. public $FormattedQuestionForm;
  99. private $diff = 0;
  100. function __construct() {
  101. $sql = e107::getDb();
  102. $userName = e107::getUser()->getLoginName();
  103. $this->diff = $sql->retrieve('timekeeperStats', 'timekeeper_percent', 'timekeeper_username="' . $userName . '" AND timekeeper_yearLevel=1');
  104. //print_a([$this->diff,'e107_timekeeperStats', '*', 'timekeeper_username="' . $userName . '"']);
  105. if (!isset($this->diff)) {
  106. $this->diff = 20;
  107. }
  108. }
  109. public function RandomQuestion() {
  110. $methods = preg_grep('/[^RandomQuestion]/', get_class_methods($this));
  111. $RandomEnglishType = rand(2, count($methods));
  112. $function = $methods[$RandomEnglishType];
  113. //print_a(['FunctionName'=>'RandomQusetion','Methods'=>$methods,'RandomSelectionNo'=>$RandomEnglishType,'CurrentSelection'=>$function]);
  114. return $this->$function();
  115. //return $this->gA();
  116. }
  117. private function NumberSequences() {
  118. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Find the missing number(s) in the sequence.</b>') . "\n";
  119. $this->FormattedQuestionForm .= '</br>';
  120. $startingNumber = rand(0, (int) ($this->diff*3));
  121. $incrementalNumber = rand(1, (int) ($this->diff * 2));
  122. $missingNumber = rand(1, 10);
  123. $TempQuestion = "";
  124. for ($i = 1; $i <= 10; $i++) {
  125. if ($i == $missingNumber) {
  126. $this->FormattedQuestionForm .= e107::getForm()->label('???') . "\n";
  127. $this->FormattedQuestionForm .= "&nbsp;-&nbsp;";
  128. $TempQuestion .= "___,";
  129. $solution = $startingNumber;
  130. } elseif ($i == 10) {
  131. $this->FormattedQuestionForm .= e107::getForm()->label($startingNumber) . "\n";
  132. $TempQuestion .= $startingNumber;
  133. } else {
  134. $this->FormattedQuestionForm .= e107::getForm()->label($startingNumber) . "\n";
  135. $this->FormattedQuestionForm .= "&nbsp;-&nbsp;";
  136. $TempQuestion .= $startingNumber . ",";
  137. }
  138. $startingNumber += $incrementalNumber;
  139. }
  140. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write first answer here!', 'autocomplete' => "off"]) . "\n";
  141. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', $solution) . "\n";
  142. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  143. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $TempQuestion) . "\n";
  144. }
  145. private function Addition() {
  146. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Addition, find the answers.</b>') . "\n";
  147. $this->FormattedQuestionForm .= '</br>';
  148. $firstNumber = rand(1, (int) ($this->diff * 13));
  149. $secondNumber = rand(1, $firstNumber);
  150. $this->FormattedQuestionForm .= e107::getForm()->label($firstNumber) . "\n";
  151. $this->FormattedQuestionForm .= e107::getForm()->label(" + " . $secondNumber) . "\n";
  152. $this->FormattedQuestionForm .= '</br>';
  153. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  154. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', $firstNumber + $secondNumber) . "\n";
  155. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  156. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $firstNumber . "+" . $secondNumber . "=") . "\n";
  157. }
  158. private function Subtraction() {
  159. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Subtraction, find the answers.</b>') . "\n";
  160. $this->FormattedQuestionForm .= '</br>';
  161. $firstNumber = rand(1, (int) ($this->diff * 9));
  162. $secondNumber = rand(1, $firstNumber);
  163. $this->FormattedQuestionForm .= e107::getForm()->label($firstNumber) . "\n";
  164. $this->FormattedQuestionForm .= e107::getForm()->label(" - " . $secondNumber) . "\n";
  165. $this->FormattedQuestionForm .= '</br>';
  166. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  167. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', $firstNumber - $secondNumber) . "\n";
  168. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  169. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $firstNumber . "-" . $secondNumber . "=") . "\n";
  170. }
  171. private function Multiplication() {
  172. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Multiplication, find the answers.</b>') . "\n";
  173. $this->FormattedQuestionForm .= '</br>';
  174. $firstNumber = rand(1, (int) ($this->diff*6));
  175. $secondNumber = rand(1, $firstNumber);
  176. $this->FormattedQuestionForm .= e107::getForm()->label($firstNumber) . "\n";
  177. $this->FormattedQuestionForm .= e107::getForm()->label(" x " . $secondNumber) . "\n";
  178. $this->FormattedQuestionForm .= '</br>';
  179. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  180. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', ($firstNumber * $secondNumber)) . "\n";
  181. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  182. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $firstNumber . "x" . $secondNumber . "=") . "\n";
  183. }
  184. private function Division() {
  185. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Division, find the answers (No remainders).</b>') . "\n";
  186. $this->FormattedQuestionForm .= '</br>';
  187. $firstNumber = rand(1, (int) ($this->diff*3));
  188. $secondNumber = rand(1, $firstNumber);
  189. $divNumber = $firstNumber * $secondNumber;
  190. $this->FormattedQuestionForm .= e107::getForm()->label($divNumber) . "\n";
  191. $this->FormattedQuestionForm .= e107::getForm()->label(" &#247; " . $secondNumber) . "\n";
  192. $this->FormattedQuestionForm .= '</br>';
  193. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  194. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($divNumber / $secondNumber)) . "\n";
  195. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  196. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $divNumber . " &#247; " . $secondNumber . "=") . "\n";
  197. }
  198. private function Rounding() {
  199. $firstNumber = sprintf("%01.2f", (float) rand(100, (int) ($this->diff) * 100) / 100);
  200. $answer = sprintf("%01.2f", round($firstNumber / 5, 2) * 5);
  201. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Rounding, round off $' . $firstNumber . ' to the nearest five cents.</b>') . "\n";
  202. $this->FormattedQuestionForm .= '</br>';
  203. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  204. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', '$' . $answer) . "\n";
  205. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  206. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Round $" . $firstNumber . " off to the nearest five cents") . "\n";
  207. }
  208. private function RoundingWorded() {
  209. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Rounding in practical use.</b>') . "\n";
  210. $this->FormattedQuestionForm .= '</br>';
  211. $names = ['Joe', 'Mat', 'Dug', 'Adam', 'Will', 'Nick'];
  212. $Quests = [['{Name1} went to the shop to buy some lollies they were {RandomQuantity} for ${RandomPrice}. How much did he pay in total if he bought {LimitedQuantity} ?'
  213. , '({RandomQuantity}*{RandomPrice})*{LimitedQuantity}'],
  214. ['{Name1} bought a puppy they were {RandomQuantity} for ${RandomPrice}. How much did he pay in total if he bought {LimitedQuantity} ?'
  215. , '({RandomQuantity}*{RandomPrice})*{LimitedQuantity}'],
  216. ['{Name1} sold bananas for {RandomQuantity} for ${RandomPrice}. How much did he make in total if he sold {LimitedQuantity} ?'
  217. , '({RandomPrice}/{RandomQuantity})*{LimitedQuantity}'],
  218. ];
  219. $RandomQuantity = 1;
  220. $RandomPrice = sprintf("%01.2f", (float) rand(100, (int) ($this->diff / 6) * 100) / 100);
  221. $LimitedQuantity = (int) rand(1, (int) $this->diff);
  222. $SelectedQuestionNo = array_rand($Quests);
  223. $SelectedNameNo = array_rand($names);
  224. $returnQuestion = str_replace('{LimitedQuantity}', $LimitedQuantity, str_replace('{RandomPrice}', $RandomPrice, str_replace('{RandomQuantity}', $RandomQuantity, str_replace('{Name1}', $names[$SelectedNameNo], $Quests[$SelectedQuestionNo][0]))));
  225. $returnAnswer = str_replace('{LimitedQuantity}', $LimitedQuantity, str_replace('{RandomPrice}', $RandomPrice, str_replace('{RandomQuantity}', $RandomQuantity, $Quests[$SelectedQuestionNo][1])));
  226. $solvedAnswer = sprintf("%01.2f", round(eval('return ' . $returnAnswer . ';') / 5, 2) * 5);
  227. // print_a(['returnAnswer'=>$returnAnswer,
  228. // 'returnQuestion'=>$returnQuestion,
  229. // 'Selection1and2'=>$SelectedQuestionNo.'-'.$SelectedNameNo,
  230. // 'question'=>$returnAnswer,
  231. // 'evaled'=>$solvedAnswer]);
  232. $this->FormattedQuestionForm .= e107::getForm()->label("Round off to the nearest five cents. " . $returnQuestion) . "\n";
  233. $this->FormattedQuestionForm .= '</br>';
  234. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  235. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', '$' . $solvedAnswer) . "\n";
  236. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  237. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Round off to the nearest five cents. " . $returnQuestion) . "\n";
  238. }
  239. private function Fractions() {// needs to be multi part question
  240. require_once( __DIR__ . '/fraction/src/Fraction.php');
  241. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Fractions, reduce to its simplest form to find the answers. (Answer as mixed fraction where possible.)</b>') . "\n";
  242. $this->FormattedQuestionForm .= '</br>';
  243. $multiplier = rand(1, (int)($this->diff/4));
  244. $nominator = rand(1, (int)($this->diff/4));
  245. $denominator = rand(1, (int)($this->diff/4));
  246. $fract1 = new Fraction($nominator*$multiplier, $denominator*$multiplier);
  247. //print_a(['fraction1'=>(string)$fract1,'fraction2'=>(string)$fract2,'fraction3'=>(string)$fract3,]); // 1/2
  248. $this->FormattedQuestionForm .= e107::getForm()->label($nominator*$multiplier) . "<br/>\n";
  249. $this->FormattedQuestionForm .= "-------<br/>\n";
  250. $this->FormattedQuestionForm .= e107::getForm()->label($denominator*$multiplier) . "\n";
  251. $this->FormattedQuestionForm .= '</br></br>';
  252. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!','autocomplete'=>"off"]) . "\n";
  253. $this->FormattedQuestionForm .= "-------<br/>\n";
  254. $this->FormattedQuestionForm .= e107::getForm()->text('q2', '', 80, ['placeholder' => 'Write answer here!','autocomplete'=>"off"]) . "\n";
  255. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int)($fract1->getNumerator())) . "\n";
  256. $this->FormattedQuestionForm .= e107::getForm()->hidden('a2', (int)($fract1->getDenominator())) . "\n";
  257. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 2) . "\n";
  258. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Simplify " . $nominator*$multiplier . " over " . $denominator*$multiplier) . "\n";
  259. }
  260. // fractions greater lesser then ie. 1/2 > 1/3 ?
  261. function gA() {
  262. $this->FormattedQuestionForm = e107::getForm()->label('<b>General Knowledge</b>') . "\n";
  263. $this->FormattedQuestionForm .= '</br>';
  264. $names = ['Joe', 'Mat', 'Dug', 'Adam', 'Will', 'Nick', 'Tim', 'Greg', 'Elliot'];
  265. $Quests = [['{Name1} ran {RandomQuantity}km. How many meters is that?'
  266. , '({RandomQuantity}*1000)','m'],
  267. ['{Name1} bought {RandomQuantity}m of string. How many centermeters did he buy?'
  268. , '({RandomQuantity}*100)','cm'],
  269. ['{Name1} ate {RandomQuantity}kg of roast beef. How many grams did he eat?'
  270. , '({RandomQuantity}*1000)','g'],
  271. ['{Name1} can build {RandomQuantity} cars a year. How many cars did he make last year?'
  272. , '({RandomQuantity})',''],
  273. ['{Name1} weighed {RandomQuantity}g of flux into a sample. How many mg did he weigh?'
  274. , '({RandomQuantity}*1000)','mg'],
  275. ['The perimeter of a square is {RandomQuantity} cm. What is the area of 2 such squares?'
  276. , '((({RandomQuantity}/4)*({RandomQuantity}/4))*2)','cm2'],
  277. ['{Name1} has ${RandomQuantity} and Silas has three times more than {Name1}. How much money do they have altogether?'
  278. , '"$".({RandomQuantity}+({RandomQuantity}*3))',''],
  279. ['The area of 2 squares is {RandomQuantity} cm². What is the area of 3 such squares?'
  280. , '(({RandomQuantity}/2)*3)','cm2'],
  281. //['A coffee costs $2.50. {Name1} spent $17.50. How many coffees did he buy?'
  282. // , '(2.5*{RandomQuantity})', '']
  283. //['An adult bus ticket costs $6.50 and a child ticket costs $4. How much would 2 adults and 5 children cost to take the bus?'
  284. // , '(({RandomQuantity}/2)*3)','cm2'],
  285. ];
  286. $RandomQuantity = sprintf("%01.1f", (float) rand(100, (int) ($this->diff / 6) * 100) / 100);
  287. $SelectedQuestionNo = array_rand($Quests);
  288. $SelectedNameNo = array_rand($names);
  289. $returnQuestion = str_replace('{RandomQuantity}', $RandomQuantity, str_replace('{Name1}', $names[$SelectedNameNo], $Quests[$SelectedQuestionNo][0]));
  290. $returnAnswer = str_replace('{RandomQuantity}', $RandomQuantity, $Quests[$SelectedQuestionNo][1]);
  291. $solvedAnswer = eval('return ' . $returnAnswer . ';');
  292. $this->FormattedQuestionForm .= e107::getForm()->label($returnQuestion) . "\n";
  293. $this->FormattedQuestionForm .= '</br>';
  294. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  295. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', $solvedAnswer.$Quests[$SelectedQuestionNo][2]) . "\n";
  296. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  297. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $returnQuestion) . "\n";
  298. }
  299. }
  300. class MathYearTwo {
  301. // Todo finish questions
  302. public $enabled = true;
  303. public $FormattedQuestionForm;
  304. private $diff = 0;
  305. function __construct() {
  306. $sql = e107::getDb();
  307. $userName = e107::getUser()->getLoginName();
  308. $this->diff = $sql->retrieve('timekeeperStats', 'timekeeper_percent', 'timekeeper_username="' . $userName . '" AND timekeeper_yearLevel=1');
  309. //print_a([$this->diff,'e107_timekeeperStats', '*', 'timekeeper_username="' . $userName . '"']);
  310. if (!isset($this->diff)) {
  311. $this->diff = 20;
  312. }
  313. }
  314. public function RandomQuestion() {
  315. $methods = preg_grep('/[^RandomQuestion]/', get_class_methods($this));
  316. $RandomEnglishType = rand(2, count($methods));
  317. $function = $methods[$RandomEnglishType];
  318. //print_a(['FunctionName'=>'RandomQusetion','Methods'=>$methods,'RandomSelectionNo'=>$RandomEnglishType,'CurrentSelection'=>$function]);
  319. return $this->$function();
  320. }
  321. private function Time() {
  322. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Time.</b>') . "\n";
  323. $this->FormattedQuestionForm .= '</br>';
  324. $firstNumber = rand(1, (int) ($this->diff / 4));
  325. $secondNumber = rand(1, $firstNumber);
  326. $this->FormattedQuestionForm .= e107::getForm()->label($firstNumber) . "\n";
  327. $this->FormattedQuestionForm .= e107::getForm()->label(" &#247; " . $secondNumber) . "\n";
  328. $this->FormattedQuestionForm .= '</br>';
  329. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  330. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($firstNumber / $secondNumber)) . "\n";
  331. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  332. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $firstNumber . " &#247; " . $secondNumber . "=") . "\n";
  333. }
  334. }
  335. //////////////////////////////////////////////////////////////
  336. //////////////////////////////////////////////////////////////
  337. //////// English
  338. //////////////////////////////////////////////////////////////
  339. //////////////////////////////////////////////////////////////
  340. class EnglishYearOne {
  341. // Todo finish questions
  342. public $enabled = false;
  343. public $FormattedQuestionForm;
  344. public function RandomQuestion() {
  345. $methods = preg_grep('/[^RandomQuestion]/', get_class_methods($this));
  346. $RandomEnglishType = rand(1, count($methods));
  347. $function = $methods[$RandomEnglishType];
  348. $this->$function();
  349. }
  350. private function Spelling() {
  351. include_once './resources/spellingLists.php';
  352. //print_a($wordsList);
  353. $words = [
  354. ['action', 'I like to watch action movies.'],
  355. ['actor', 'I thought the actor was good in that movie.'],
  356. ['actually', 'Did you actually think that would work.'],
  357. ['addition', 'Did you know addition is part of maths.'],
  358. ['agreed', 'I thought we agreed not to fight.'],
  359. ['allowed', 'Are you allowed to do that.'],
  360. ['aloud', 'Say your name out aloud.'],
  361. ['amendment', 'Do you know your first amendment rights.'],
  362. ['amount', 'What amount did you pay for that.'],
  363. ['amusement', 'Are you going on the amusement rides later.'],
  364. ['annual', 'Your birthday is an annual event.'],
  365. ['appointed', 'Do you know who the appointed prime minister is.'],
  366. ['arrange', 'Lets arrange to meet tomorrow afternoon.'],
  367. ['attention', 'Are you paying attention to what was just said.'],
  368. ['awhile', 'Could you wait awhile please.'],
  369. ['beginning', 'Did you understand the beginning of that movie.'],
  370. ['bruise', 'Did you get a bruise while playing sport.'],
  371. ['business', 'What kind of business would you like to open.'],
  372. ['calves', 'Did you see all the calves in the paddock.'],
  373. ['capital', 'Canberra is the capital city of Australia.'],
  374. ['capitol', 'The capitol building is where a legislature meets.'],
  375. ['captain', 'Did you see the captain of this ship.'],
  376. ['carefully', 'Walk down the stairs carefully so you don\'t fall.'],
  377. ['caught', 'The cat caught the mouse.'],
  378. ['cause', 'What do you think the cause of that is.'],
  379. ['celebrate', 'How do you want to celebrate your birthday.'],
  380. ['century', 'A century is one hundred years.'],
  381. ['chemical', 'What kind of chemical is lemon juice.'],
  382. ['chocolate', 'Would you like some chocolate ice cream.'],
  383. ['circle', 'Can you draw a circle neatly.'],
  384. ['climate', 'The weather is part of the climate.'],
  385. ['climbed', 'The hiker climbed up the hill.'],
  386. ['collar', 'My dog has a collar that he wears.'],
  387. ['column', 'Did you read the news column yesterday.'],
  388. ['company', 'What kind of company would you like to start.'],
  389. ['condition', 'What condition is your car in.'],
  390. ['consider', 'Would you consider this fun.'],
  391. ['consonant', 'The distinction between consonant and vowel is not always clear.'],
  392. ['constant', 'In math a constant is a number that is fixed and known.'],
  393. ['continent', 'A continent is one of several very large landmasses.'],
  394. ['continued', 'Was your story continued from the last one.'],
  395. ['country', 'Which country would you like to visit next.'],
  396. ['course', 'Lets go to the race course today.'],
  397. ['crystal', 'Check out that crystal vase in the shop.'],
  398. ['current', 'What is the current weather where you are.'],
  399. ['curtain', 'Coult you open the curtain to let some light in.'],
  400. ['daughter', 'Does your daughter like ice cream.'],
  401. ['daytime', 'Is it daytime where you are.'],
  402. ['decided', 'I thought we decided to watch the movie.'],
  403. ['decimal', 'Do not forget the decimal place when doing math.'],
  404. ['delicious', 'That was a delicious apple pie.'],
  405. ['desert', 'Do not desert your army unit.'],
  406. ['dessert', 'we made a dessert of chocolate mousse.'],
  407. ['details', 'You need to give more details so people understand.'],
  408. ['determine', 'You need to determine why that happened.'],
  409. ['dictionary', 'A dictionary lists words and their meanings.'],
  410. ['difference', 'Can you see the difference between the two dogs.'],
  411. ['different', 'Do you know which is the different picture.'],
  412. ['difficult', 'It is very difficult to copy a painting perfectly.'],
  413. ['direction', 'Are you sure this is the right direction to take.'],
  414. ['disappoint', 'You could disappoint me if you get this wrong.'],
  415. ['division', 'I am not very good at long division in math.'],
  416. ['eighth', 'This is the eighth day of the month.'],
  417. ['election', 'Who did you vote for in the election today.'],
  418. ['elements', 'Do you know the periodic table of elements in science.'],
  419. ['energy', 'Do you have the energy to participate in another race.'],
  420. ['enjoyment', 'Do you find enjoyment getting these answers right.'],
  421. ['equal', 'What is equal to one plus one.'],
  422. ['equation', 'A math equation can be fun to figure out.'],
  423. ['errands', 'What errands do you have to run today.'],
  424. ['exact', 'Please be exact with your answers.'],
  425. ['except', 'I have finished all the letters except one.'],
  426. ['expect', 'I expect you to get this question right.'],
  427. ['explain', 'Please explain yourself clearly.'],
  428. ['explode', 'Bombs can explode even when not set off.'],
  429. ['express', 'Did you send your letter via express post.'],
  430. ['factory', 'What happened at the toy factory today.'],
  431. ['fault', 'There was a fault in the manufacturing process.'],
  432. ['favorite', 'What is your favorite ice cream.'],
  433. ['finally', 'We finally finished all of out studies today.'],
  434. ['finished', 'We finally finished all of out studies today.'],
  435. ['forward', 'Pushing up on the control makes the car move forward.'],
  436. ['fought', 'You fought with your brother again.'],
  437. ['fraction', 'What fraction of your class is boys.'],
  438. ['furniture', 'Should we go to the furniture store today.'],
  439. ['future', 'I the future you will be better at this.'],
  440. ['general', 'The arrangements were outlined in very general terms.'],
  441. ['government', 'Most countries have a government to run them.'],
  442. ['graceful', 'The girl was very graceful as she moved across the room.'],
  443. ['graph', 'Did you see the bar graph at the convention.'],
  444. ['grasp', 'Do you have a grasp on the topic at hand.'],
  445. ['grease', 'You can use grease to lubricate machinery.'],
  446. ['grown-ups', 'I do not like it when grown-ups get all serious.'],
  447. ['guest', 'Would you show our guest to his room.'],
  448. ['guide', 'Did you follow the guide during the tour.'],
  449. ['happened', 'What happened to your knee.'],
  450. ['happily', 'He happily went to school this morning.'],
  451. ['harvest', 'The farmer was happy the harvest went well this year.'],
  452. ['healthy', 'The baby was healthy when he was born.'],
  453. ['height', 'What is the height of that tree over there.'],
  454. ['hoarse', 'The grumpy old man has a hoarse voice.'],
  455. ['human', 'Pet food is not fit for human consumption.'],
  456. ['idea', 'Do you have any idea how he got up there.'],
  457. ['imagine', 'Can you imagine how much fun that would be.'],
  458. ['include', 'Remember to include your brother when you are playing games.'],
  459. ['increase', 'Can you increase the temperature as I am feeling cold.'],
  460. ['indicate', 'Sales indicate a growing market for such art.'],
  461. ['information', 'What information do you need.'],
  462. ['instrument', 'What is your favorte musical instrument to play.'],
  463. ['intention', 'What is your intention with that foam sword.'],
  464. ['interesting', 'The news was very interesting today.'],
  465. ['inventor', 'Do you know the inventor that created the light bulb.'],
  466. ['island', 'Australia is the largest island in the world.'],
  467. ['jewel', 'She was the jewel of his eye.'],
  468. ['journey', 'I am embarking on a journey around the world.'],
  469. ['jungle', 'The tree tops of the jungle make a canopy.'],
  470. ['knives', 'I bought a block of knives from the home store.'],
  471. ['known', 'He was well known throughout the land.'],
  472. ['language', 'What other language do you speak.'],
  473. ['laughter', 'The audience bust into laughter while watching the comedian.'],
  474. ['length', 'How long was the length of string.'],
  475. ['limb', 'Did you break the tree limb while you were climbing it.'],
  476. ['located', 'Where is the school located on the map.'],
  477. ['lumber', 'We went to the lumber yard to buy some wood.'],
  478. ['major', 'The use of drugs is a major problem.'],
  479. ['mammal', 'Did you know every mammal is warm blooded.'],
  480. ['manufacture', 'Do you know where they manufacture those toys.'],
  481. ['material', 'What material is her dress made of.'],
  482. ['mayor', 'Did you see the mayor of the city.'],
  483. ['measure', 'You can use a ruler to measure things.'],
  484. ['melody', 'Can you play a melody on the flute.'],
  485. ['members', 'Do you know who the members of parliment are.'],
  486. ['memories', 'Do you have good memories of your last holiday.'],
  487. ['message', 'What message would you like to pass.'],
  488. ['method', 'What method do you use to remember things.'],
  489. ['million', 'I would love to have one million dollars.'],
  490. ['minor', 'That was only a minor car crash.'],
  491. ['modern', 'Do you like modern art.'],
  492. ['mountain', 'Can you see the mountain in the distance.'],
  493. ['music', 'What kind of music do you like.'],
  494. ['natural', 'Carrots contain a natural antiseptic.'],
  495. ['necessary', 'The council granted the necessary planning permission.'],
  496. ['neither', 'He didn\'t remember, and neither did I.'],
  497. ['newspaper', 'The local newspaper had the story.'],
  498. ['northern', 'The cliff protects the bay from the northern winds.'],
  499. ['notebook', 'Make sure you write it down in your notebook so you don\'t forget.'],
  500. ['notice', 'The jobs were advertised in a notice posted in the newspaper.'],
  501. ['noun', 'Example of a noun is a "toothbrush".'],
  502. ['numeral', 'Do you know what the roman numeral "X" stands for.'],
  503. ['object', 'Disease became the object of investigation.'],
  504. ['observe', 'Shouldn\'t you observe what the teacher is showing.'],
  505. ['opposite', 'Whats the opposite of left.'],
  506. ['orphan', 'An orphan is a child without parents.'],
  507. ['ought', 'Five minutes ought to be enough time,'],
  508. ['outside', 'Do you want to go outside to play.'],
  509. ['oxygen', 'There is oxygen in the air we breathe.'],
  510. ['paid', 'I paid the bill using my key card.'],
  511. ['paint', 'Could you help me paint the house.'],
  512. ['paragraph', 'Did you read the whole paragraph of the story.'],
  513. ['pattern', 'What pattern is that on your shirt.'],
  514. ['pause', 'Can you pause your movie for a minute to help me.'],
  515. ['payment', 'How did you make the payment while shopping.'],
  516. ['perhaps', 'Would you perhaps consent to act as our guide.'],
  517. ['period', 'The Cretaceous period was a time that dinosaurs existed.'],
  518. ['permit', 'Some places require a parking permit to park there.'],
  519. ['phone', 'Did someone call your phone just now.'],
  520. ['phrase', 'Could you repeat that phrase again.'],
  521. ['pleasant', 'Try to be pleasant when talking to people.'],
  522. ['pleasure', 'She smiled with pleasure at being praised.'],
  523. ['plural', 'The plural of a word eans there is more than one.'],
  524. ['poison', 'Be careful as there is poison in that bottle.'],
  525. ['position', 'What position would you like to play as.'],
  526. ['possible', 'I did not think that was possible in this game.'],
  527. ['practice', 'You need lots of practice to get good at things.'],
  528. ['prepared', 'Make sure you are well prepared for the test later.'],
  529. ['president', 'Do you know who is the president of the European Union.'],
  530. ['probably', 'She would probably never see him again.'],
  531. ['problem', 'What seems to be the problem that you are experiencing.'],
  532. ['process', 'The manufacturing process is relatively simple.'],
  533. ['produce', 'The produce of a farm is fruit and vegetables.'],
  534. ['program', 'An extensive program of reforms.'],
  535. ['promise', 'I promise to do my studies later.'],
  536. ['property', 'She wanted Oliver and his property out of her flat.'],
  537. ['protection', 'Make sure you have protection on when you go out to play.'],
  538. ['provide', 'Can you provide more details please.'],
  539. ['puzzle', 'Did you solve the puzzle yesterday.'],
  540. ['quickly', 'Can you quickly answer the question.'],
  541. ['quietly', 'Can you quietly answer the question.'],
  542. ['radio', 'What radio station are you listening to.'],
  543. ['raise', 'You can raise chickens for eggs.'],
  544. ['rarely', 'You rarely find gold on the ground.'],
  545. ['rather', 'She has been behaving rather strangely.'],
  546. ['reached', 'The boy reached out to catch the ball.'],
  547. ['receive', 'Did you receive your letter of approval.'],
  548. ['record', 'We should record a song together.'],
  549. ['region', 'What region do you live in.'],
  550. ['relax', 'Try to relax at the spa later.'],
  551. ['remain', 'Try to remain impartial in the debate.'],
  552. ['remove', 'Can you remove your toys from the kitchen.'],
  553. ['repay', 'Just repay me when you get the money.'],
  554. ['repeat', 'Can you repeat what you just said.'],
  555. ['report', 'What did your school report say.'],
  556. ['represent', 'The lawyer can represent you in court.'],
  557. ['respond', 'Please respond when someone speaks to you.'],
  558. ['result', 'What is the result of the test.'],
  559. ['rhythm', 'Do you like the rhythm of this song.'],
  560. ['rising', 'I think the tide is rising quickly.'],
  561. ['ruin', 'Do not drag your feet or you will ruin your shoes.'],
  562. ['salad', 'Would you like some salad with dinner.'],
  563. ['sandal', 'A sandal is a type of open toed shoe.'],
  564. ['scale', 'I found a scale in my fish soup.'],
  565. ['scent', 'A flowers scent can be beautiful.'],
  566. ['schedule', 'The train follows a strict schedule of stops.'],
  567. ['science', 'Do you like science at school.'],
  568. ['section', 'What section of the class are you in.'],
  569. ['separate', 'Keep the ingredients separate until you are told to mix them.'],
  570. ['service', 'We need to send the car for service later today.'],
  571. ['settled', 'When the class settled the teacher started teaching.'],
  572. ['several', 'When several students misbehave the teacher gets mad.'],
  573. ['shadow', 'A sundial uses a shadow to tell the time.'],
  574. ['shelter', 'We better get to shelter before the storm get here.'],
  575. ['shoulder', 'The man carried the log on his shoulder because it was heavy.'],
  576. ['shouted', 'The man shouted at the kids to stay out of the worksite.'],
  577. ['shower', 'Remember to have a shower before going to bed.'],
  578. ['signal', 'Remember to signal when turning the corner.'],
  579. ['similar', 'That bike looks similar to yours.'],
  580. ['sincerely', 'I sincerely hope you get this right.'],
  581. ['single', 'She wrote down every single word.'],
  582. ['size', 'What size clothes do you wear.'],
  583. ['slippery', 'Be careful as the shower is slippery when wet.'],
  584. ['soar', 'The eagle can soar high in the sky.'],
  585. ['soil', 'The farmer needed to order more soil for his farm.'],
  586. ['solution', 'The solution to the puzzle is on the back page.'],
  587. ['solve', 'Can you solve that puzzle.'],
  588. ['southern', 'Australia is in the southern hemisphere.'],
  589. ['split', 'The man used the axe to split the wood.'],
  590. ['spoiled', 'What a spoiled little brat.'],
  591. ['sports', 'What sports do you like to play.'],
  592. ['square', 'Is that a square or a triangle.'],
  593. ['squeeze', 'Do you like to squeeze the juice out of oranges.'],
  594. ['stain', 'Be careful as chocolate can stain very badly.'],
  595. ['state', 'Do you know what state you live in.'],
  596. ['statement', 'The police gave a statement about crime.'],
  597. ['station', 'The trian stopped at the station to pick up passengers.'],
  598. ['steer', 'The driver can steer the car around.'],
  599. ['stomach', 'My stomach is painful after eating too much.'],
  600. ['stopping', 'Caution, frequently stopping vehicle.'],
  601. ['straight', 'I can see straight down the road.'],
  602. ['straighten', 'I got the hair dresser to straighten my hair.'],
  603. ['stream', 'I like to sit by the stream and read a book.'],
  604. ['stretched', 'Wear your jumper properly so it doesn\'t get stretched further.'],
  605. ['suggest', 'I suggest you pay attention to your studies.'],
  606. ['suitcase', 'Have you packed your suitcase for the trip.'],
  607. ['sunset', 'I would live to watch the sunset over the ocean.'],
  608. ['supply', 'The army supply depot ran out of bullets.'],
  609. ['sure', 'Are you sure you want to do that.'],
  610. ['surface', 'The surface of the salt lake is very flat.'],
  611. ['surprise', 'The announcement came as a complete surprise to all of us.'],
  612. ['surround', 'The army tried to surround the enemy.'],
  613. ['sweater', 'It is cold outside, you should put your sweater on.'],
  614. ['syllable', 'Can you name a two syllable word.'],
  615. ['syrup', 'What kind of syrup would you like on your pancakes.'],
  616. ['tablet', 'Do you like using a tablet computer.'],
  617. ['tasty', 'Would you like a bite of my tasty pie.'],
  618. ['teaspoon', 'Could you get a teaspoon for my coffee please.'],
  619. ['terrible', 'Your brother can make a terrible mess at times.'],
  620. ['though', 'You will be informed of its progress, slow though that may be.'],
  621. ['thoughtful', 'That was a very thoughtful gift to give.'],
  622. ['thrown', 'The ball was thrown into the play area.'],
  623. ['tornado', 'The tornado destroyed alot of houses.'],
  624. ['toward', 'Move toward your brother so we can take the photo.'],
  625. ['traffic', 'The traffic down town is quite busy.'],
  626. ['trail', 'Please keep to the trail while bush walking.'],
  627. ['treasure', 'The treasure map has a big "X" on it.'],
  628. ['treatment', 'You may need to go to hospital for treatment of your injuries.'],
  629. ['triangle', 'A triangle is a shape that has three sides.'],
  630. ['trouble', 'Try to stay out of trouble while playing.'],
  631. ['tunnel', 'The train goes through a tunnel to cross the mountian.'],
  632. ['type', 'What type of food do you like to eat.'],
  633. ['understood', 'I hope you understood the directions.'],
  634. ['unknown', 'Exploration into unknown territory can be exciting.'],
  635. ['usually', 'I usually go to the shops early in the morning.'],
  636. ['value', 'What is the value of your house.'],
  637. ['various', 'There are various ways to learn.'],
  638. ['warn', 'Did you warn your friends about the wasp nest.'],
  639. ['weigh', 'Can you weigh yourself on the scales.'],
  640. ['weight', 'What is your weight on the scales.'],
  641. ['weird', 'Thats a weird way to do things.'],
  642. ['western', 'There will be showers in some western areas.'],
  643. ['whisper', 'Can you whisper the answer to me.'],
  644. ['whoever', 'Thank you whoever you are.'],
  645. ['whole', 'Would you like a whole apple.'],
  646. ['whose', 'I wonder whose shoes those are.'],
  647. ['wives', 'The wives went shopping together.'],
  648. ['women', 'The women had a meet up at the local coffee shop.'],
  649. ['wonderful', 'It is a wonderful day outside.'],
  650. ['wound', 'The guy had a gun wound after he was shot.'],
  651. ['wreck', 'We are going diving at the ship wreck.'],
  652. ['x-ray', 'Did they x-ray your broken arm.'],
  653. ['yesterday', 'What did you do yesterday after school.'],
  654. ];
  655. // $words = [
  656. // ['Actor','The movie had some good actors in it.'],
  657. // ['addition','Can you do addition.'],
  658. // ['advice','Can I give you some advice on how to beat the game.'],
  659. // ['against','Today you will be playing against a team.'],
  660. // ['ahead','If you study hard you can get ahead of your class.'],
  661. // ['amount','What is the amount of money you need to buy something.'],
  662. // ['annual','Christmas is an annual event.'],
  663. // ['answer','You need to answer this question.'],
  664. // ['apiece','The cupcakes are two dollars apiece.'],
  665. // ['argue','You should not argue with your parents.'],
  666. // ['author','Did you see who the author of that book is.'],
  667. // ['avoid','You should avoid making mistakes.'],
  668. // ['beetle','There was a beetle in the garden.'],
  669. // ['borrow','Can I borrow your book.'],
  670. // ['breath','Take a deep breath and calm down.'],
  671. // ['calm','Keep calm while talking to people.'],
  672. // ['canal','Can you see all the water in the canal.'],
  673. // ['cannon','The army has a big cannon.'],
  674. // ['central','The post office is in a central location.'],
  675. // ['charge','You need to charge your phone.'],
  676. // ['collar','Your shirt has a collar.'],
  677. // ['continue','Can you continue reading your book.'],
  678. // ['creation','What kind of creation are you working on.'],
  679. // ['cried','I cried when my brother hit me.'],
  680. // ['daily','The daily paper had some bad news in it.'],
  681. // ['decorator','The decorator did a good job with this room.'],
  682. // ['device','A tape measure is a device used for measuring lenghts.'],
  683. // ['direction','Which direction is north.'],
  684. // ['earthquake','The earthquake was very scary.'],
  685. // ['enough','When you have had enough to eat you may leave the table.'],
  686. // ['excuse','You need a better excuse to get out of studying.'],
  687. // ['fraction','Your math has one more fraction left until its finished.'],
  688. // ['furniture','The furniture shop sells some nice tables.'],
  689. // ['ghost','The ghost scared everyone that night.'],
  690. // ['guess','Try to guess what im holding behind my back.'],
  691. // ['ignore','When someone calls you names just ignore them.'],
  692. // ['island','There is an island just off the coast.'],
  693. // ['journal','You can keep a journal of things you have done.'],
  694. // ['judge','You should be able to judge how far away the car is.'],
  695. // ['kept','He kept his promise to play after school.'],
  696. // ['ledge','Please stay away for the ledge so you dont fall off.'],
  697. // ['lettuce','Would you like lettuce on your burger.'],
  698. // ['manage','If you manage to finish your studies you can play.'],
  699. // ['mention','Dont mention to your friends about the movie on tonight.'],
  700. // ['narrate','You need to narrate the movie we are making.'],
  701. // ['nineteen','Runner nineteen won the race.'],
  702. // ['noisy','The neighbours can be very noisy at times.'],
  703. // ['often','Try not to make mistakes too often.'],
  704. // ['palm','Palm trees like to grow near the beach.'],
  705. // ['people','There are lots of people at the station.'],
  706. // ['portion','You can have a portion of the pie for dinner.'],
  707. // ['praise','The teacher will praise you if you do a good job.'],
  708. // ['remark','The teacher left a remark on my report card.'],
  709. // ['repair','The mechanic knows how to repair the car.'],
  710. // ['royal','The queen is part of the royal family.'],
  711. // ['shear','Do you know how to shear a sheep.'],
  712. // ['slept','The baby slept most of the day.'],
  713. // ['station','The train stops at the station to pick up passengers.'],
  714. // ['steam','The steam engine runs on steam.'],
  715. // ['strange','Its strange that you dont like sweets.'],
  716. // ['stretch','Can you stretch up and reach the roof.'],
  717. // ['sweat','It so hot outside that it will make you sweat.'],
  718. // ['terrible','Sometimes little borthers and sisters can make a terrible mess.'],
  719. // ['themselves','Some people only think of themselves.'],
  720. // ['thirsty','If you dont drink you will be thirsty.'],
  721. // ['throne','The queen sits on a throne.'],
  722. // ['tried','I tried to study hard.'],
  723. // ['trouble','If you dont do as you ar told you will get into trouble.'],
  724. // ['understand','If you dont understand what I said then I can repeat it.'],
  725. // ['until','You must study until you understand the subject.'],
  726. // ['vacation','The vacation we had in asia was fun.'],
  727. // ['visitor','If you go to see someone at their house you are a visitor.'],
  728. // ['vocal','If someone shares their opinion they are being vocal.'],
  729. // ['wander','If you wander aroud the shopping centre you may get lost.'],
  730. // ['weave','Do you know how to weave a basket.'],
  731. // ['whenever','You can ask for help whenever you need it.'],
  732. // ['whole','Can you really put the whole fork in your mouth.'],
  733. // ];
  734. // $words = ['add', 'after', 'again', 'any', 'apple', 'arm', 'banana', 'bark', 'been', 'being', 'bent', 'best', 'bone', 'black', 'block', 'blue', 'bring', 'brown', 'bush', 'came', 'cane', 'card', 'cart', 'case', 'chain', 'chair', 'chalk', 'chat', 'chin', 'chop', 'clam', 'clan', 'clap', 'claw', 'clay', 'clean', 'cool', 'dark', 'desk', 'drop', 'end', 'family', 'fang,fast', 'fell', 'few', 'fill', 'flag', 'flat', 'fool', 'foot', 'fort', 'free', 'fresh', 'from', 'glad', 'golf', 'gone', 'grit', 'hand', 'hang', 'happy', 'harm', 'help', 'here', 'hide', 'hill', 'hint', 'hope', 'horn', 'how', 'ill', 'into', 'jaw', 'joke', 'just', 'keep', 'king', 'last', 'line', 'look', 'luck', 'made', 'many', 'meal', 'must', 'nice', 'new', 'next', 'odd', 'put', 'quit', 'rang', 'space', 'said', 'time', 'was', 'yard', 'yarn',
  735. // 'baseball', 'brother', 'can\'t', 'clover', 'cloud', 'crayon', 'club', 'coat', 'come', 'cookie', 'could', 'crow', 'cube', 'cupcake', 'deal', 'dew', 'didn\'t', 'dime', 'dine', 'dirt', 'doll', 'don\'t', 'door', 'draw', 'dream', 'dress', 'drink', 'dull', 'each', 'east', 'easy', 'eight', 'eleven', 'every', 'father', 'field', 'fine', 'first', 'flew', 'flower', 'friend', 'globe', 'going', 'grape', 'grass', 'grew', 'heavy', 'I\'m', 'it\'s', 'know', 'marker', 'maybe', 'milk', 'morning', 'mother', 'myself', 'much', 'never', 'notebook', 'other', 'over', 'paper', 'pencil', 'pretty', 'rabbit', 'school', 'seven', 'sew', 'shirt', 'sister', 'smell', 'stray', 'string', 'summer', 'start', 'swing', 'table', 'thank', 'thrift', 'twelve', 'twist', 'under', 'very', 'water', 'were', 'where', 'won\'t', 'yellow', 'zebra', 'zero',
  736. // 'always', 'animal', 'around', 'because', 'before', 'believe', 'between', 'bread', 'bright', 'busy', 'cannot', 'caught', 'charge', 'clapped', 'clean', 'chicken', 'children', 'doctor', 'does', 'goes', 'everyone', 'everywhere', 'flight', 'inside', 'juice', 'kitchen', 'laughter', 'lunchroom', 'nobody', 'once', 'orange', 'outside', 'piece', 'purple', 'raise', 'round', 'shoes', 'today', 'used', 'weak', 'week', 'whale', 'which', 'while', 'wool', 'yesterday'];
  737. //$RandomEnglishWord = $words[rand(1, count($words))];
  738. $RandomEnglishWord = $words[array_rand($words)];
  739. //exec('espeak -ven+f3 -k5 -s125 -w"./audio/'.$RandomEnglishWord[0].'.wav" "Spell the word, '.$RandomEnglishWord[0].'. '.$RandomEnglishWord[1].'"');
  740. //./audio/flite-2.0.0-release/bin/flite -voice ./audio/voices/cmu_us_aew.flitevox -o "./audio/'.$RandomEnglishWord[0].'.wav" "Spell the word, '.$RandomEnglishWord[0].'. '.$RandomEnglishWord[1].'"');
  741. exec('./audio/flite-2.0.0-release/bin/flite -voice ./audio/voices/cmu_us_aew.flitevox -o "./audio/' . $RandomEnglishWord[0] . '.wav" "Spell the word, ' . $RandomEnglishWord[0] . '. ' . $RandomEnglishWord[1] . '"');
  742. //print_a([exec('ls ./audio/'),$RandomEnglishWord]);
  743. $this->FormattedQuestionForm .= "<audio controls><source src='audio/" . $RandomEnglishWord[0] . ".wav' type='audio/wav'>Your browser does not support the audio element.</audio> ";
  744. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]);
  745. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', $RandomEnglishWord[0]);
  746. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1);
  747. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Spell the word " . $RandomEnglishWord[0] . "");
  748. }
  749. }
  750. class EnglishYearTwo {
  751. // Todo finish questions
  752. public $enabled = false;
  753. public function RandomQuestion() {
  754. $methods = preg_grep('/[^RandomQuestion]/', get_class_methods($this));
  755. $RandomEnglishType = rand(1, count($methods));
  756. $function = $methods[$RandomEnglishType];
  757. $this->$function();
  758. }
  759. //centry
  760. //mellenium etc...
  761. private function Nouns() {
  762. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Nouns.</b>') . "\n";
  763. $this->FormattedQuestionForm .= '</br>';
  764. $firstNumber = rand(1, (int) ($this->diff / 4));
  765. $secondNumber = rand(1, $firstNumber);
  766. $divNumber = $firstNumber * $secondNumber;
  767. $this->FormattedQuestionForm .= e107::getForm()->label($divNumber) . "\n";
  768. $this->FormattedQuestionForm .= e107::getForm()->label(" &#247; " . $secondNumber) . "\n";
  769. $this->FormattedQuestionForm .= '</br>';
  770. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  771. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($divNumber / $secondNumber)) . "\n";
  772. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 1) . "\n";
  773. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', $divNumber . " &#247; " . $secondNumber . "=") . "\n";
  774. }
  775. private function SingularPluralNouns() {
  776. }
  777. private function CountableUncountableNouns() {
  778. }
  779. private function Pronouns() {
  780. }
  781. private function Possession() {
  782. }
  783. private function Agreement() {
  784. }
  785. private function Adjectives() {
  786. }
  787. private function ComparisonOfAdjectives() {
  788. }
  789. private function DefiniteIndefiniteArticles() {
  790. }
  791. private function SomeAndAny() {
  792. }
  793. private function FormsOfVerbs() {
  794. }
  795. private function TheVerbToBe() {
  796. }
  797. private function SimplePresentTense() {
  798. }
  799. private function PresentConttinuousTense() {
  800. }
  801. private function PresentPerfectTense() {
  802. }
  803. private function SimplePastTense() {
  804. }
  805. private function PastContinuousTense() {
  806. }
  807. private function SimpleFutureAndGoingToForm() {
  808. }
  809. private function ConditionalIf() {
  810. }
  811. private function Adverbs() {
  812. }
  813. private function ComparisonOfAdverbs() {
  814. }
  815. private function JoiningSentences() {
  816. }
  817. private function Conjuctions() {
  818. }
  819. private function PositiveNegativeSentences() {
  820. }
  821. private function ShortForms() {
  822. }
  823. private function QuestionWords() {
  824. }
  825. private function QuestionTags() {
  826. }
  827. private function ShortAnswersReplies() {
  828. }
  829. private function Prepositions() {
  830. }
  831. private function Punctuation() {
  832. }
  833. }
  834. //
  835. // check to see if a question has been correct 10 time in a row and then perfere it less.
  836. class Question_Engine_2 {
  837. public $QuestionArray;
  838. ////////////////////////////////////////////////////////////////////////////
  839. /// Construct and main entry point.
  840. ////////////////////////////////////////////////////////////////////////////
  841. // Construct Question_Engine inital values
  842. public function __construct($subject, $difficulty) {
  843. // Set QuestionArray array and subject as first value
  844. $this->QuestionArray = ['subjectMajor' => $subject];
  845. // Add difficulty to QuestionArray
  846. $this->QuestionArray['difficulty'] = $difficulty;
  847. }
  848. // Main entry point to the question generator.
  849. public function generate() {
  850. $tmp = ['test' => $this->generalKnowledge(),];
  851. $tmp['test'];
  852. // Call sub question generator for major subject
  853. switch ($this->subject) {
  854. // Call question fetcher directly as there is no sub sections
  855. case "general":
  856. $this->generalKnowledge();
  857. break;
  858. // Call sub generate to select a minor subject
  859. case "math":
  860. $this->subGenerateMath();
  861. break;
  862. case "math":
  863. $this->subGenerateMath();
  864. break;
  865. case "math":
  866. $this->subGenerateMath();
  867. break;
  868. case "math":
  869. $this->subGenerateMath();
  870. break;
  871. case "math":
  872. $this->subGenerateMath();
  873. break;
  874. case "math":
  875. $this->subGenerateMath();
  876. break;
  877. case "math":
  878. $this->subGenerateMath();
  879. break;
  880. case "math":
  881. $this->subGenerateMath();
  882. break;
  883. }
  884. // 'english' => 0,
  885. // 'pePd' => 0, //health-and-physical-education
  886. // 'socialStudies' => 0, //humanities-and-social-sciences
  887. // 'languages' => 0,
  888. // 'science' => 0,
  889. // 'technologies' => 0,
  890. // 'art' => 0,
  891. // Debug line TODO remove once tested.
  892. print_a(['subject' => $this->subject, 'difficulty' => $this->difficulty]);
  893. }
  894. ////////////////////////////////////////////////////////////////////////////
  895. /// Sub generate functions for minor subjects
  896. ////////////////////////////////////////////////////////////////////////////
  897. //
  898. private function subGenerateMath() {
  899. switch ($this->subject) {
  900. case $value:
  901. break;
  902. default:
  903. break;
  904. }
  905. print_a(['subject' => $this->subject, 'difficulty' => $this->difficulty]);
  906. }
  907. ////////////////////////////////////////////////////////////////////////////
  908. /// Raw question fetchers
  909. ////////////////////////////////////////////////////////////////////////////
  910. // Fetch and return question from DB questions
  911. private function generalKnowledge() {
  912. //array_rand($array);
  913. }
  914. //english (spelling)
  915. //english (syntax)
  916. //english (comprehention)
  917. private function math() {
  918. }
  919. private function mathGeneral() {
  920. }
  921. private function mathUnits() {
  922. }
  923. //science
  924. //technolegy
  925. //geography
  926. //
  927. }