'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.'.'
');
// 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", '11⁄2
');
$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 .= '';
$text .= '';
$text .= e107::getForm()->flipswitch('timekeeperState', 'on', ['on' => 'Enabled', 'off' => 'Disabled']);
$text .= e107::getForm()->label(' Timekeeper State');
$text .= '';
$text .= '';
$text .= e107::getForm()->label('Free minutes of play time a day.');
$text .= '';
$text .= e107::getForm()->number('freeMinutes', 30, 2, ['min' => 0, 'max' => 120]);
$text .= '';
$text .= '';
$text .= e107::getForm()->label('Minimum Questions required to enable play time each day.');
$text .= '';
$text .= e107::getForm()->number('MinQuestions', 0, 2, ['min' => 0, 'max' => 500]);
$text .= '';
$text .= '';
$text .= e107::getForm()->label('Start of playtime each day');
$text .= '';
$text .= ''; //e107::getForm()->number('Start', 10, 2,['min'=>0,'max'=>23]);
$text .= '';
$text .= '';
$text .= e107::getForm()->label('End of playtime each day');
$text .= '';
$text .= ''; //e107::getForm()->number('End', 22, 2,['min'=>0,'max'=>23]);
$text .= '';
$text .= '';
$text .= '';
$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 .= '';
$this->FormattedQuestionForm .= e107::getForm()->button('Answered', 'Check answer') . "\n";
$this->FormattedQuestionForm .= e107::getForm()->close();
$this->FormattedQuestionForm .= '';
return $this->FormattedQuestionForm;
}
private function Fractions() {// needs to be multi part question
require_once( __DIR__ . '/fraction/src/Fraction.php');
$this->FormattedQuestionForm .= e107::getForm()->label('Fractions, reduce to its simplest form to find the answers. (Answer as mixed fraction where possible.)') . "\n";
$this->FormattedQuestionForm .= '';
$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) . "
\n";
$this->FormattedQuestionForm .= "-------
\n";
$this->FormattedQuestionForm .= e107::getForm()->label($denominator * $multiplier) . "\n";
$this->FormattedQuestionForm .= '';
$this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
$this->FormattedQuestionForm .= "-------
\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('Science, Periodic Table of Elements. Fill in the missing information.') . "\n";
$this->FormattedQuestionForm .= '';
$this->FormattedQuestionForm .= $tp->parseTemplate(file_get_contents('templates/elementTable.html'), true, $sc);
$this->FormattedQuestionForm .= '';
$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) . "
\n";
//$this->FormattedQuestionForm .= "-------
\n";
//$this->FormattedQuestionForm .= e107::getForm()->label($denominator * $multiplier) . "\n";
//$this->FormattedQuestionForm .= '';
//$this->FormattedQuestionForm .= e107::getForm()->text('q1', '', 80, ['placeholder' => 'Write answer here!', 'autocomplete' => "off"]) . "\n";
//$this->FormattedQuestionForm .= "-------
\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;
}
}