| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?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.
- */
- print_a(['Development area'=>'head var','session'=>$_SESSION]);
- $query = "SELECT (SUM(correct)/COUNT(correct)*100) as percent
- FROM e107.`e107_tkReport` WHERE
- answereddatestamp >= unix_timestamp((NOW()) - INTERVAL 1 MONTH)
- AND username = 'elliot' AND subject = 'numeracy';";
- e107::getDb()->gen($query);
- while ($row = e107::getDb()->fetch()) {
- print_a(['elliesNumeracy'=>$row]);
- }
- print_a($tp->toHtml('Don't be silly while you are studying.'));
- $debugQ = true;
- if($debugQ) {
- // Instanciate the new question engine with debug settings.
- // 0 = Math
- // 1 = English
- // 2 = Science
- $newQuestions = new Subjects(2, 0, $debugQ);
- // get array of data for question
- $rawQuestion = $newQuestions->getQuestion();
- if ($debugQ) {
- print_a([__FILE__=>$rawQuestion]);
- }
- include('forms.php');
- $template = new forms($rawQuestion);
- $tmpdata = $template->templater();
- if ($debugQ) {
- print_a([__FILE__=>$tmpdata]);
- }
- // Get question from engine
- $ns->tablerender("Question", $tmpdata);
- }
- //$QE = new Question_Engine_2($subject, $year);
- //$QE->generate();
- ////print_a($content);
- //$text2 .= $content; //$this->renderQuestion($frm, $content);
- //$ns->tablerender("Question(Do not use)", 'exec done.'.'<br/>');
- // Template test
- //$template = e107::getTemplate('timekeeper'); // loads e107_plugins/timekeeper/templates/timekeeper_template.php
- //print_a(['templete='=>$template]);
- //$ret = $tp->parseTemplate($template['testen'], false, ['VALUE1'=>'12','VALU'=>'13']);
- // end test
- //
- $ns->tablerender("Fraction Test", '1<sup>1</sup>⁄<sub>2</sub><br/>');
- $TA = new testQuestions();
- $ns->tablerender("TestQuestion", $TA->testQuestion());
- print_a(['testloc'=>'here']);
- //TODO teachers section
- if (isset($_GET["setTimekeeper"])) {
-
- $ns->tablerender("Generate Questions Sheet", $text);
- $text = e107::getForm()->open('TimekeeperControl', 'POST', '', ['autocomplete' => 'off', 'class' => 'formclass']);
- $text .= e107::getForm()->userlist('user');
- $text .= '</br>';
- $text .= '</br>';
- $text .= e107::getForm()->flipswitch('timekeeperState', 'on', ['on' => 'Enabled', 'off' => 'Disabled']);
- $text .= e107::getForm()->label(' Timekeeper State');
- $text .= '</br>';
- $text .= '</br>';
- $text .= e107::getForm()->label('<b>Free minutes of play time a day.</b>');
- $text .= '</br>';
- $text .= e107::getForm()->number('freeMinutes', 30, 2, ['min' => 0, 'max' => 120]);
- $text .= '</br>';
- $text .= '</br>';
- $text .= e107::getForm()->label('<b>Minimum Questions required to enable play time each day.</b>');
- $text .= '</br>';
- $text .= e107::getForm()->number('MinQuestions', 0, 2, ['min' => 0, 'max' => 500]);
- $text .= '</br>';
- $text .= '</br>';
- $text .= e107::getForm()->label('Start of playtime each day');
- $text .= '</br>';
- $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]);
- $text .= '</br>';
- $text .= '</br>';
- $text .= e107::getForm()->label('End of playtime each day');
- $text .= '</br>';
- $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]);
- $text .= '</br>';
- $text .= '</br>';
- $text .= '<button type="submit" name="setTimekeeper" value="Set Timekeeper" id="setTimekeeper" class="btn submit btn-success"><span>Set Timekeeper</span></button>';
- $text .= e107::getForm()->close();
- $ns->tablerender("Timekeeper Control (Not finished)", $text);
- if (isset($_POST["setTimekeeper"])) {
- print_a($_POST);
- }
- }
- class testQuestions {
- private $FormattedQuestionForm = "";
- private $diff = 20;
- function testQuestion() {
- $this->FormattedQuestionForm = e107::getForm()->open('questionForm', 'post', '', ['autocomplete' => 'off', 'class' => 'formclass']) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('yearLevel', 1) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('subject', 'Fractions') . "\n";
- $this->FormattedQuestionForm .= $this->elements();
- $this->FormattedQuestionForm .= '</br>';
- $this->FormattedQuestionForm .= e107::getForm()->button('Answered', 'Check answer') . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->close();
- $this->FormattedQuestionForm .= '</br>';
- return $this->FormattedQuestionForm;
- }
- private function Fractions() {// needs to be multi part question
- require_once( __DIR__ . '/fraction/src/Fraction.php');
- $this->FormattedQuestionForm .= e107::getForm()->label('<b>Fractions, reduce to its simplest form to find the answers. (Answer as mixed fraction where possible.)</b>') . "\n";
- $this->FormattedQuestionForm .= '</br>';
- $multiplier = rand(1, (int) ($this->diff / 4));
- $nominator = rand(1, (int) ($this->diff / 4));
- $denominator = rand(1, (int) ($this->diff / 4));
- $fract1 = new Fraction($nominator * $multiplier, $denominator * $multiplier);
- $fract2 = new Fraction(rand(1, (int) ($this->diff / 4)) * rand(1, (int) ($this->diff / 4)), $denominator * $multiplier);
- if ($fract1->toFloat() >> $fract2->toFloat()) {
- $fract3 = 1;
- } else {
- $fract3 = 0;
- }
- print_a(['fraction1' => $fract1->toFloat(), 'fraction2' => $fract2->toFloat(), 'fract1Greater' => (string) $fract3,]); // 1/2
- $this->FormattedQuestionForm .= e107::getForm()->label($nominator * $multiplier) . "<br/>\n";
- $this->FormattedQuestionForm .= "-------<br/>\n";
- $this->FormattedQuestionForm .= e107::getForm()->label($denominator * $multiplier) . "\n";
- $this->FormattedQuestionForm .= '</br></br>';
- $this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
- $this->FormattedQuestionForm .= "-------<br/>\n";
- $this->FormattedQuestionForm .= e107::getForm()->text('q2', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($fract1->getNumerator())) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('a2', (int) ($fract1->getDenominator())) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 2) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Simplify " . $nominator * $multiplier . " over " . $denominator * $multiplier) . "\n";
- }
- private function elements() {// needs to be multi part question
-
- $elements = json_decode(file_get_contents('resources/periodicTable.json'), true);
-
- $tp = e107::getParser();
- $sc = e107::getScBatch('timekeeper', TRUE);
- $sc->setVars($elements['elements'][118]);
-
-
- $this->FormattedQuestionForm .= e107::getForm()->label('<b>Science, Periodic Table of Elements. Fill in the missing information.</b>') . "\n";
- $this->FormattedQuestionForm .= '</br></br>';
- $this->FormattedQuestionForm .= $tp->parseTemplate(file_get_contents('templates/elementTable.html'), true, $sc);
-
- $this->FormattedQuestionForm .= '</br>';
-
- $multiplier = rand(1, (int) ($this->diff / 4));
- $nominator = rand(1, (int) ($this->diff / 4));
- $denominator = rand(1, (int) ($this->diff / 4));
- //print_a(['nominator'=>$nominator , 'multiplier'=>$multiplier, 'denominator'=>$denominator,'cal1'=>$nominator * $multiplier,'cal2'=>$denominator * $multiplier]);
-
- //$fract1 = new Fraction($nominator * $multiplier, $denominator * $multiplier);
- //$fract2 = new Fraction(rand(1, (int) ($this->diff / 4)) * rand(1, (int) ($this->diff / 4)), $denominator * $multiplier);
- //if ($fract1->toFloat() >> $fract2->toFloat()) {
- // $fract3 = 1;
- //} else {
- // $fract3 = 0;
- //}
- //print_a(['fraction1' => $fract1->toFloat(), 'fraction2' => $fract2->toFloat(), 'fract1Greater' => (string) $fract3,]); // 1/2
- //$this->FormattedQuestionForm .= e107::getForm()->label($nominator * $multiplier) . "<br/>\n";
- //$this->FormattedQuestionForm .= "-------<br/>\n";
- //$this->FormattedQuestionForm .= e107::getForm()->label($denominator * $multiplier) . "\n";
- //$this->FormattedQuestionForm .= '</br></br>';
- //$this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
- //$this->FormattedQuestionForm .= "-------<br/>\n";
- //$this->FormattedQuestionForm .= e107::getForm()->text('q2', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
- //$this->FormattedQuestionForm .= e107::getForm()->hidden('a1', (int) ($fract1->getNumerator())) . "\n";
- //$this->FormattedQuestionForm .= e107::getForm()->hidden('a2', (int) ($fract1->getDenominator())) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('qc1', 2) . "\n";
- $this->FormattedQuestionForm .= e107::getForm()->hidden('question', "Simplify " . $nominator * $multiplier . " over " . $denominator * $multiplier) . "\n";
- }
- }
- /**
- * Substitutor class
- * Convert a question as text with sort codes to text
- */
- class substitutor {
-
- private $questionData;
- private $returnQuestion;
- /**
- * __construct()
- * @param String $question Question data to check and replace short codes in.
- */
- public function __construct($question) {
- $this->questionData = $question;
- }
-
- public function replaceCodes() {
-
-
- return $this->returnQuestion;
- }
-
- }
|