/** * Makes a calculated question about summing two numbers. * @return qtype_calculated_question */ public function get_calculated_question_data_sum() { question_bank::load_question_definition_classes('calculated'); $qdata = new stdClass(); test_question_maker::initialise_question_data($qdata); $qdata->qtype = 'calculated'; $qdata->name = 'Simple sum'; $qdata->questiontext = 'What is {a} + {b}?'; $qdata->generalfeedback = 'Generalfeedback: {={a} + {b}} is the right answer.'; $qdata->options = new stdClass(); $qdata->options->unitgradingtype = 0; $qdata->options->unitpenalty = 0.0; $qdata->options->showunits = qtype_numerical::UNITNONE; $qdata->options->unitsleft = 0; $qdata->options->synchronize = 0; $qdata->options->answers = array(13 => new qtype_numerical_answer(13, '{a} + {b}', 1.0, 'Very good.', FORMAT_HTML, 0.001), 14 => new qtype_numerical_answer(14, '{a} - {b}', 0.0, 'Add. not subtract!.', FORMAT_HTML, 0.001), 17 => new qtype_numerical_answer(17, '*', 0.0, 'Completely wrong.', FORMAT_HTML, 0)); foreach ($qdata->options->answers as $answer) { $answer->correctanswerlength = 2; $answer->correctanswerformat = 1; } $qdata->options->units = array(); return $qdata; }
/** * Makes a match question about completing two blanks in some text. * @return object the question definition data, as it might be returned from * get_question_options. */ public function get_match_question_data_foursubq() { global $USER; $q = new stdClass(); test_question_maker::initialise_question_data($q); $q->name = 'Matching question'; $q->qtype = 'match'; $q->parent = 0; $q->questiontext = 'Classify the animals.'; $q->questiontextformat = FORMAT_HTML; $q->generalfeedback = 'General feedback.'; $q->generalfeedbackformat = FORMAT_HTML; $q->defaultmark = 1; $q->penalty = 0.3333333; $q->length = 1; $q->hidden = 0; $q->createdby = $USER->id; $q->modifiedby = $USER->id; $q->options = new stdClass(); $q->options->shuffleanswers = 1; test_question_maker::set_standard_combined_feedback_fields($q->options); $q->options->subquestions = array(14 => (object) array('id' => 14, 'questiontext' => 'frog', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'amphibian'), 15 => (object) array('id' => 15, 'questiontext' => 'cat', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'mammal'), 16 => (object) array('id' => 16, 'questiontext' => 'newt', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'amphibian'), 17 => (object) array('id' => 17, 'questiontext' => '', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'insect')); return $q; }
/** * Makes a multianswer question about completing two blanks in some text. * @return object the question definition data, as it might be returned from * get_question_options. */ public function get_multianswer_question_data_twosubq() { $qdata = new stdClass(); test_question_maker::initialise_question_data($qdata); $qdata->name = 'Simple multianswer'; $qdata->questiontext = 'Complete this opening line of verse: "The {#1} and the {#2} went to sea".'; $qdata->generalfeedback = 'General feedback: It\'s from "The Owl and the Pussy-cat" by Lear: ' . '"The owl and the pussycat went to sea'; $qdata->defaultmark = 2.0; $qdata->qtype = 'multianswer'; $sa = new stdClass(); test_question_maker::initialise_question_data($sa); $sa->name = 'Simple multianswer'; $sa->questiontext = '{1:SHORTANSWER:Dog#Wrong, silly!~=Owl#Well done!~*#Wrong answer}'; $sa->generalfeedback = ''; $sa->penalty = 0.0; $sa->qtype = 'shortanswer'; $sa->options = new stdClass(); $sa->options->usecase = 0; $sa->options->answers = array( 13 => new question_answer(13, 'Dog', 0, 'Wrong, silly!', FORMAT_HTML), 14 => new question_answer(14, 'Owl', 1, 'Well done!', FORMAT_HTML), 15 => new question_answer(15, '*', 0, 'Wrong answer', FORMAT_HTML), ); $mc = new stdClass(); test_question_maker::initialise_question_data($mc); $mc->name = 'Simple multianswer'; $mc->questiontext = '{1:MULTICHOICE:Bow-wow#You seem to have a dog obsessions!~' . 'Wiggly worm#Now you are just being ridiculous!~=Pussy-cat#Well done!}'; $mc->generalfeedback = ''; $mc->penalty = 0.0; $mc->qtype = 'multichoice'; $mc->options = new stdClass(); $mc->options->layout = 0; $mc->options->single = 1; $mc->options->shuffleanswers = 1; $mc->options->correctfeedback = ''; $mc->options->correctfeedbackformat = 1; $mc->options->partiallycorrectfeedback = ''; $mc->options->partiallycorrectfeedbackformat = 1; $mc->options->incorrectfeedback = ''; $mc->options->incorrectfeedbackformat = 1; $mc->options->answernumbering = ''; $mc->options->shownumcorrect = 0; $mc->options->answers = array( 23 => new question_answer(23, 'Bow-wow', 0, 'You seem to have a dog obsessions!', FORMAT_HTML), 24 => new question_answer(24, 'Wiggly worm', 0, 'Now you are just being ridiculous!', FORMAT_HTML), 25 => new question_answer(25, 'Pussy-cat', 1, 'Well done!', FORMAT_HTML), ); $qdata->options = new stdClass(); $qdata->options->questions = array( 1 => $sa, 2 => $mc, ); $qdata->hints = array( new question_hint(0, 'Hint 1', FORMAT_HTML), new question_hint(0, 'Hint 2', FORMAT_HTML), ); return $qdata; }
/** * Gets the question data for a transcription questionwith just the correct * ansewer 'frog', and no other answer matching. * @return stdClass */ public function get_transcription_question_data_frogonly() { $qdata = new stdClass(); test_question_maker::initialise_question_data($qdata); $qdata->qtype = 'transcription'; $qdata->name = 'Transcription question'; $qdata->questiontext = 'Name the best amphibian: __________'; $qdata->generalfeedback = 'Generalfeedback: you should have said frog.'; $qdata->options = new stdClass(); $qdata->options->usecase = false; $qdata->options->answers = array(13 => new question_answer(13, 'frog', 1.0, 'Frog is right.', FORMAT_HTML)); return $qdata; }
/** * Gets the question data for a shortanswer questionwith just the correct * ansewer 'frog', and no other answer matching. * @return stdClass */ public function get_gapfill_question_data_catmat() { $qdata = new stdClass(); test_question_maker::initialise_question_data($qdata); $qdata->qtype = 'gapfill'; $qdata->name = 'catmat'; $qdata->questiontext = 'The [cat] sat on the [mat]'; $qdata->generalfeedback = 'someanswer'; $qdata->options = new stdClass(); $qdata->options->casesensitive = false; return $qdata; }
/** * Makes a multianswer question onetaining one blank in some text. * This question has no hints. * * @return object the question definition data, as it might be returned from * get_question_options. */ public function get_multianswer_question_data_dollarsigns() { $qdata = new stdClass(); test_question_maker::initialise_question_data($qdata); $qdata->name = 'Multianswer with $s'; $qdata->questiontext = 'Which is the right order? {#1}'; $qdata->generalfeedback = ''; $qdata->defaultmark = 1.0; $qdata->qtype = 'multianswer'; $mc = new stdClass(); test_question_maker::initialise_question_data($mc); $mc->name = 'Multianswer with $s'; $mc->questiontext = '{1:MULTICHOICE:=y,y,$3~$3,y,y}'; $mc->generalfeedback = ''; $mc->penalty = 0.0; $mc->qtype = 'multichoice'; $mc->options = new stdClass(); $mc->options->layout = 0; $mc->options->single = 1; $mc->options->shuffleanswers = 0; $mc->options->correctfeedback = ''; $mc->options->correctfeedbackformat = 1; $mc->options->partiallycorrectfeedback = ''; $mc->options->partiallycorrectfeedbackformat = 1; $mc->options->incorrectfeedback = ''; $mc->options->incorrectfeedbackformat = 1; $mc->options->answernumbering = 0; $mc->options->shownumcorrect = 0; $mc->options->answers = array(23 => new question_answer(23, 'y,y,$3', 0, '', FORMAT_HTML), 24 => new question_answer(24, '$3,y,y', 0, '', FORMAT_HTML)); $qdata->options = new stdClass(); $qdata->options->questions = array(1 => $mc); $qdata->hints = array(); return $qdata; }
/** * @return qtype_stack_question the question from the test3.xml file. */ public static function get_stack_question_data_test3() { question_bank::load_question_definition_classes('stack'); $qdata = new stdClass(); test_question_maker::initialise_question_data($qdata); $qdata->contextid = context_system::instance()->id; $qdata->qtype = 'stack'; $qdata->name = 'test-3'; $qdata->questiontext = '<p>1. Give an example of an odd function by typing an expression which represents it. $f_1(x)=$ [[input:ans1]]. [[validation:ans1]] [[feedback:odd]]</p> <p>2. Give an example of an even function. $f_2(x)=$ [[input:ans2]]. [[validation:ans2]] [[feedback:even]]</p> <p>3. Give an example of a function which is odd and even. $f_3(x)=$ [[input:ans3]]. [[validation:ans3]] [[feedback:oddeven]]</p> <p>4. Is the answer to 3. unique? [[input:ans4]] (Or are there many different possibilities.) [[validation:ans4]] [[feedback:unique]]</p>'; $qdata->generalfeedback = ''; $qdata->penalty = 0.4; $qdata->options = new stdClass(); $qdata->options->id = 0; $qdata->options->questionvariables = ''; $qdata->options->specificfeedback = ''; $qdata->options->specificfeedbackformat = FORMAT_HTML; $qdata->options->questionnote = ''; $qdata->options->questionsimplify = 1; $qdata->options->assumepositive = 0; $qdata->options->markmode = 'penalty'; $qdata->options->prtcorrect = self::DEFAULT_CORRECT_FEEDBACK; $qdata->options->prtcorrectformat = FORMAT_HTML; $qdata->options->prtpartiallycorrect = self::DEFAULT_PARTIALLYCORRECT_FEEDBACK; $qdata->options->prtpartiallycorrectformat = FORMAT_HTML; $qdata->options->prtincorrect = self::DEFAULT_INCORRECT_FEEDBACK; $qdata->options->prtincorrectformat = FORMAT_HTML; $qdata->options->multiplicationsign = 'dot'; $qdata->options->sqrtsign = 1; $qdata->options->complexno = 'i'; $qdata->options->inversetrig = 'cos-1'; $qdata->options->matrixparens = '['; $qdata->options->variantsselectionseed = ''; $input = new stdClass(); $input->name = 'ans1'; $input->id = 0; $input->questionid = 0; $input->type = 'algebraic'; $input->tans = 'x^3'; $input->boxsize = 15; $input->strictsyntax = 1; $input->insertstars = 0; $input->syntaxhint = ''; $input->forbidwords = ''; $input->allowwords = ''; $input->forbidfloat = 1; $input->requirelowestterms = 0; $input->checkanswertype = 0; $input->mustverify = 1; $input->showvalidation = 1; $input->options = ''; $qdata->inputs['ans1'] = $input; $input = new stdClass(); $input->name = 'ans2'; $input->id = 0; $input->questionid = 0; $input->type = 'algebraic'; $input->tans = 'x^4'; $input->boxsize = 15; $input->strictsyntax = 1; $input->insertstars = 0; $input->syntaxhint = ''; $input->forbidwords = ''; $input->allowwords = ''; $input->forbidfloat = 1; $input->requirelowestterms = 0; $input->checkanswertype = 0; $input->mustverify = 1; $input->showvalidation = 1; $input->options = ''; $qdata->inputs['ans2'] = $input; $input = new stdClass(); $input->name = 'ans3'; $input->id = 0; $input->questionid = 0; $input->type = 'algebraic'; $input->tans = '0'; $input->boxsize = 15; $input->strictsyntax = 1; $input->insertstars = 0; $input->syntaxhint = ''; $input->forbidwords = ''; $input->allowwords = ''; $input->forbidfloat = 1; $input->requirelowestterms = 0; $input->checkanswertype = 0; $input->mustverify = 1; $input->showvalidation = 1; $input->options = ''; $qdata->inputs['ans3'] = $input; $input = new stdClass(); $input->name = 'ans4'; $input->id = 0; $input->questionid = 0; $input->type = 'boolean'; $input->tans = 'true'; $input->boxsize = 15; $input->strictsyntax = 1; $input->insertstars = 0; $input->syntaxhint = ''; $input->forbidwords = ''; $input->allowwords = ''; $input->forbidfloat = 1; $input->requirelowestterms = 0; $input->checkanswertype = 0; $input->mustverify = 0; $input->showvalidation = 0; $input->options = ''; $qdata->inputs['ans4'] = $input; $prt = new stdClass(); $prt->name = 'odd'; $prt->id = '0'; $prt->questionid = '0'; $prt->value = 1; $prt->autosimplify = 1; $prt->feedbackvariables = 'sa:subst(x=-x,ans1)+ans1'; $prt->firstnodename = '0'; $node = new stdClass(); $node->id = 0; $node->questionid = 0; $node->prtname = 'odd'; $node->nodename = '0'; $node->answertest = 'AlgEquiv'; $node->sans = 'sa'; $node->tans = '0'; $node->testoptions = null; $node->quiet = 0; $node->truescoremode = '='; $node->truescore = 1; $node->truepenalty = 0.4; $node->truenextnode = -1; $node->trueanswernote = 'odd-0-1'; $node->truefeedback = ''; $node->truefeedbackformat = FORMAT_HTML; $node->falsescoremode = '='; $node->falsescore = 0; $node->falsepenalty = 0.4; $node->falsenextnode = -1; $node->falseanswernote = 'odd-0-0'; $node->falsefeedback = 'Your answer is not an odd function. Look, \\[ f(x)+f(-x)=@sa@ \\neq 0.\\]'; $node->falsefeedbackformat = FORMAT_HTML; $prt->nodes['0'] = $node; $qdata->prts['odd'] = $prt; $prt = new stdClass(); $prt->name = 'even'; $prt->id = '0'; $prt->questionid = '0'; $prt->value = 1; $prt->autosimplify = 1; $prt->feedbackvariables = 'sa:subst(x=-x,ans2)-ans2'; $prt->firstnodename = '0'; $node = new stdClass(); $node->id = 0; $node->questionid = 0; $node->prtname = 'even'; $node->nodename = '0'; $node->answertest = 'AlgEquiv'; $node->sans = 'sa'; $node->tans = '0'; $node->testoptions = null; $node->quiet = 0; $node->truescoremode = '='; $node->truescore = 1; $node->truepenalty = 0.4; $node->truenextnode = -1; $node->trueanswernote = 'even-0-1'; $node->truefeedback = ''; $node->truefeedbackformat = FORMAT_HTML; $node->falsescoremode = '='; $node->falsescore = 0; $node->falsepenalty = 0.4; $node->falsenextnode = -1; $node->falseanswernote = 'even-0-0'; $node->falsefeedback = 'Your answer is not an even function. Look, \\[ f(x)-f(-x)=@sa@ \\neq 0.\\]'; $node->falsefeedbackformat = FORMAT_HTML; $prt->nodes['0'] = $node; $qdata->prts['even'] = $prt; $prt = new stdClass(); $prt->name = 'oddeven'; $prt->id = '0'; $prt->questionid = '0'; $prt->value = 1; $prt->autosimplify = 1; $prt->feedbackvariables = 'sa1:ans3+subst(x=-x,ans3); sa2:ans3-subst(x=-x,ans3)'; $prt->firstnodename = '0'; $node = new stdClass(); $node->id = 0; $node->questionid = 0; $node->prtname = 'oddeven'; $node->nodename = '0'; $node->answertest = 'AlgEquiv'; $node->sans = 'sa1'; $node->tans = '0'; $node->testoptions = null; $node->quiet = 0; $node->truescoremode = '='; $node->truescore = 0.5; $node->truepenalty = 0.4; $node->truenextnode = 1; $node->trueanswernote = 'oddeven-0-1'; $node->truefeedback = ''; $node->truefeedbackformat = FORMAT_HTML; $node->falsescoremode = '='; $node->falsescore = 0; $node->falsepenalty = 0.4; $node->falsenextnode = 1; $node->falseanswernote = 'oddeven-0-0'; $node->falsefeedback = 'Your answer is not an odd function. Look, \\[ f(x)+f(-x)=@sa1@ \\neq 0.\\]'; $node->falsefeedbackformat = FORMAT_HTML; $prt->nodes['0'] = $node; $node = new stdClass(); $node->id = 0; $node->questionid = 0; $node->prtname = 'oddeven'; $node->nodename = '1'; $node->answertest = 'AlgEquiv'; $node->sans = 'sa2'; $node->tans = '0'; $node->testoptions = null; $node->quiet = 0; $node->truescoremode = '+'; $node->truescore = 0.5; $node->truepenalty = 0.4; $node->truenextnode = -1; $node->trueanswernote = 'oddeven-1-1'; $node->truefeedback = ''; $node->truefeedbackformat = FORMAT_HTML; $node->falsescoremode = '+'; $node->falsescore = 0; $node->falsepenalty = 0.4; $node->falsenextnode = -1; $node->falseanswernote = 'oddeven-1-0'; $node->falsefeedback = 'Your answer is not an even function. Look, \\[ f(x)-f(-x)=@sa2@ \\neq 0.\\]'; $node->falsefeedbackformat = FORMAT_HTML; $prt->nodes['1'] = $node; $qdata->prts['oddeven'] = $prt; $prt = new stdClass(); $prt->name = 'unique'; $prt->id = '0'; $prt->questionid = '0'; $prt->value = 1; $prt->autosimplify = 1; $prt->feedbackvariables = null; $prt->firstnodename = '0'; $node = new stdClass(); $node->id = 0; $node->questionid = 0; $node->prtname = 'unique'; $node->nodename = '0'; $node->answertest = 'AlgEquiv'; $node->sans = 'ans4'; $node->tans = 'true'; $node->testoptions = null; $node->quiet = 0; $node->truescoremode = '='; $node->truescore = 1; $node->truepenalty = 1; $node->truenextnode = -1; $node->trueanswernote = 'unique-0-1'; $node->truefeedback = ''; $node->truefeedbackformat = FORMAT_HTML; $node->falsescoremode = '='; $node->falsescore = 0; $node->falsepenalty = 1; $node->falsenextnode = -1; $node->falseanswernote = 'unique-0-0'; $node->falsefeedback = ''; $node->falsefeedbackformat = FORMAT_HTML; $prt->nodes['0'] = $node; $qdata->prts['unique'] = $prt; $qdata->deployedseeds = array(); $qdata->testcases = array(); $qdata->hints = array(1 => new question_hint(1, 'Hint 1', FORMAT_HTML), 2 => new question_hint(2, 'Hint 2', FORMAT_HTML)); return $qdata; }