当前位置: 首页>>代码示例>>PHP>>正文


PHP question_bank::load_question_definition_classes方法代码示例

本文整理汇总了PHP中question_bank::load_question_definition_classes方法的典型用法代码示例。如果您正苦于以下问题:PHP question_bank::load_question_definition_classes方法的具体用法?PHP question_bank::load_question_definition_classes怎么用?PHP question_bank::load_question_definition_classes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在question_bank的用法示例。


在下文中一共展示了question_bank::load_question_definition_classes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:dthies,项目名称:moodle-qtype_gapfill,代码行数:35,代码来源:helper.php

示例2: 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);
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:30,代码来源:question_test.php

示例3: get_calculated_question_data_sum

    /**
     * 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;
    }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:36,代码来源:helper.php

示例4: 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;
    }
开发者ID:nigeldaley,项目名称:moodle,代码行数:37,代码来源:helper.php

示例5: make_question_instance

 protected function make_question_instance($questiondata)
 {
     question_bank::load_question_definition_classes($this->name());
     $class = get_class($this);
     if ($questiondata->options->single) {
         $class = $class . '_single_question';
     } else {
         $class = $class . '_multi_question';
     }
     return new $class();
 }
开发者ID:kikkomep,项目名称:moodle.omero-qtypes,代码行数:11,代码来源:questiontype_base.php

示例6: make_a_regexp_question

 /**
  * Makes a REGEXP question with (first) correct answer "it's blue, white and red"
  * partially correct answer must match "(it('s| is) |they are )?blue, white, red"
  * @return qtype_regexp_question
  */
 public static function make_a_regexp_question()
 {
     question_bank::load_question_definition_classes('regexp');
     $pm = new qtype_regexp_question();
     self::initialise_a_question($pm);
     $pm->name = 'Regular expression short answer question';
     $pm->questiontext = 'French flag colors : __________';
     // generalfeedback is not needed in the REGEXP question type
     //$pm->generalfeedback = 'Generalfeedback: ';
     //$pm->regexpoptions = new regexp_options();
     $pm->answers = array(13 => new question_answer(13, "it's blue, white and red", 1.0, 'ok', FORMAT_HTML), 14 => new question_answer(14, "(it('s| is) |they are )?blue, white, red", 0.8, 'yes', FORMAT_HTML), 15 => new question_answer(15, '--.*blue.*', 0.0, 'Missing blue!', FORMAT_HTML), 15 => new question_answer(15, '.*', 0.0, 'No, no, no! Try again', FORMAT_HTML));
     $pm->qtype = question_bank::get_qtype('regexp');
     return $pm;
 }
开发者ID:rezeau,项目名称:moodle-qtype_regexp,代码行数:19,代码来源:testquestion.php

示例7: 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;
 }
开发者ID:fontinixxl,项目名称:moodle-qtype_linkerdesc,代码行数:17,代码来源:helper.php

示例8: make_a_turmultiplechoice_multi_question

 /**
  * Makes a turmultiplechoice question with choices 'A', 'B', 'C' and 'D' shuffled.
  * 'A' and 'C' is correct, defaultmark 1.
  * @return qtype_turmultiplechoice_multi_question
  */
 public static function make_a_turmultiplechoice_multi_question()
 {
     question_bank::load_question_definition_classes('turmultiplechoice');
     $mc = new qtype_turmultiplechoice_multi_question();
     self::initialise_a_question($mc);
     $mc->name = 'Multi-choice question, multiple response';
     $mc->questiontext = 'The answer is A and C.';
     $mc->generalfeedback = 'You should have selected A and C.';
     $mc->qtype = question_bank::get_qtype('turmultiplechoice');
     $mc->shuffleanswers = 1;
     $mc->qdifficulty = '0';
     self::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', -1, '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', -1, 'D is wrong', FORMAT_HTML));
     return $mc;
 }
开发者ID:edwinphillips,项目名称:turmultiplechoice_2.2,代码行数:20,代码来源:helpers.php

示例9: 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;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:20,代码来源:helper.php

示例10: 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;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:helper.php

示例11: 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;
 }
开发者ID:ndunand,项目名称:moodle-qtype_ddmarker,代码行数:19,代码来源:helper.php

示例12: 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;
    }
开发者ID:Burick,项目名称:moodle,代码行数:20,代码来源:helper.php

示例13: 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;
 }
开发者ID:ndunand,项目名称:moodle-qtype_gapselect,代码行数:20,代码来源:helper.php

示例14: 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;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:49,代码来源:helper.php

示例15: 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;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:24,代码来源:helper.php


注:本文中的question_bank::load_question_definition_classes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。