function getVariablesUpdate($sVar) { $sVar->action = $_POST['myAction']; return $sVar; } function checkVariables() { if (strlen($_POST['myName']) < 6 && strlen($_POST['myRepeat']) < 6 && (strlen($_POST['startDate']) == 10 || strlen($_POST['startDate']) == 0) && (strlen($_POST['startTime']) == 5 || strlen($_POST['startTime']) == 0) && strlen($_POST['Duration']) < 4 && strlen($_POST['myAction']) < 30 && strlen($_POST['Command']) < 7 && strlen($_POST['id']) < 6) { return 34566543; } return 1; } $sVar = array('Command' => NULL, 'id' => NULL, 'name' => NULL, 'toRepeat' => NULL, 'startTime' => NULL, 'endTime' => NULL, 'action' => NULL); addHeader(); $conn = startConnection(); if (checkVariables() != 34566543) { die('Variables Problem'); } $sVar = new StdClass(); $sVar->Command = $_POST['Command']; if ($sVar->Command != NULL) { if (sha1($_POST['psswd']) == PWD_SHA) { if ($sVar->Command == 'Add') { $sVar = getVariablesAdd($sVar); if (!addQuerySelect($conn, $sVar)) { die("add Problem"); } } elseif ($sVar->Command == 'Erase') { $sVar = getVariablesErase($sVar); if (!EraseQuery($conn, $sVar->id)) { die("Erase Problem");
function SaveCalculation(&$question) { // TODO : NO template // format the text for the question foreach ($question->variables as $var => $vairable) { ${$var} = MathsUtils::gen_random_no(checkVariables($vairable->min), checkVariables($vairable->max), $vairable->inc, $vairable->dec); } eval("\$answer = " . $question->formula . ";"); $q_text = $question->leadin; $q_text = str_ireplace("\$A", $A, $q_text); $q_text = str_ireplace("\$B", $B, $q_text); $q_text = str_ireplace("\$C", $C, $q_text); $q_text = str_ireplace("\$D", $D, $q_text); $q_text = str_ireplace("\$E", $E, $q_text); $q_text = str_ireplace("\$F", $F, $q_text); $q_text = str_ireplace("\$G", $G, $q_text); $q_text = str_ireplace("\$H", $H, $q_text); //echo $q_text."<BR>"; $question->leadin = $q_text; $headertext = $this->MakeQuestionHeader($question); $title = StripForTitle($question->leadin); $ob = new OB(); $ob->ClearAndSave(); include "qti20/tmpl/calculation.php"; $this->output .= $ob->GetContent(); $ob->Restore(); }
/** * Save 'calculation' question type to QTI XML * @param ST_Question_Calculation $question Reference to the question object * @author Adam Clarke, Rob Ingram */ function SaveCalculation(&$question) { if ($question->q_type == 'enhancedcalc') { $this->SaveEnhancedCalc($question); return; } $question->formula = trim($question->formula); if (substr($question->formula, 0, 1) == "=") { $question->formula = substr($question->formula, 1); } $question->origleadin = $question->leadin; $q_text = $question->leadin; // format the text for the question // replace all variables in leadin with randomly generated values foreach ($question->variables as $var => $vairable) { ${$var} = MathsUtils::gen_random_no(checkVariables($vairable->min), checkVariables($vairable->max), $vairable->inc, $vairable->dec); $q_text = str_ireplace("\${$var}", ${$var}, $q_text); } eval("\$answer = " . $question->formula . ";"); //echo $q_text."<BR>"; $question->leadin = $q_text; list($headertext, $title) = $this->MakeQuestionHeader($question); $type = "Calculation"; $ob = new OB(); $ob->ClearAndSave(); include "qti12/tmpl/calculation.php"; $this->output .= $ob->GetContent(); $ob->Restore(); }