當前位置: 首頁>>代碼示例>>PHP>>正文


PHP question_type類代碼示例

本文整理匯總了PHP中question_type的典型用法代碼示例。如果您正苦於以下問題:PHP question_type類的具體用法?PHP question_type怎麽用?PHP question_type使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了question_type類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initialise_question_instance

    protected function initialise_question_instance(question_definition $question, $questiondata) {
        question_type::initialise_question_instance($question, $questiondata);

        $question->shuffleanswers = $questiondata->options->shuffleanswers;
        $question->answernumbering = $questiondata->options->answernumbering;
        if (!empty($questiondata->options->layout)) {
            $question->layout = $questiondata->options->layout;
        } else {
            $question->layout = qtype_multichoice_single_question::LAYOUT_VERTICAL;
        }

        $question->synchronised = $questiondata->options->synchronize;

        $this->initialise_combined_feedback($question, $questiondata, true);
        $this->initialise_question_answers($question, $questiondata);

        foreach ($questiondata->options->answers as $a) {
            $question->answers[$a->id]->correctanswerlength = $a->correctanswerlength;
            $question->answers[$a->id]->correctanswerformat = $a->correctanswerformat;
        }

        $question->datasetloader = new qtype_calculated_dataset_loader($questiondata->id);
    }
開發者ID:JP-Git,項目名稱:moodle,代碼行數:23,代碼來源:questiontype.php

示例2: save_question

 public function save_question($question, $form)
 {
     // Make very sure that descriptions can'e be created with a grade of
     // anything other than 0.
     $form->defaultmark = 0;
     return parent::save_question($question, $form);
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:7,代碼來源:questiontype.php

示例3: save_question_options

 public function save_question_options($question)
 {
     global $DB;
     $result = new stdClass();
     $context = $question->context;
     $question->feedbackperconditions = rtrim(str_replace("\r\n", "\n", $question->feedbackperconditions), "\n");
     $question->conditions = rtrim(str_replace("\r\n", "\n", $question->conditions), "\n");
     $parentresult = parent::save_question_options($question);
     if ($parentresult !== null) {
         // Parent function returns null if all is OK
         return $parentresult;
     }
     $this->save_hints($question);
     return $parentresult;
 }
開發者ID:ndunand,項目名稱:moodle-qtype_multinumerical,代碼行數:15,代碼來源:questiontype.php

示例4: foreach

 function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     global $COURSE;
     if ($extra !== null) {
         throw new coding_exception("coderunner:export_to_xml: Unexpected parameter");
     }
     // Copy the question so we can modify it for export
     // (Just in case the original gets used elsewhere).
     $questiontoexport = clone $question;
     $qtype = $question->options->coderunnertype;
     $coursecontext = context_course::instance($COURSE->id);
     $row = self::get_prototype($qtype, $coursecontext);
     // Clear all inherited fields equal in value to the corresponding Prototype field
     // (but only if this is not a prototype question itself)
     if ($questiontoexport->options->prototypetype == 0) {
         $noninheritedfields = $this->noninherited_fields();
         $extrafields = $this->extra_question_fields();
         foreach ($row as $field => $value) {
             if (in_array($field, $extrafields) && !in_array($field, $noninheritedfields) && $question->options->{$field} === $value) {
                 $questiontoexport->options->{$field} = null;
             }
         }
     }
     $expout = parent::export_to_xml($questiontoexport, $format, $extra);
     $expout .= "    <testcases>\n";
     foreach ($question->options->testcases as $testcase) {
         $useasexample = $testcase->useasexample ? 1 : 0;
         $hiderestiffail = $testcase->hiderestiffail ? 1 : 0;
         $mark = sprintf("%.7f", $testcase->mark);
         $expout .= "      <testcase useasexample=\"{$useasexample}\" hiderestiffail=\"{$hiderestiffail}\" mark=\"{$mark}\" >\n";
         foreach (array('testcode', 'stdin', 'expected', 'extra', 'display') as $field) {
             $exportedValue = $format->writetext($testcase->{$field}, 4);
             $expout .= "      <{$field}>\n        {$exportedValue}      </{$field}>\n";
         }
         $expout .= "    </testcase>\n";
     }
     // Add datafiles within the scope of the <testcases> element
     $fs = get_file_storage();
     $contextid = $question->contextid;
     $datafiles = $fs->get_area_files($contextid, 'qtype_coderunner', 'datafile', $question->id);
     $expout .= $format->write_files($datafiles);
     $expout .= "    </testcases>\n";
     return $expout;
 }
開發者ID:pac,項目名稱:CodeRunner,代碼行數:44,代碼來源:questiontype.php

示例5: save_question

 public function save_question($question, $form) {
     $form->name = '';
     // Name is not a required field for random questions, but
     // parent::save_question Assumes that it is.
     return parent::save_question($question, $form);
 }
開發者ID:nottmoo,項目名稱:moodle,代碼行數:6,代碼來源:questiontype.php

