本文整理汇总了PHP中test_question_maker::initialise_a_question方法的典型用法代码示例。如果您正苦于以下问题:PHP test_question_maker::initialise_a_question方法的具体用法?PHP test_question_maker::initialise_a_question怎么用?PHP test_question_maker::initialise_a_question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_question_maker
的用法示例。
在下文中一共展示了test_question_maker::initialise_a_question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_calculated_question_sum
/**
* Makes a calculated question about summing two numbers.
* @return qtype_calculated_question
*/
public function make_calculated_question_sum() {
question_bank::load_question_definition_classes('calculated');
$q = new qtype_calculated_question();
test_question_maker::initialise_a_question($q);
$q->name = 'Simple sum';
$q->questiontext = 'What is {a} + {b}?';
$q->generalfeedback = 'Generalfeedback: {={a} + {b}} is the right answer.';
$q->answers = array(
13 => new qtype_numerical_answer(13, '{a} + {b}', 1.0, 'Very good.', FORMAT_HTML, 0),
14 => new qtype_numerical_answer(14, '{a} - {b}', 0.0, 'Add. not subtract!.',
FORMAT_HTML, 0),
17 => new qtype_numerical_answer(17, '*', 0.0, 'Completely wrong.', FORMAT_HTML, 0),
);
foreach ($q->answers as $answer) {
$answer->correctanswerlength = 2;
$answer->correctanswerformat = 1;
}
$q->qtype = question_bank::get_qtype('calculated');
$q->unitdisplay = qtype_numerical::UNITNONE;
$q->unitgradingtype = 0;
$q->unitpenalty = 0;
$q->ap = new qtype_numerical_answer_processor(array());
$q->synchronised = false;
$q->datasetloader = new qtype_calculated_test_dataset_loader(0, array(
array('a' => 1, 'b' => 5),
array('a' => 3, 'b' => 4),
));
return $q;
}
示例2: make_question
public static function make_question($type, $answers = array("cat", "mat"))
{
question_bank::load_question_definition_classes($type);
$question = new qtype_gapfill_question();
test_question_maker::initialise_a_question($question);
$question->qtype = question_bank::get_qtype('gapfill');
$question->name = 'Gapfill Test Question';
$question->questiontext = "The [cat] sat on the [mat]";
$question->textfragments = array('The ', ' sat on the ');
$question->displayanswers = '1';
$question->casesensitive = '1';
$question->generalfeedback = 'congratulations on your knowledge of pets and floor covering';
$question->places[1] = $answers[0];
$question->places[2] = $answers[1];
$answer1 = new question_answer(43, $answers[0], 4, 1, 1);
$answer2 = new question_answer(44, $answers[1], 4, 1, 1);
$question->answers = array($answer1, $answer2);
$question->options = new stdClass();
$question->options->showanswers = false;
$question->options->delimitchars = "[]";
$question->options->casesensitive = false;
$question->options->correctfeedback = "";
$question->options->correctfeedbackformat = "";
$question->options->partiallycorrectfeedback = "";
$question->options->partiallycorrectfeedbackformat = "";
$question->options->incorrectfeedback = "";
$question->options->incorrectfeedbackformat = "";
$question->options->shuffledanswers = "mat,cat";
$question->options->wronganswers = "bat,dog";
$question->shuffledanswers = "mat,cat,bat,dog";
$answers = new stdClass();
$question->options->answers = array($answer1, $answer2);
$question->hints = array(new question_hint(1, 'This is the first hint.', FORMAT_HTML), new question_hint(2, 'This is the second hint.', FORMAT_HTML));
return $question;
}
示例3: test_grading_rounding_three_right
public function test_grading_rounding_three_right() {
question_bank::load_question_definition_classes('multichoice');
$mc = new qtype_multichoice_multi_question();
test_question_maker::initialise_a_question($mc);
$mc->name = 'Odd numbers';
$mc->questiontext = 'Which are the odd numbers?';
$mc->generalfeedback = '1, 3 and 5 are the odd numbers.';
$mc->qtype = question_bank::get_qtype('multichoice');
$mc->shuffleanswers = 0;
$mc->answernumbering = 'abc';
test_question_maker::set_standard_combined_feedback_fields($mc);
$mc->answers = array(
11 => new question_answer(11, '1', 0.3333333, '', FORMAT_HTML),
12 => new question_answer(12, '2', -1, '', FORMAT_HTML),
13 => new question_answer(13, '3', 0.3333333, '', FORMAT_HTML),
14 => new question_answer(14, '4', -1, '', FORMAT_HTML),
15 => new question_answer(15, '5', 0.3333333, '', FORMAT_HTML),
16 => new question_answer(16, '6', -1, '', FORMAT_HTML),
);
$mc->start_attempt(new question_attempt_step(), 1);
list($grade, $state) = $mc->grade_response(
array('choice0' => 1, 'choice2' => 1, 'choice4' => 1));
$this->assertEquals(1, $grade, '', 0.000001);
$this->assertEquals(question_state::$gradedright, $state);
}
示例4: make_a_stack_question
/**
* Does the basical initialisation of a new Stack question that all the test
* questions will need.
* @return qtype_stack_question the new question.
*/
protected static function make_a_stack_question()
{
question_bank::load_question_definition_classes('stack');
$q = new qtype_stack_question();
test_question_maker::initialise_a_question($q);
$q->qtype = question_bank::get_qtype('stack');
$q->contextid = context_system::instance()->id;
$q->questionvariables = '';
$q->specificfeedback = '';
$q->specificfeedbackformat = FORMAT_HTML;
$q->penalty = 0.1;
// The default.
$q->prtcorrect = self::DEFAULT_CORRECT_FEEDBACK;
$q->prtcorrectformat = FORMAT_HTML;
$q->prtpartiallycorrect = self::DEFAULT_PARTIALLYCORRECT_FEEDBACK;
$q->prtpartiallycorrectformat = FORMAT_HTML;
$q->prtincorrect = self::DEFAULT_INCORRECT_FEEDBACK;
$q->prtincorrectformat = FORMAT_HTML;
$q->generalfeedback = '';
$q->variantsselectionseed = '';
$q->inputs = array();
$q->prts = array();
$q->options = new stack_options();
$q->questionnote = '';
return $q;
}
示例5: make_linkerdesc_question_info
/**
* @return qtype_linkerdesc_question
*/
public static function make_linkerdesc_question_info()
{
question_bank::load_question_definition_classes('linkerdesc');
$q = new qtype_linkerdesc_question();
test_question_maker::initialise_a_question($q);
$q->defaultmark = 0;
$q->penalty = 0;
$q->length = 0;
$q->name = 'Description';
$q->questiontext = 'Here is some information about the questions you are about to attempt.';
$q->generalfeedback = 'And here is some more text shown only on the review page.';
$q->qtype = question_bank::get_qtype('linkerdesc');
return $q;
}
示例6: make_a_multichoiceset_question
/**
* Makes a multichoice all or nothing question with choices 'A', 'B', 'C' and 'D' shuffled.
* 'A' and 'C' is correct, defaultmark 1.
* @return qtype_multichoiceset_question
*/
public static function make_a_multichoiceset_question()
{
question_bank::load_question_definition_classes('multichoiceset');
$mc = new qtype_multichoiceset_question();
test_question_maker::initialise_a_question($mc);
$mc->name = 'Multi-choice all or nothing question';
$mc->questiontext = 'The answer is A and C.';
$mc->generalfeedback = 'You should have selected A and C.';
$mc->qtype = question_bank::get_qtype('multichoiceset');
$mc->shuffleanswers = 1;
$mc->answernumbering = 'abc';
test_question_maker::set_standard_combined_feedback_fields($mc);
$mc->answers = array(13 => new question_answer(13, 'A', 0.5, 'A is part of the right answer', FORMAT_HTML), 14 => new question_answer(14, 'B', 0, 'B is wrong', FORMAT_HTML), 15 => new question_answer(15, 'C', 0.5, 'C is part of the right answer', FORMAT_HTML), 16 => new question_answer(16, 'D', 0, 'D is wrong', FORMAT_HTML));
return $mc;
}
示例7: make_ddmarker_question_maths
/**
* @return qtype_ddmarker_question
*/
public function make_ddmarker_question_maths()
{
question_bank::load_question_definition_classes('ddmarker');
$dd = new qtype_ddmarker_question();
test_question_maker::initialise_a_question($dd);
$dd->name = 'Drag-and-drop markers question';
$dd->questiontext = 'Fill in the operators to make this equation work: ';
$dd->generalfeedback = 'Hmmmm...';
$dd->qtype = question_bank::get_qtype('ddmarker');
$dd->shufflechoices = true;
test_question_maker::set_standard_combined_feedback_fields($dd);
$dd->choices = $this->make_choice_structure(array(new qtype_ddmarker_drag_item('+', 1, 1), new qtype_ddmarker_drag_item('-', 2, 1), new qtype_ddmarker_drag_item('*', 3, 1), new qtype_ddmarker_drag_item('/', 4, 1)));
$dd->places = $this->make_place_structure(array(new qtype_ddmarker_drop_zone(1, 'circle', '50,50;50'), new qtype_ddmarker_drop_zone(2, 'rectangle', '100,0;100,100'), new qtype_ddmarker_drop_zone(3, 'polygon', '0,100;100,100;100,200;0,200')));
$dd->rightchoices = array(1 => 1, 2 => 1, 3 => 1);
return $dd;
}
示例8: initialise_essay_question
/**
* Helper method to reduce duplication.
* @return qtype_essay_question
*/
protected function initialise_essay_question() {
question_bank::load_question_definition_classes('essay');
$q = new qtype_essay_question();
test_question_maker::initialise_a_question($q);
$q->name = 'Essay question (HTML editor)';
$q->questiontext = 'Please write a story about a frog.';
$q->generalfeedback = 'I hope your story had a beginning, a middle and an end.';
$q->responseformat = 'editor';
$q->responsefieldlines = 10;
$q->attachments = 0;
$q->graderinfo = '';
$q->graderinfoformat = FORMAT_HTML;
$q->qtype = question_bank::get_qtype('essay');
return $q;
}
示例9: make_ddimageortext_question_maths
/**
* Make a mathematical ddimageortext question.
*
* @return qtype_ddimageortext_question
*/
public function make_ddimageortext_question_maths()
{
question_bank::load_question_definition_classes('ddimageortext');
$dd = new qtype_ddimageortext_question();
test_question_maker::initialise_a_question($dd);
$dd->name = 'Drag-and-drop onto image question';
$dd->questiontext = 'Fill in the operators to make this equation work: ' . '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
$dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
$dd->qtype = question_bank::get_qtype('ddimageortext');
$dd->shufflechoices = true;
test_question_maker::set_standard_combined_feedback_fields($dd);
$dd->choices = $this->make_choice_structure(array(new qtype_ddimageortext_drag_item('+', 1, 1), new qtype_ddimageortext_drag_item('-', 2, 1)));
$dd->places = $this->make_place_structure(array(new qtype_ddimageortext_drop_zone('', 1, 1), new qtype_ddimageortext_drop_zone('', 2, 1), new qtype_ddimageortext_drop_zone('', 3, 1), new qtype_ddimageortext_drop_zone('', 4, 1)));
$dd->rightchoices = array(1 => 1, 2 => 2, 3 => 1, 4 => 2);
return $dd;
}
示例10: make_a_maths_gapselect_question
/**
* @return qtype_gapselect_question
*/
public static function make_a_maths_gapselect_question()
{
question_bank::load_question_definition_classes('gapselect');
$gapselect = new qtype_gapselect_question();
test_question_maker::initialise_a_question($gapselect);
$gapselect->name = 'Selection from drop down list question';
$gapselect->questiontext = 'Fill in the operators to make this equation work: ' . '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
$gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
$gapselect->qtype = question_bank::get_qtype('gapselect');
$gapselect->shufflechoices = true;
test_question_maker::set_standard_combined_feedback_fields($gapselect);
$gapselect->choices = array(1 => array(1 => new qtype_gapselect_choice('+', 1, true), 2 => new qtype_gapselect_choice('-', 1, true), 3 => new qtype_gapselect_choice('*', 1, true), 4 => new qtype_gapselect_choice('/', 1, true)));
$gapselect->places = array(1 => 1, 2 => 1, 3 => 1, 4 => 1);
$gapselect->rightchoices = array(1 => 1, 2 => 2, 3 => 1, 4 => 2);
$gapselect->textfragments = array('7 ', ' 11 ', ' 13 ', ' 17 ', ' 19 = 3');
return $gapselect;
}
示例11: make_randomsamatch_question_animals
/**
* Makes a randomsamatch question similar to the match question returned
* by {@link make_a_matching_question}, but with no 'insect' distractor.
* @return qtype_randomsamatch_question
*/
public function make_randomsamatch_question_animals()
{
question_bank::load_question_definition_classes('randomsamatch');
$q = new qtype_randomsamatch_question();
test_question_maker::initialise_a_question($q);
$q->name = 'Random shortanswer matching question';
$q->questiontext = 'Classify the animals.';
$q->generalfeedback = 'Frogs and toads are amphibians, the others are mammals.';
$q->qtype = question_bank::get_qtype('randomsamatch');
test_question_maker::set_standard_combined_feedback_fields($q);
$q->shufflestems = false;
$q->stems = array();
$q->choices = array();
$q->right = array();
// Now we create 4 shortanswers question,
// but we just fill the needed fields.
question_bank::load_question_definition_classes('shortanswer');
$sa1 = new qtype_shortanswer_question();
test_question_maker::initialise_a_question($sa1);
$sa1->id = 25;
$sa1->questiontext = 'Dog';
$sa1->answers = array(13 => new question_answer(13, 'Mammal', 1.0, 'Correct.', FORMAT_HTML), 14 => new question_answer(14, 'Animal', 0.5, 'There is a betterresponse.', FORMAT_HTML), 15 => new question_answer(15, '*', 0.0, 'That is a bad answer.', FORMAT_HTML));
$sa1->qtype = question_bank::get_qtype('shortanswer');
$sa2 = new qtype_shortanswer_question();
test_question_maker::initialise_a_question($sa2);
$sa2->id = 26;
$sa2->questiontext = 'Frog';
$sa2->answers = array(16 => new question_answer(16, 'Amphibian', 1.0, 'Correct.', FORMAT_HTML), 17 => new question_answer(17, 'A Prince', 1.0, 'Maybe.', FORMAT_HTML), 18 => new question_answer(18, '*', 0.0, 'That is a bad answer.', FORMAT_HTML));
$sa2->qtype = question_bank::get_qtype('shortanswer');
$sa3 = new qtype_shortanswer_question();
test_question_maker::initialise_a_question($sa3);
$sa3->id = 27;
$sa3->questiontext = 'Toad';
$sa3->answers = array(19 => new question_answer(19, 'Amphibian', 1.0, 'Correct.', FORMAT_HTML), 20 => new question_answer(20, '*', 0.0, 'That is a bad answer.', FORMAT_HTML));
$sa3->qtype = question_bank::get_qtype('shortanswer');
$sa4 = new qtype_shortanswer_question();
test_question_maker::initialise_a_question($sa4);
$sa4->id = 28;
$sa4->questiontext = 'Cat';
$sa4->answers = array(21 => new question_answer(21, 'Mammal', 1.0, 'Correct.', FORMAT_HTML));
$sa4->qtype = question_bank::get_qtype('shortanswer');
$q->questionsloader = new qtype_randomsamatch_test_question_loader(array(), 4, array($sa1, $sa2, $sa3, $sa4));
return $q;
}
示例12: make_truefalse_question_false
/**
* Makes a truefalse question with correct answer false.
* @return qtype_truefalse_question
*/
public function make_truefalse_question_false() {
question_bank::load_question_definition_classes('truefalse');
$tf = new qtype_truefalse_question();
test_question_maker::initialise_a_question($tf);
$tf->name = 'True/false question';
$tf->questiontext = 'The answer is false.';
$tf->generalfeedback = 'You should have selected false.';
$tf->penalty = 1;
$tf->qtype = question_bank::get_qtype('truefalse');
$tf->rightanswer = false;
$tf->truefeedback = 'This is the wrong answer.';
$tf->falsefeedback = 'This is the right answer.';
$tf->truefeedbackformat = FORMAT_HTML;
$tf->falsefeedbackformat = FORMAT_HTML;
$tf->trueanswerid = 13;
$tf->falseanswerid = 14;
return $tf;
}
示例13: make_multianswer_question_twosubq
/**
* Makes a multianswer question about summing two numbers.
* @return qtype_multianswer_question
*/
public function make_multianswer_question_twosubq()
{
question_bank::load_question_definition_classes('multianswer');
$q = new qtype_multianswer_question();
test_question_maker::initialise_a_question($q);
$q->name = 'Simple multianswer';
$q->questiontext = 'Complete this opening line of verse: "The {#1} and the {#2} went to sea".';
$q->generalfeedback = 'Generalfeedback: It\'s from "The Owl and the Pussy-cat" by Lear: ' . '"The owl and the pussycat went to see';
$q->questiontextformat = FORMAT_HTML;
$q->generalfeedbackformat = FORMAT_HTML;
// Shortanswer subquestion.
question_bank::load_question_definition_classes('shortanswer');
$sa = new qtype_shortanswer_question();
test_question_maker::initialise_a_question($sa);
$sa->name = 'Simple multianswer';
$sa->questiontext = '{1:SHORTANSWER:Dog#Wrong, silly!~=Owl#Well done!~*#Wrong answer}';
$sa->questiontextformat = FORMAT_HTML;
$sa->generalfeedback = '';
$sa->generalfeedbackformat = FORMAT_HTML;
$sa->usecase = true;
$sa->answers = array(13 => new question_answer(13, 'Dog', 0.0, 'Wrong, silly!', FORMAT_HTML), 14 => new question_answer(14, 'Owl', 1.0, 'Well done!', FORMAT_HTML), 15 => new question_answer(15, '*', 0.0, 'Wrong answer', FORMAT_HTML));
$sa->qtype = question_bank::get_qtype('shortanswer');
$sa->maxmark = 1;
// Multiple-choice subquestion.
question_bank::load_question_definition_classes('multichoice');
$mc = new qtype_multichoice_single_question();
test_question_maker::initialise_a_question($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 rediculous!~=Pussy-cat#Well done!}';
$mc->questiontextformat = FORMAT_HTML;
$mc->generalfeedback = '';
$mc->generalfeedbackformat = FORMAT_HTML;
$mc->shuffleanswers = 1;
$mc->answernumbering = 'none';
$mc->layout = qtype_multichoice_base::LAYOUT_DROPDOWN;
$mc->answers = array(13 => new question_answer(13, 'Bow-wow', 0, 'You seem to have a dog obsessions!', FORMAT_HTML), 14 => new question_answer(14, 'Wiggly worm', 0, 'Now you are just being rediculous!', FORMAT_HTML), 15 => new question_answer(15, 'Pussy-cat', 1, 'Well done!', FORMAT_HTML));
$mc->qtype = question_bank::get_qtype('multichoice');
$mc->maxmark = 1;
$q->subquestions = array(1 => $sa, 2 => $mc);
return $q;
}
示例14: make_a_ddmatching_question
/**
* Makes a matching question to classify 'Dog', 'Frog', 'Toad' and 'Cat' as
* 'Mammal', 'Amphibian' or 'Insect'.
* defaultmark 1. Stems are shuffled by default.
* @return qtype_match_question
*/
public static function make_a_ddmatching_question()
{
question_bank::load_question_definition_classes('ddmatch');
$ddmatch = new qtype_ddmatch_question();
test_question_maker::initialise_a_question($ddmatch);
$ddmatch->name = 'Drag and drop matching question';
$ddmatch->questiontext = 'Classify the animals.';
$ddmatch->generalfeedback = 'Frogs and toads are amphibians, the others are mammals.';
$ddmatch->qtype = question_bank::get_qtype('ddmatch');
$ddmatch->shufflestems = 1;
test_question_maker::set_standard_combined_feedback_fields($ddmatch);
// Using unset to get 1-based arrays.
$ddmatch->stems = array('', 'Dog', 'Frog', 'Toad', 'Cat');
$ddmatch->stemformat = array('', FORMAT_HTML, FORMAT_HTML, FORMAT_HTML, FORMAT_HTML);
$ddmatch->choices = array('', 'Mammal', 'Amphibian', 'Insect');
$ddmatch->choiceformat = array('', FORMAT_HTML, FORMAT_HTML, FORMAT_HTML);
$ddmatch->right = array('', 1, 2, 2, 1);
unset($ddmatch->stems[0]);
unset($ddmatch->stemformat[0]);
unset($ddmatch->choices[0]);
unset($ddmatch->right[0]);
return $ddmatch;
}
示例15: make_sqr_user_type_prototype
private function make_sqr_user_type_prototype($fileAttachmentReqd = false)
{
global $DB;
$q = $this->make_question('sqr');
$q->test_cases = array();
// No testcases in a prototype
$q->customise = 1;
$q->prototypetype = 2;
$q->typename = "sqr_user_prototype";
$q->cputimelimitsecs = 179;
// Silly test value
$q->combinatortemplate = 'combinatortemplatevalue';
// Save the prototype to the DB so it has an accessible context for
// retrieving associated files. All we need is its id and
// its category, but the DB has other required fields so we dummy
// up a minimal question containing the right category, at least.
question_bank::load_question_definition_classes('coderunner');
$row = new qtype_coderunner_question();
test_question_maker::initialise_a_question($row);
$catRow = $DB->get_record_select('question_categories', "contextid=1 limit 1");
$row->category = $catRow->id;
$row->qtype = 'qtype_coderunner';
$row->contextid = 1;
foreach (array('id', 'name', 'questiontext', 'generalfeedback') as $key) {
$row->{$key} = $q->{$key};
}
$q->id = $DB->insert_record('question', $row);
$qtype = new qtype_coderunner();
$qtype->save_question_options($q);
if ($fileAttachmentReqd) {
// Attach a file.
$fs = get_file_storage();
$fileinfo = array('contextid' => 1, 'component' => 'qtype_coderunner', 'filearea' => 'datafile', 'itemid' => $q->id, 'filepath' => '/', 'filename' => 'data.txt');
// Create file
$fs->create_file_from_string($fileinfo, "This is data\nLine 2");
}
return $q->id;
}