| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of subjects
- *
- * @author gregory
- */
- class subjects {
- public $state = "error";
- private $debug = false;
- private $major;
- private $minor;
- private $returnQuestionData = [];
- /**
- * Setup new question engine
- *
- * @param integer $major Max subject limit or debug selection.
- * @param integer $minor Max sub subject limit or debug selection.
- * @param bool $test Enable debug mode.
- */
- public function __construct($major, $minor, $test = false) {
- // some minor protection for this class
- if (!is_numeric($major) || !is_numeric($minor)) {
- $this->state = "error, Incorrect init values.";
- return;
- }
- // set diagnostics flag or init values.
- if ($test) {
- $this->debug = true;
- $this->major = $major;
- $this->minor = $minor;
- } else {
- $this->major = mt_rand(0, $major);
- $this->minor = mt_rand(0, $this->subjectLimiter($this->major, $minor));
- }
- $this->state = "ready";
- //print_a(['thisMa'=>$this->major,'thisMi'=>$this->minor,'Ma'=>$major,'Mi'=>$minor,'limitMi'=> $this->subjectLimiter($major, $minor)]);
- }
- /**
- * Return question data for the template engine.
- *
- * @return string Question ready to be passed to the template engine.
- */
- public function getQuestion() {
- // return the error message if the engine is not ready
- if (!$this->state == "ready") {
- return $this->state;
- }
- // debug output
- if ($this->debug) {
- $this->returnQuestionData['DebugSubjects'] = [];
- $this->returnQuestionData['DebugSubjects']['majorSubject'] = $this->major;
- $this->returnQuestionData['DebugSubjects']['minorSubject'] = $this->minor;
- }
- $this->selectSubject();
- return $this->returnQuestionData;
- }
- private function selectSubject() {
- switch ($this->major) {
- case 0: // Math
- $this->selectMinorMath();
- break;
- case 1: // English
- $this->selectMinorEnglish();
- break;
- case 2: // Science
- $this->selectMinorScience();
- break;
- case 3: // Geography
- $this->a(3);
- case 4: // History
- $this->a(4);
- case 5: // Art
- $this->a(5);
- case 6: // Technology
- $this->a(6);
- case 7: // language
- $this->a(7);
- case 8: // Health - Health and Physical Education
- $this->a(8);
- }
- }
-
- private function a($int)
- {
- print_a("Case $int not implemented yet!");
- }
- private function subjectLimiter($majorSubject,$requestedMinor) {
- $limits = [
- '0'=>2,// Math
- '1'=>0,// English
- '2'=>0,// Science
- '3'=>0,// Geography
- '4'=>0,// History
- '5'=>0,// Art
- '6'=>0,// Technology
- '7'=>0,// language
- '8'=>0,// Health
- ];
-
- if($limits[$majorSubject]<=$requestedMinor) {
- return $limits[$majorSubject];
- }else{
- return $requestedMinor;
- }
- }
- private function selectMinorMath() {
- switch ($this->minor) {
- case 0: // Numbers
- include 'questionGenerators/math/numbers.php';
- $mathNum = new numbers($this->debug);
- $this->returnQuestionData['numbers'] = $mathNum->getNumbers();
- break;
- case 1: // Numeracy
- include 'questionGenerators/math/numeracy.php';
- $mathNum = new numeracy($this->debug);
- $this->returnQuestionData['numeracy'] = $mathNum->getNumeracy();
- break;
- case 2: // Math_word_Problems
- include 'questionGenerators/math/math_word_problems.php';
- $mathNum = new math_word_problems($this->debug);
- $this->returnQuestionData['math_word_problems'] = $mathNum->getProblem();
- break;
- case 3: // money////////////////////////////////////////////////////
- include 'questionGenerators/math/numeracy.php';
- $mathNum = new numeracy($this->debug);
- $this->returnQuestionData['numeracy'] = $mathNum->getNumeracy();
- break;
- case 4: // time/////////////////////////////////////////////////////
- include 'questionGenerators/math/numeracy.php';
- $mathNum = new numeracy($this->debug);
- $this->returnQuestionData['numeracy'] = $mathNum->getNumeracy();
- break;
- case 5: // geometry////////////////////////////////////////////////
- include 'questionGenerators/math/numeracy.php';
- $mathNum = new numeracy($this->debug);
- $this->returnQuestionData['numeracy'] = $mathNum->getNumeracy();
- break;
-
- }
- }
- private function selectMinorEnglish() {
- switch ($this->minor) {
- case 0: // spelling
- include 'questionGenerators/english/spelling.php';
- $engSpell = new spelling($this->debug);
- $this->returnQuestionData['spelling'] = $engSpell->getSpellingWord("");
- break;
- case 1: // English
- //$this->selectMinorEnglish();
- break;
- }
- }
- private function selectMinorScience() {
- switch ($this->minor) {
- case 0: // Periodic Table of Elements
- include 'questionGenerators/science/elements.php';
- $scienceElements = new elements($this->debug);
- $this->returnQuestionData['elements'] = $scienceElements->getElements();
- break;
- case 1: // English
- //$this->selectMinorEnglish();
- break;
- }
- }
- }
-
- ////////////////////////
- // Worded questions
- ///////////////////////
-
- $geometry = [
- 'The perimeter of a square is 48 cm. What is the area of 2 such squares?',
- 'The area of 2 squares is 32 cm². What is the area of 3 such squares?',
- 'The perimeter of a rectangle is 24 cm. If the length is 9 cm, what is the width?',
- 'The perimeter of a rectangle is 52 cm. If the length is 15 cm, what is the width?',
- 'The width of a rectangle is 5 cm and the length is twice the width. What is the area of 10 such rectangles?',
- 'The area of square A is 49 cm². The area of square B is 144 cm². What is the difference in the perimeters of both squares?',
- 'The area of a square is 64 cm². What is the perimeter of 5 such squares?',
- 'The length of a rectangle is 11 cm. The perimeter of the rectangle is 34 cm. What is the width of the rectangle?',
- 'A square room has a side measurement of 16 m. Find the area of carpet needed to cover half the room?',
- 'An area of a square room is 400 m². A rectangle carpet measures 18 m by 10 m. Find the area of the room not covered in carpet?',
- 'A side of a square is 16 cm. What is the area of 5 similar squares?',
- 'The area of 2 similar squares is 128 cm². What is the side of each square?',
- 'The perimeter of a rectangle is 42 cm. The length is twice as long as the width. What is the width of the rectangle?',
- 'The perimeter of square A is 40 cm. The perimeter of square B is double of square A. What is 1 side of square B?',
- 'In a picture there are 4 squares drawn next to each other. How many right angles can you find?',
- 'The area of a room is 500m². A rug has an area of 5m². How many rugs are needed to cover half the floor of the room?',
- 'The perimeter of carpet A is 18m. The area of carpet B is twice the perimeter of carpet A. Find out what each side of carpet B measures?',
- 'The perimeter of a rectangle is 44 cm. The width of the rectangle is 9 cm. What is the length?',
- 'The perimeter of square A is 48 cm. The perimeter of square B is half of square A. What is the area of square B?',
- 'The combined height of 2 buildings is 390m. The height of building A is twice the height of building B. What are the heights of Building A? Building B?'
- ];
-
- $money = [
- 'Elliot has $27.10 and Silas has three times more than Elliot. How much money do they have altogether?',
- 'A coffee costs $2.50. Greg spent $17.50. How many coffees did he buy?',
- '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?',
- 'Wayne has $54. He bought 3 books that cost $16 each. How much money does he have left?',
- 'Sammy has $31, Ella has $18 more than Sammy and Molly has $20 more than Ella. How much does Molly have?',
- '1 meter of cloth costs $7. How much would six and a half meters of cloth cost?',
- '12 eggs cost $6. How much would 18 eggs cost?',
- 'Bekka had $250 and she spent a quarter of her money. How much does she have left?',
- 'Kelly has $170. Kate has twice the amount of Kelly. Kitty has $65 more than Kate. How much does Kitty have?',
- '1 meter of rope costs $21. Rope fence A uses 15 meters. Rope fence B uses four times more rope than fence A. How much did fence B cost to make?',
- 'Francis has $55 and his brother has 1 fifth less than him. How much do they have in total?',
- 'A sandwich costs $2.20. Silas has $18. How many sandwiches can he buy? How much change will he have left?',
- 'Louis had $96. He spent $24.50 on Tuesday and $39.70 on Wednesday. How much does he have left?',
- 'Farmer Ben had 320 pigs. 1 eighth of the pigs were eaten by wolves. He sold the remaining pigs at $90 each. How much money did he make?',
- '100 grams of flour costs 50 cents. How much does 3 kilos of flour cost?',
- 'A cupcake costs $1.50. Mei Lee made $60. How many cupcakes did she sell?',
- 'A toy costs $39.50. David and Dylan split the cost evenly between them. How much did each person pay for the toy?',
- '3 girls bought a pizza for $40. Girl A paid double than what Girl B paid. Girl C paid $10. How much did Girl A pay?',
- 'Greg bought a pie for $4.90, 2 milkshakes for $6 each and had $2.30 left. How much did he have at first?',
- 'Greg used 5000 cm of rope to make a fence. 1 meter of rope costs $3. How much did Greg spend on his rope fence?',
- 'A taxi meter starts at $4. Every 30 seconds, the meter jumps by 10 cents. How much would the meter show if a passenger sat in the taxi for 4 minutes?',
- '$210.60 has to shared equally between 3 sisters. How much would each sister get?',
- 'A meter of steel costs $7.40. Randy spent $44.40 How many meters did he buy?',
- 'Farmer Tim sold each 42 pigs at $70 each. He donated half the money to charity and kept the rest. How much did he keep?',
- ];
-
- $time = [
- 'Rowan’s swim class started at 10.55 am. It went for 2 hours and 10 minutes. What time did it end?',
- 'David starts work at 7.45 am. He works for 9 hours and 5 minutes. What time did he finish work?',
- 'David starts work at 8.50 am. He works for 9 hours and 30 minutes. What time did he finish work?',
- 'Hank takes 4 minutes to cycle to Coles. In total he cycled for 1 hour. How many trips to Coles did he make?',
- 'Finn earns $50 a week. How much does he earn in 1 year?',
- 'Adam started work at 8.45 am. He worked for nine and a half hours. What time did he finish work?',
- 'Rita takes 12 seconds to make a paper boat. How many boats can she make in 6 minutes?',
- 'Silas can do 3 twirls in every 20 seconds. How many twirls can he do in 5 minutes?',
- 'The restaurant opened at 12.45 pm. Elliot was 35 minutes late for work. What time did Elliot arrive at the restaurant?',
- 'Ruby went in for an operation at 4.25 pm. Her operation ended at 6.05 pm. How long was the operation?',
- ];
-
-
|