示例6: initialise_question_instance

 /**
  * Initialise the common question_definition fields.
  * 
  * @param question_definition $question the question_definition we are creating.
  * @param object $questiondata the question data loaded from the database.
  */
 protected function initialise_question_instance(question_definition $question, $questiondata)
 {
     parent::initialise_question_instance($question, $questiondata);
     $question->rows = $questiondata->options->rows;
     $question->cols = $questiondata->options->cols;
     $question->weights = $questiondata->options->weights;
     $question->grademethod = $questiondata->options->grademethod;
     $question->multiple = $questiondata->options->multiple;
 }
開發者ID:sunilwebaccess,項目名稱:moodle-question-matrix,代碼行數:15,代碼來源:questiontype.php

示例7: delete_files

 protected function delete_files($questionid, $contextid)
 {
     $fs = get_file_storage();
     parent::delete_files($questionid, $contextid);
     $this->delete_files_in_answers($questionid, $contextid, true);
     $fs->delete_area_files($contextid, 'question', 'correctfeedback', $questionid);
     $fs->delete_area_files($contextid, 'question', 'incorrectfeedback', $questionid);
 }
開發者ID:parksandwildlife,項目名稱:learning,代碼行數:8,代碼來源:questiontype.php

示例8: delete_files

    protected function delete_files($questionid, $contextid) {
        global $DB;
        $fs = get_file_storage();

        parent::delete_files($questionid, $contextid);

        $subquestionids = $DB->get_records_menu('question_match_sub',
                array('question' => $questionid), 'id', 'id,1');
        foreach ($subquestionids as $subquestionid => $notused) {
            $fs->delete_area_files($contextid, 'qtype_match', 'subquestion', $subquestionid);
        }

        $this->delete_files_in_combined_feedback($questionid, $contextid);
    }
開發者ID:nigeldaley,項目名稱:moodle,代碼行數:14,代碼來源:questiontype.php

示例9: save_question

 public function save_question($question, $form)
 {
     $form->name = '';
     // In case someone set the question text to true/false in the old style, set it properly.
     if ($form->questiontext['text']) {
         $form->questiontext['text'] = '1';
     } else {
         $form->questiontext['text'] = '0';
     }
     $form->tags = array();
     // Name is not a required field for random questions, but
     // parent::save_question Assumes that it is.
     return parent::save_question($question, $form);
 }
開發者ID:abhilash1994,項目名稱:moodle,代碼行數:14,代碼來源:questiontype.php

示例10: delete_files

 protected function delete_files($questionid, $contextid)
 {
     global $DB;
     $fs = get_file_storage();
     parent::delete_files($questionid, $contextid);
 }
開發者ID:jacac,項目名稱:qtype_order,代碼行數:6,代碼來源:questiontype.php

示例11: make_question

 public function make_question($questiondata)
 {
     $question = parent::make_question($questiondata);
     $question->questiontext = html_writer::tag('div', get_string('missingqtypewarning', 'qtype_missingtype'), array('class' => 'warning missingqtypewarning')) . $question->questiontext;
     return $question;
 }
開發者ID:EmmanuelYupit,項目名稱:educursos,代碼行數:6,代碼來源:questiontype.php

示例12: save_question

 public function save_question($question, $form)
 {
     $form->name = '';
     $form->questiontextformat = FORMAT_MOODLE;
     $form->tags = array();
     // Name is not a required field for random questions, but
     // parent::save_question Assumes that it is.
     return parent::save_question($question, $form);
 }
開發者ID:tyleung,項目名稱:CMPUT401MoodleExams,代碼行數:9,代碼來源:questiontype.php

示例13: initialise_question_instance

 protected function initialise_question_instance(question_definition $question, $questiondata)
 {
     // TODO.
     parent::initialise_question_instance($question, $questiondata);
 }
開發者ID:edwinp-catalyst-eu,項目名稱:moodle-qtype_TEMPLATE,代碼行數:5,代碼來源:questiontype.php

示例14: delete_files

 protected function delete_files($questionid, $contextid)
 {
     global $DB;
     $fs = get_file_storage();
     parent::delete_files($questionid, $contextid);
     $subquestionids = $DB->get_records_menu('question_order_sub', array('question' => $questionid), 'id', 'id,1');
     foreach ($subquestionids as $subquestionid => $notused) {
         $fs->delete_area_files($contextid, 'qtype_order', 'subquestion', $subquestionid);
     }
     $fs->delete_area_files($contextid, 'qtype_multichoice', 'correctfeedback', $questionid);
     $fs->delete_area_files($contextid, 'qtype_multichoice', 'partiallycorrectfeedback', $questionid);
     $fs->delete_area_files($contextid, 'qtype_multichoice', 'incorrectfeedback', $questionid);
 }
開發者ID:nadavkav,項目名稱:Moodle2-Hebrew-plugins,代碼行數:13,代碼來源:questiontype.php

示例15: delete_files

 protected function delete_files($questionid, $contextid)
 {
     parent::delete_files($questionid, $contextid);
     $fs = get_file_storage();
     $fs->delete_area_files($contextid, 'qtype_javaunittest', 'graderinfo', $questionid);
 }
開發者ID:printz81,項目名稱:javaunittest,代碼行數:6,代碼來源:questiontype.php


注:本文中的question_type類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。