• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP question_bank类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: define_question_plugin_structure

 /**
  * Returns the qtype information to attach to question element.
  */
 protected function define_question_plugin_structure()
 {
     $qtypeobj = question_bank::get_qtype($this->pluginname);
     // Define the virtual plugin element with the condition to fulfill.
     $plugin = $this->get_plugin_element(null, '../../qtype', $qtypeobj->name());
     // Create one standard named plugin element (the visible container).
     $pluginwrapper = new backup_nested_element($this->get_recommended_name());
     // Connect the visible container ASAP.
     $plugin->add_child($pluginwrapper);
     // This qtype uses standard question_answers, add them here
     // to the tree before any other information that will use them.
     $this->add_question_question_answers($pluginwrapper);
     $answers = $pluginwrapper->get_child('answers');
     $answer = $answers->get_child('answer');
     // Extra question fields.
     $extraquestionfields = $qtypeobj->extra_question_fields();
     if (!empty($extraquestionfields)) {
         $tablename = array_shift($extraquestionfields);
         $child = new backup_nested_element($qtypeobj->name(), array('id'), $extraquestionfields);
         $pluginwrapper->add_child($child);
         $child->set_source_table($tablename, array($qtypeobj->questionid_column_name() => backup::VAR_PARENTID));
     }
     // Extra answer fields.
     $extraanswerfields = $qtypeobj->extra_answer_fields();
     if (!empty($extraanswerfields)) {
         $tablename = array_shift($extraanswerfields);
         $child = new backup_nested_element('extraanswerdata', array('id'), $extraanswerfields);
         $answer->add_child($child);
         $child->set_source_table($tablename, array('answerid' => backup::VAR_PARENTID));
     }
     // Don't need to annotate ids nor files.
     return $plugin;
 }
开发者ID:saylordotorg,项目名称:moodle-qtype_poasquestion,代码行数:36,代码来源:backup_poasquestion_plugin.class.php


示例2: definition_inner

 protected function definition_inner($mform)
 {
     global $DB, $question;
     $loaded_initialy = optional_param('reloaded_initialy', 1, PARAM_INT);
     $qtype = question_bank::get_qtype('javaunittest');
     $definitionoptions = $this->_customdata['definitionoptions'];
     $attachmentoptions = $this->_customdata['attachmentoptions'];
     // -------------------------- feedback options
     $mform->addElement('select', 'feedbacklevel', get_string('feedbacklevel', 'qtype_javaunittest'), $qtype->feedback_levels());
     $mform->setDefault('feedbacklevel', FEEDBACK_ONLY_TIMES);
     // -------------------------- size of the response field
     $mform->addElement('select', 'responsefieldlines', get_string('responsefieldlines', 'qtype_javaunittest'), $qtype->response_sizes());
     $mform->setDefault('responsefieldlines', 15);
     // -------------------------- "Given Code" Text-Area
     $mform->addElement('textarea', 'givencode', get_string('givencode', 'qtype_javaunittest'), array('cols' => 80, 'rows' => 20));
     $mform->setType('givencode', PARAM_RAW);
     $mform->addHelpButton('givencode', 'givencode', 'qtype_javaunittest');
     // -------------------------- "Test class" Text-Area
     $mform->addElement('textarea', 'testclassname', get_string('testclassname', 'qtype_javaunittest'), array('cols' => 80, 'rows' => 1));
     $mform->setType('testclassname', PARAM_ALPHANUMEXT);
     $mform->addRule('testclassname', null, 'required');
     $mform->addHelpButton('testclassname', 'testclassname', 'qtype_javaunittest');
     $mform->addElement('textarea', 'junitcode', get_string('uploadtestclass', 'qtype_javaunittest'), array('cols' => 80, 'rows' => 20));
     $mform->setType('junitcode', PARAM_RAW);
     $mform->addRule('junitcode', null, 'required');
     $mform->addHelpButton('junitcode', 'uploadtestclass', 'qtype_javaunittest');
 }
开发者ID:printz81,项目名称:javaunittest,代码行数:27,代码来源:edit_javaunittest_form.php


示例3: get_questions_category

