示例#1
0
 public function makeNewQuestion($userId, $problemId)
 {
     $db = QuestionDbWriter::getInstance();
     $dataDef = $db->getDefinitionFromDb($problemId);
     $questionAssembler = new QuestionAssembler();
     $questionAssembler->build($dataDef);
     $question = $questionAssembler->getTestQuestion();
     $question->handle = $userId;
     $db->storeTestQuestion($question);
     return $question;
 }
示例#2
0
$template->build($defn);
$soln = $template->getTestQuestion();
print $soln->question . "<br>";
print $soln->answer . "<br>";
print $soln->solve("3/2");
print "<br><br>";
$questionStr = "%ax + %by = %c<br>%dx + %ey = %f";
$answerStr = "x=%x, y=%y";
$dataDef = "x = random(-5,5, makeSet(0));\n   \t       y = random(-5,5, makeSet(0));\n\t       a = random(-5,5, makeSet(0));\n\t       b = random(-5,5, makeSet(0));\n\t       c = %a * %x + %b * %y;\n\t       d = random(-5,5, makeSet(0));\n\t       e = random(-5,5, makeSet(0));\n\t       f = %d * %x + %e * %y;";
$solutionFn = "equals";
$solution = "makeArray(%x, %y);";
$template = new QuestionAssembler();
$defn = new QuestionDefinition($dataDef, $questionStr, $answerStr, $solution, $solutionFn, 0);
$template->build($defn);
$soln = $template->getTestQuestion();
print $soln->question . "<br>";
print $soln->answer . "<br>";
print $soln->solve("-5; 1");
print "<br><br>";
$questionStr = "%a + %b = ?<br>(a) %c (b) %d (c) %e (d) %f";
$answerStr = "(c)";
$dataDef = "a = random(1, 5);\n   \t       b = random(1, 5);\n\t       c = %a - %b;\n\t       d = %a - %b - 1;\n\t       e = %a + %b;\n\t       f = %a + %b + 1;";
$solutionFn = "equals";
$solution = "makeArray(\"c\");";
$template = new QuestionAssembler();
$defn = new QuestionDefinition($dataDef, $questionStr, $answerStr, $solution, $solutionFn, 0);
$template->build($defn);
$soln = $template->getTestQuestion();
print $soln->question . "<br>";
print $soln->answer . "<br>";
print $soln->solve("c");