DevelopmentArea.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. print_a(['Development area'=>'head var','session'=>$_SESSION]);
  8. $query = "SELECT (SUM(correct)/COUNT(correct)*100) as percent
  9. FROM e107.`e107_tkReport` WHERE
  10. answereddatestamp >= unix_timestamp((NOW()) - INTERVAL 1 MONTH)
  11. AND username = 'elliot' AND subject = 'numeracy';";
  12. e107::getDb()->gen($query);
  13. while ($row = e107::getDb()->fetch()) {
  14. print_a(['elliesNumeracy'=>$row]);
  15. }
  16. print_a($tp->toHtml('Don&#039;t be silly while you are studying.'));
  17. $debugQ = true;
  18. if($debugQ) {
  19. // Instanciate the new question engine with debug settings.
  20. // 0 = Math
  21. // 1 = English
  22. // 2 = Science
  23. $newQuestions = new Subjects(2, 0, $debugQ);
  24. // get array of data for question
  25. $rawQuestion = $newQuestions->getQuestion();
  26. if ($debugQ) {
  27. print_a([__FILE__=>$rawQuestion]);
  28. }
  29. include('forms.php');
  30. $template = new forms($rawQuestion);
  31. $tmpdata = $template->templater();
  32. if ($debugQ) {
  33. print_a([__FILE__=>$tmpdata]);
  34. }
  35. // Get question from engine
  36. $ns->tablerender("Question", $tmpdata);
  37. }
  38. //$QE = new Question_Engine_2($subject, $year);
  39. //$QE->generate();
  40. ////print_a($content);
  41. //$text2 .= $content; //$this->renderQuestion($frm, $content);
  42. //$ns->tablerender("Question(Do not use)", 'exec done.'.'<br/>');
  43. // Template test
  44. //$template = e107::getTemplate('timekeeper'); // loads e107_plugins/timekeeper/templates/timekeeper_template.php
  45. //print_a(['templete='=>$template]);
  46. //$ret = $tp->parseTemplate($template['testen'], false, ['VALUE1'=>'12','VALU'=>'13']);
  47. // end test
  48. //
  49. $ns->tablerender("Fraction Test", '1<sup>1</sup>&frasl;<sub>2</sub><br/>');
  50. $TA = new testQuestions();
  51. $ns->tablerender("TestQuestion", $TA->testQuestion());
  52. print_a(['testloc'=>'here']);
  53. //TODO teachers section
  54. if (isset($_GET["setTimekeeper"])) {
  55. $ns->tablerender("Generate Questions Sheet", $text);
  56. $text = e107::getForm()->open('TimekeeperControl', 'POST', '', ['autocomplete' => 'off', 'class' => 'formclass']);
  57. $text .= e107::getForm()->userlist('user');
  58. $text .= '</br>';
  59. $text .= '</br>';
  60. $text .= e107::getForm()->flipswitch('timekeeperState', 'on', ['on' => 'Enabled', 'off' => 'Disabled']);
  61. $text .= e107::getForm()->label('&nbsp;&nbsp;&nbsp;&nbsp;Timekeeper State');
  62. $text .= '</br>';
  63. $text .= '</br>';
  64. $text .= e107::getForm()->label('<b>Free minutes of play time a day.</b>');
  65. $text .= '</br>';
  66. $text .= e107::getForm()->number('freeMinutes', 30, 2, ['min' => 0, 'max' => 120]);
  67. $text .= '</br>';
  68. $text .= '</br>';
  69. $text .= e107::getForm()->label('<b>Minimum Questions required to enable play time each day.</b>');
  70. $text .= '</br>';
  71. $text .= e107::getForm()->number('MinQuestions', 0, 2, ['min' => 0, 'max' => 500]);
  72. $text .= '</br>';
  73. $text .= '</br>';
  74. $text .= e107::getForm()->label('Start of playtime each day');
  75. $text .= '</br>';
  76. $text .= '<input name="playtimeStart" type=time min="00:00" max="23:45" step="15" value="00:00">'; //e107::getForm()->number('Start', 10, 2,['min'=>0,'max'=>23]);
  77. $text .= '</br>';
  78. $text .= '</br>';
  79. $text .= e107::getForm()->label('End of playtime each day');
  80. $text .= '</br>';
  81. $text .= '<input name="playtimeStop" id="playtimeStop" type=time min="00:00" max="23:45" step="15" value="00:00">'; //e107::getForm()->number('End', 22, 2,['min'=>0,'max'=>23]);
  82. $text .= '</br>';
  83. $text .= '</br>';
  84. $text .= '<button type="submit" name="setTimekeeper" value="Set Timekeeper" id="setTimekeeper" class="btn submit btn-success"><span>Set Timekeeper</span></button>';
  85. $text .= e107::getForm()->close();
  86. $ns->tablerender("Timekeeper Control (Not finished)", $text);
  87. if (isset($_POST["setTimekeeper"])) {
  88. print_a($_POST);
  89. }
  90. }
  91. class testQuestions {
  92. private $FormattedQuestionForm = "";
  93. private $diff = 20;
  94. function testQuestion() {
  95. $this->FormattedQuestionForm = e107::getForm()->open('questionForm', 'post', '', ['autocomplete' => 'off', 'class' => 'formclass']) . "\n";
  96. $this->FormattedQuestionForm .= e107::getForm()->hidden('yearLevel', 1) . "\n";
  97. $this->FormattedQuestionForm .= e107::getForm()->hidden('subject', 'Fractions') . "\n";
  98. $this->FormattedQuestionForm .= $this->elements();
  99. $this->FormattedQuestionForm .= '</br>';
  100. $this->FormattedQuestionForm .= e107::getForm()->button('Answered', 'Check answer') . "\n";
  101. $this->FormattedQuestionForm .= e107::getForm()->close();
  102. $this->FormattedQuestionForm .= '</br>';
  103. return $this->FormattedQuestionForm;
  104. }
  105. private function Fractions() {// needs to be multi part question
  106. require_once( __DIR__ . '/fraction/src/Fraction.php');
  107. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Fractions, reduce to its simplest form to find the answers. (Answer as mixed fraction where possible.)</b>') . "\n";
  108. $this->FormattedQuestionForm .= '</br>';
  109. $multiplier = rand(1, (int) ($this->diff / 4));
  110. $nominator = rand(1, (int) ($this->diff / 4));
  111. $denominator = rand(1, (int) ($this->diff / 4));
  112. $fract1 = new Fraction($nominator * $multiplier, $denominator * $multiplier);
  113. $fract2 = new Fraction(rand(1, (int) ($this->diff / 4)) * rand(1, (int) ($this->diff / 4)), $denominator * $multiplier);
  114. if ($fract1->toFloat() >> $fract2->toFloat()) {
  115. $fract3 = 1;
  116. } else {
  117. $fract3 = 0;
  118. }
  119. print_a(['fraction1' => $fract1->toFloat(), 'fraction2' => $fract2->toFloat(), 'fract1Greater' => (string) $fract3,]); // 1/2
  120. $this->FormattedQuestionForm .= e107::getForm()->label($nominator * $multiplier) . "<br/>\n";
  121. $this->FormattedQuestionForm .= "-------<br/>\n";
  122. $this->FormattedQuestionForm .= e107::getForm()->label($denominator * $multiplier) . "\n";
  123. $this->FormattedQuestionForm .= '</br></br>';
  124. $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  125. $this->FormattedQuestionForm .= "-------<br/>\n";
  126. $this->FormattedQuestionForm .= e107::getForm()->text('q2', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  127. $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($fract1->getNumerator())) . "\n";
  128. $this->FormattedQuestionForm .= e107::getForm()->hidden('a2', (int) ($fract1->getDenominator())) . "\n";
  129. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 2) . "\n";
  130. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Simplify " . $nominator * $multiplier . " over " . $denominator * $multiplier) . "\n";
  131. }
  132. private function elements() {// needs to be multi part question
  133. $elements = json_decode(file_get_contents('resources/periodicTable.json'), true);
  134. $tp = e107::getParser();
  135. $sc = e107::getScBatch('timekeeper', TRUE);
  136. $sc->setVars($elements['elements'][118]);
  137. $this->FormattedQuestionForm .= e107::getForm()->label('<b>Science, Periodic Table of Elements. Fill in the missing information.</b>') . "\n";
  138. $this->FormattedQuestionForm .= '</br></br>';
  139. $this->FormattedQuestionForm .= $tp->parseTemplate(file_get_contents('templates/elementTable.html'), true, $sc);
  140. $this->FormattedQuestionForm .= '</br>';
  141. $multiplier = rand(1, (int) ($this->diff / 4));
  142. $nominator = rand(1, (int) ($this->diff / 4));
  143. $denominator = rand(1, (int) ($this->diff / 4));
  144. //print_a(['nominator'=>$nominator , 'multiplier'=>$multiplier, 'denominator'=>$denominator,'cal1'=>$nominator * $multiplier,'cal2'=>$denominator * $multiplier]);
  145. //$fract1 = new Fraction($nominator * $multiplier, $denominator * $multiplier);
  146. //$fract2 = new Fraction(rand(1, (int) ($this->diff / 4)) * rand(1, (int) ($this->diff / 4)), $denominator * $multiplier);
  147. //if ($fract1->toFloat() >> $fract2->toFloat()) {
  148. // $fract3 = 1;
  149. //} else {
  150. // $fract3 = 0;
  151. //}
  152. //print_a(['fraction1' => $fract1->toFloat(), 'fraction2' => $fract2->toFloat(), 'fract1Greater' => (string) $fract3,]); // 1/2
  153. //$this->FormattedQuestionForm .= e107::getForm()->label($nominator * $multiplier) . "<br/>\n";
  154. //$this->FormattedQuestionForm .= "-------<br/>\n";
  155. //$this->FormattedQuestionForm .= e107::getForm()->label($denominator * $multiplier) . "\n";
  156. //$this->FormattedQuestionForm .= '</br></br>';
  157. //$this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  158. //$this->FormattedQuestionForm .= "-------<br/>\n";
  159. //$this->FormattedQuestionForm .= e107::getForm()->text('q2', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
  160. //$this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($fract1->getNumerator())) . "\n";
  161. //$this->FormattedQuestionForm .= e107::getForm()->hidden('a2', (int) ($fract1->getDenominator())) . "\n";
  162. $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 2) . "\n";
  163. $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Simplify " . $nominator * $multiplier . " over " . $denominator * $multiplier) . "\n";
  164. }
  165. }
  166. /**
  167. * Substitutor class
  168. * Convert a question as text with sort codes to text
  169. */
  170. class substitutor {
  171. private $questionData;
  172. private $returnQuestion;
  173. /**
  174. * __construct()
  175. * @param String $question Question data to check and replace short codes in.
  176. */
  177. public function __construct($question) {
  178. $this->questionData = $question;
  179. }
  180. public function replaceCodes() {
  181. return $this->returnQuestion;
  182. }
  183. }