/**
* Function to read all questions for category into big array
*
* @param int $category category number
* @param bool $noparent if true only questions with NO parent will be selected
* @param bool $recurse include subdirectories
* @param bool $export set true if this is called by questionbank export
*/
function get_questions_category($category, $noparent = false, $recurse = true, $export = true)
{
    global $DB;
    // Build sql bit for $noparent
    $npsql = '';
    if ($noparent) {
        $npsql = " and parent='0' ";
    }
    // Get list of categories
    if ($recurse) {
        $categorylist = question_categorylist($category->id);
    } else {
        $categorylist = array($category->id);
    }
    // Get the list of questions for the category
    list($usql, $params) = $DB->get_in_or_equal($categorylist);
    $questions = $DB->get_records_select('question', "category {$usql} {$npsql}", $params, 'qtype, name');
    // Iterate through questions, getting stuff we need
    $qresults = array();
    foreach ($questions as $key => $question) {
        $question->export_process = $export;
        $qtype = question_bank::get_qtype($question->qtype, false);
        if ($export && $qtype->name() == 'missingtype') {
            // Unrecognised question type. Skip this question when exporting.
            continue;
        }
        $qtype->get_question_options($question);
        $qresults[] = $question;
    }
    return $qresults;
}
开发者ID:janeklb,项目名称:moodle,代码行数:39,代码来源:editlib.php


示例4: definition_inner

 protected function definition_inner($mform)
 {
     global $PAGE, $CFG;
     $PAGE->requires->js('/question/type/jme/jme_script.js');
     $PAGE->requires->css('/question/type/jme/styles.css');
     $mform->addElement('hidden', 'usecase', 1);
     $mform->setType('usecase', PARAM_INT);
     $optionscript = 'onClick = "setJSMEoptions()"';
     $label = get_string('jmeoptions', 'qtype_jme');
     $editoroptions[] = $mform->createElement('text', 'jmeoptions', '', array('size' => 50));
     $editoroptions[] = $mform->createElement('button', 'setoptions', get_string('setoptions', 'qtype_jme'), $optionscript);
     $mform->addElement('group', 'editoroptions', $label, $editoroptions, null, false);
     $mform->setDefault('jmeoptions', $CFG->qtype_jme_options);
     $mform->setType('jmeoptions', PARAM_RAW);
     $mform->addHelpButton('editoroptions', 'jmeoptions', 'qtype_jme');
     $mform->addElement('text', 'width', get_string('width', 'qtype_jme'), array('size' => 6));
     $mform->setDefault('width', QTYPE_JME_APPLET_WIDTH);
     $mform->setType('width', PARAM_INT);
     $mform->addElement('text', 'height', get_string('height', 'qtype_jme'), array('size' => 6));
     $mform->setDefault('height', QTYPE_JME_APPLET_HEIGHT);
     $mform->setType('height', PARAM_INT);
     $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'qtype_jme'), get_string('filloutoneanswer', 'qtype_jme'));
     $mform->addElement('html', html_writer::tag('div', get_string('enablejavascript', 'qtype_jme'), array('class' => 'jme_applet', 'code' => 'JME.class', 'id' => 'jme1', 'name' => 'JME1', 'archive' => 'JME.jar', 'width' => '360', 'height' => '315', 'style' => 'margin: 1.5em auto')));
     $mform->closeHeaderBefore('answersinstruct');
     $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_jme', '{no}'), question_bank::fraction_options());
     $this->add_interactive_settings();
     // Include JSME loader script as an html tag.
     $jsmescript = $CFG->wwwroot . '/question/type/jme/jsme/jsme.nocache.js';
     $mform->addElement('html', html_writer::tag('script', '', array('src' => $jsmescript)));
 }
开发者ID:uofr,项目名称:moodle-qtype_jme,代码行数:30,代码来源:edit_jme_form.php


示例5: validation

 public function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     if (isset($data->categorymoveto)) {
         list($category) = explode(',', $data['categorymoveto']);
     } else {
         list($category) = explode(',', $data['category']);
     }
     $saquestions = question_bank::get_qtype('randomsamatch')->get_sa_candidates($category);
     $numberavailable = count($saquestions);
     if ($saquestions === false) {
         $a = new stdClass();
         $a->catname = $DB->get_field('question_categories', 'name', array('id' => $category));
         $errors['choose'] = get_string('nosaincategory', 'qtype_randomsamatch', $a);
     } else {
         if ($numberavailable < $data['choose']) {
             $a = new stdClass();
             $a->catname = $DB->get_field('question_categories', 'name', array('id' => $category));
             $a->nosaquestions = $numberavailable;
             $errors['choose'] = get_string('notenoughsaincategory', 'qtype_randomsamatch', $a);
         }
     }
     return $errors;
 }
开发者ID:helenagarcia90,项目名称:moodle,代码行数:25,代码来源:edit_randomsamatch_form.php


示例6: definition_inner

 protected function definition_inner($mform)
 {
     $qtype = question_bank::get_qtype('poodllrecording');
     $mform->addElement('select', 'responseformat', get_string('responseformat', 'qtype_poodllrecording'), $qtype->response_formats());
     $mform->setDefault('responseformat', 'editor');
     $mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_poodllrecording'), array('rows' => 10), $this->editoroptions);
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:7,代码来源:edit_poodllrecording_form.php


示例7: test_core_question_update_flag

 /**
  * Test update question flag
  */
 public function test_core_question_update_flag()
 {
     $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
     // Create a question category.
     $cat = $questiongenerator->create_question_category();
     $quba = question_engine::make_questions_usage_by_activity('core_question_update_flag', context_system::instance());
     $quba->set_preferred_behaviour('deferredfeedback');
     $questiondata = $questiongenerator->create_question('numerical', null, array('category' => $cat->id));
     $question = question_bank::load_question($questiondata->id);
     $slot = $quba->add_question($question);
     $qa = $quba->get_question_attempt($slot);
     self::setUser($this->student);
     $quba->start_all_questions();
     question_engine::save_questions_usage_by_activity($quba);
     $qubaid = $quba->get_id();
     $questionid = $question->id;
     $qaid = $qa->get_database_id();
     $checksum = md5($qubaid . "_" . $this->student->secret . "_" . $questionid . "_" . $qaid . "_" . $slot);
     $flag = core_question_external::update_flag($qubaid, $questionid, $qaid, $slot, $checksum, true);
     $this->assertTrue($flag['status']);
     // Test invalid checksum.
     try {
         // Using random_string to force failing.
         $checksum = md5($qubaid . "_" . random_string(11) . "_" . $questionid . "_" . $qaid . "_" . $slot);
         core_question_external::update_flag($qubaid, $questionid, $qaid, $slot, $checksum, true);
         $this->fail('Exception expected due to invalid checksum.');
     } catch (moodle_exception $e) {
         $this->assertEquals('errorsavingflags', $e->errorcode);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:externallib_test.php


示例8: definition_inner

 protected function definition_inner($mform)
 {
     $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_numerical', '{no}'), question_bank::fraction_options());
     $this->add_unit_options($mform);
     $this->add_unit_fields($mform);
     $this->add_interactive_settings();
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:7,代码来源:edit_numerical_form.php


示例9: definition_inner

    protected function definition_inner($mform) {
        $qtype = question_bank::get_qtype('essay');

        $mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_essay'),
                array('rows' => 10), $this->editoroptions);

        $mform->addElement('header', 'responseheader', get_string('responseheader', 'qtype_essay'));

        $mform->addElement('select', 'responseformat',
                get_string('responseformat', 'qtype_essay'), $qtype->response_formats());
        $mform->setDefault('responseformat', 'editor');

        $mform->addElement('select', 'responsefieldlines',
                get_string('responsefieldlines', 'qtype_essay'), $qtype->response_sizes());
        $mform->setDefault('responsefieldlines', 15);

        $mform->addElement('select', 'attachments',
                get_string('allowattachments', 'qtype_essay'), $qtype->attachment_options());
        $mform->setDefault('attachments', 0);

        $mform->addElement('select', 'responselimitpolicy',
                get_string('responselimitpolicy', 'qtype_essay'), $qtype->response_limit_policies());
        $mform->addHelpButton('responselimitpolicy', 'responselimitpolicy', 'qtype_essay');

        $mform->addElement('text', 'wordlimit', get_string('wordlimit', 'qtype_essay'), array('size' => 3));
        $mform->disabledIf('wordlimit', 'responselimitpolicy', 'eq', 0);
        $mform->setType('wordlimit', PARAM_INT);

        $mform->addElement('text', 'charlimit', get_string('charlimit', 'qtype_essay'), array('size' => 3));
        $mform->disabledIf('charlimit', 'responselimitpolicy', 'eq', 0);
        $mform->setType('charlimit', PARAM_INT);
    }
开发者ID:nickkoeppen,项目名称:moodle,代码行数:32,代码来源:edit_essay_form.php


示例10: 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


示例11: 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


示例12: test_import_match

 public function test_import_match()
 {
     $xml = $this->make_test_xml();
     $importer = new qformat_blackboard_six();
     $questions = $importer->readquestions($xml);
     $q = $questions[5];
     // If qtype_ddmatch is installed, the formatter produces ddmatch
     // qtypes, not match ones.
     $ddmatchisinstalled = question_bank::is_qtype_installed('ddmatch');
     $expectedq = new stdClass();
     $expectedq->qtype = $ddmatchisinstalled ? 'ddmatch' : 'match';
     $expectedq->name = 'Classify the animals.';
     $expectedq->questiontext = '<i>Classify the animals.</i>';
     $expectedq->questiontextformat = FORMAT_HTML;
     $expectedq->correctfeedback = array('text' => '', 'format' => FORMAT_HTML);
     $expectedq->partiallycorrectfeedback = array('text' => '', 'format' => FORMAT_HTML);
     $expectedq->incorrectfeedback = array('text' => '', 'format' => FORMAT_HTML);
     $expectedq->generalfeedback = '';
     $expectedq->generalfeedbackformat = FORMAT_HTML;
     $expectedq->defaultmark = 1;
     $expectedq->length = 1;
     $expectedq->penalty = 0.3333333;
     $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers');
     $expectedq->subquestions = array(array('text' => 'cat', 'format' => FORMAT_HTML), array('text' => '', 'format' => FORMAT_HTML), array('text' => 'frog', 'format' => FORMAT_HTML), array('text' => 'newt', 'format' => FORMAT_HTML));
     if ($ddmatchisinstalled) {
         $expectedq->subanswers = array(array('text' => 'mammal', 'format' => FORMAT_HTML), array('text' => 'insect', 'format' => FORMAT_HTML), array('text' => 'amphibian', 'format' => FORMAT_HTML), array('text' => 'amphibian', 'format' => FORMAT_HTML));
     } else {
         $expectedq->subanswers = array('mammal', 'insect', 'amphibian', 'amphibian');
     }
     $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:blackboardformatpool_test.php


示例13: __construct

 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 public function __construct($submiturl, $question, $regenerate)
 {
     global $SESSION, $CFG, $DB;
     $this->regenerate = $regenerate;
     $this->question = $question;
     $this->qtypeobj = question_bank::get_qtype($this->question->qtype);
     // Validate the question category.
     if (!($category = $DB->get_record('question_categories', array('id' => $question->category)))) {
         print_error('categorydoesnotexist', 'question', $returnurl);
     }
     $this->category = $category;
     $this->categorycontext = context::instance_by_id($category->contextid);
     // Get the dataset defintions for this question.
     if (empty($question->id)) {
         $this->datasetdefs = $this->qtypeobj->get_dataset_definitions($question->id, $SESSION->calculated->definitionform->dataset);
     } else {
         if (empty($question->options)) {
             $this->get_question_options($question);
         }
         $this->datasetdefs = $this->qtypeobj->get_dataset_definitions($question->id, array());
     }
     foreach ($this->datasetdefs as $datasetdef) {
         // Get maxnumber.
         if ($this->maxnumber == -1 || $datasetdef->itemcount < $this->maxnumber) {
             $this->maxnumber = $datasetdef->itemcount;
         }
     }
     foreach ($this->datasetdefs as $defid => $datasetdef) {
         if (isset($datasetdef->id)) {
             $this->datasetdefs[$defid]->items = $this->qtypeobj->get_database_dataset_items($datasetdef->id);
         }
     }
     parent::__construct($submiturl);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:39,代码来源:datasetitems_form.php


示例14: readquestions

 public function readquestions($lines)
 {
     question_bank::get_qtype('multianswer');
     // Ensure the multianswer code is loaded.
     // For this class the method has been simplified as
     // there can never be more than one question for a
     // multianswer import.
     $questions = array();
     $questiontext = array();
     $questiontext['text'] = implode('', $lines);
     $questiontext['format'] = FORMAT_MOODLE;
     $questiontext['itemid'] = '';
     $question = qtype_multianswer_extract_question($questiontext);
     $question->questiontext = $question->questiontext['text'];
     $question->questiontextformat = 0;
     $question->qtype = 'multianswer';
     $question->generalfeedback = '';
     $question->generalfeedbackformat = FORMAT_MOODLE;
     $question->length = 1;
     $question->penalty = 0.3333333;
     if (!empty($question)) {
         $question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question'));
         $questions[] = $question;
     }
     return $questions;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:format.php


示例15: definition_inner

 protected function definition_inner($mform)
 {
     $qtype = question_bank::get_qtype('essay');
     $mform->addElement('header', 'responseoptions', get_string('responseoptions', 'qtype_essay'));
     $mform->setExpanded('responseoptions');
     $mform->addElement('select', 'responseformat', get_string('responseformat', 'qtype_essay'), $qtype->response_formats());
     $mform->setDefault('responseformat', 'editor');
     $mform->addElement('select', 'responserequired', get_string('responserequired', 'qtype_essay'), $qtype->response_required_options());
     $mform->setDefault('responserequired', 1);
     $mform->disabledIf('responserequired', 'responseformat', 'eq', 'noinline');
     $mform->addElement('select', 'responsefieldlines', get_string('responsefieldlines', 'qtype_essay'), $qtype->response_sizes());
     $mform->setDefault('responsefieldlines', 15);
     $mform->disabledIf('responsefieldlines', 'responseformat', 'eq', 'noinline');
     $mform->addElement('select', 'attachments', get_string('allowattachments', 'qtype_essay'), $qtype->attachment_options());
     $mform->setDefault('attachments', 0);
     $mform->addElement('select', 'attachmentsrequired', get_string('attachmentsrequired', 'qtype_essay'), $qtype->attachments_required_options());
     $mform->setDefault('attachmentsrequired', 0);
     $mform->addHelpButton('attachmentsrequired', 'attachmentsrequired', 'qtype_essay');
     $mform->disabledIf('attachmentsrequired', 'attachments', 'eq', 0);
     $mform->addElement('header', 'responsetemplateheader', get_string('responsetemplateheader', 'qtype_essay'));
     $mform->addElement('editor', 'responsetemplate', get_string('responsetemplate', 'qtype_essay'), array('rows' => 10), array_merge($this->editoroptions, array('maxfiles' => 0)));
     $mform->addHelpButton('responsetemplate', 'responsetemplate', 'qtype_essay');
     $mform->addElement('header', 'graderinfoheader', get_string('graderinfoheader', 'qtype_essay'));
     $mform->setExpanded('graderinfoheader');
     $mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_essay'), array('rows' => 10), $this->editoroptions);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:edit_essay_form.php


示例16: definition_inner

    /**
     * Add question-type specific form fields.
     *
     * @param object $mform the form being built.
     */
    protected function definition_inner($mform) {
        $menu = array(
            get_string('answersingleno', 'qtype_multichoice'),
            get_string('answersingleyes', 'qtype_multichoice'),
        );
        $mform->addElement('select', 'single',
                get_string('answerhowmany', 'qtype_multichoice'), $menu);
        $mform->setDefault('single', 1);

        $mform->addElement('advcheckbox', 'shuffleanswers',
                get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1));
        $mform->addHelpButton('shuffleanswers', 'shuffleanswers', 'qtype_multichoice');
        $mform->setDefault('shuffleanswers', 1);

        $mform->addElement('select', 'answernumbering',
                get_string('answernumbering', 'qtype_multichoice'),
                qtype_multichoice::get_numbering_styles());
        $mform->setDefault('answernumbering', 'abc');

        $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'),
                question_bank::fraction_options_full(), max(5, QUESTION_NUMANS_START));

        $this->add_combined_feedback_fields(true);
        $mform->disabledIf('shownumcorrect', 'single', 'eq', 1);

        $this->add_interactive_settings(true, true);
    }
开发者ID:Burick,项目名称:moodle,代码行数:32,代码来源:edit_multichoice_form.php


示例17: 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


示例18: 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


示例19: test_render_missing

 public function test_render_missing()
 {
     $records = new question_test_recordset(array(array('questionattemptid', 'contextid', 'questionusageid', 'slot', 'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged', 'questionsummary', 'rightanswer', 'responsesummary', 'timemodified', 'attemptstepid', 'sequencenumber', 'state', 'fraction', 'timecreated', 'userid', 'name', 'value'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, '_order', '1,2,3'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.5, 1256233705, 1, '-submit', '1'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.5, 1256233705, 1, 'choice0', '1')));
     $question = test_question_maker::make_question('truefalse', 'true');
     $question->id = -1;
     question_bank::start_unit_test();
     question_bank::load_test_question_data($question);
     $qa = question_attempt::load_from_records($records, 1, new question_usage_null_observer(), 'deferredfeedback');
     question_bank::end_unit_test();
     $this->assertEquals(2, $qa->get_num_steps());
     $step = $qa->get_step(0);
     $this->assertEquals(question_state::$todo, $step->get_state());
     $this->assertNull($step->get_fraction());
     $this->assertEquals(1256233700, $step->get_timecreated());
     $this->assertEquals(1, $step->get_user_id());
     $this->assertEquals(array('_order' => '1,2,3'), $step->get_all_data());
     $step = $qa->get_step(1);
     $this->assertEquals(question_state::$complete, $step->get_state());
     $this->assertEquals(0.5, $step->get_fraction());
     $this->assertEquals(1256233705, $step->get_timecreated());
     $this->assertEquals(1, $step->get_user_id());
     $this->assertEquals(array('-submit' => '1', 'choice0' => '1'), $step->get_all_data());
     $output = $qa->render(new question_display_options(), '1');
     $this->assertRegExp('/' . preg_quote($qa->get_question()->questiontext, '/') . '/', $output);
     $this->assertRegExp('/' . preg_quote(get_string('questionusedunknownmodel', 'qbehaviour_missing'), '/') . '/', $output);
     $this->assertTag(array('tag' => 'div', 'attributes' => array('class' => 'warning')), $output);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:missingbehaviour_test.php


示例20: definition_inner

 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 protected function definition_inner($mform)
 {
     $mform->removeElement('defaultmark');
     $mform->addElement('hidden', 'defaultmark', '1');
     $mform->removeElement('generalfeedback');
     $mform->addElement('advcheckbox', 'autoplay', get_string('autoplay', 'qtype_turmultiplechoice'), null, null, array(0, 1));
     $mform->addHelpButton('autoplay', 'autoplay', 'qtype_turmultiplechoice');
     $mform->setDefault('autoplay', 0);
     $menu = array(get_string('answersingleno', 'qtype_turmultiplechoice'), get_string('answersingleyes', 'qtype_turmultiplechoice'));
     $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_turmultiplechoice'), $menu);
     $mform->setDefault('single', 0);
     // 'Image to display' filemanager
     $mform->addElement('filemanager', 'questionimage', 'Image to display', null, array('maxfiles' => 1));
     // TODO: Use lang string
     // 'Choose soundfile for question' filemanager
     $mform->addElement('filemanager', 'questionsound', 'Choose soundfile for question', null, array('maxfiles' => 1, 'accepted_types' => array('.mp3')));
     // TODO: Use lang string
     $question_difficulties = array();
     $question_difficulties[0] = get_string('q_easy1', 'qtype_turmultiplechoice');
     $question_difficulties[1] = get_string('q_easy2', 'qtype_turmultiplechoice');
     $question_difficulties[2] = get_string('q_easy3', 'qtype_turmultiplechoice');
     $question_difficulties[3] = get_string('q_medium1', 'qtype_turmultiplechoice');
     $question_difficulties[4] = get_string('q_medium2', 'qtype_turmultiplechoice');
     $question_difficulties[5] = get_string('q_medium3', 'qtype_turmultiplechoice');
     $question_difficulties[6] = get_string('q_hard1', 'qtype_turmultiplechoice');
     $question_difficulties[7] = get_string('q_hard2', 'qtype_turmultiplechoice');
     $question_difficulties[8] = get_string('q_hard3', 'qtype_turmultiplechoice');
     $mform->addElement('select', 'qdifficulty', get_string('qdifficulty', 'qtype_turmultiplechoice'), $question_difficulties);
     $mform->setDefault('qdifficulty', 0);
     $mform->addElement('hidden', 'shuffleanswers', 1);
     $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_turmultiplechoice', '{no}'), question_bank::fraction_options_full(), max(4, QUESTION_NUMANS_START), 4);
     $this->add_combined_feedback_fields(true);
     $mform->disabledIf('shownumcorrect', 'single', 'eq', 1);
 }
开发者ID:edwinphillips,项目名称:turmultiplechoice_2.2,代码行数:39,代码来源:edit_turmultiplechoice_form.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP question_classified_response类代码示例发布时间:2022-05-23
下一篇:
PHP question_attempt_step类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap