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


PHP question_edit_form类代码示例

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


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

示例1: array

 function set_data($question)
 {
     if (!empty($question->options->trueanswer)) {
         $trueanswer = $question->options->answers[$question->options->trueanswer];
         $draftid = file_get_submitted_draft_itemid('trueanswer');
         $answerid = $question->options->trueanswer;
         $text = $trueanswer->feedback;
         $question->correctanswer = $trueanswer->fraction != 0;
         $question->feedbacktrue = array();
         $question->feedbacktrue['text'] = $trueanswer->feedback;
         $question->feedbacktrue['format'] = $trueanswer->feedbackformat;
         $question->feedbacktrue['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answerid) ? (int) $answerid : null, $this->fileoptions, $text);
         $question->feedbacktrue['itemid'] = $draftid;
     }
     if (!empty($question->options->falseanswer)) {
         $falseanswer = $question->options->answers[$question->options->falseanswer];
         $draftid = file_get_submitted_draft_itemid('falseanswer');
         $answerid = $question->options->falseanswer;
         $text = $falseanswer->feedback;
         $question->feedbackfalse = array();
         $question->feedbackfalse['text'] = $falseanswer->feedback;
         $question->feedbackfalse['format'] = $falseanswer->feedbackformat;
         $question->feedbackfalse['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answerid) ? (int) $answerid : null, $this->fileoptions, $text);
         $question->feedbackfalse['itemid'] = $draftid;
     }
     parent::set_data($question);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:27,代码来源:edit_truefalse_form.php

示例2: validation

 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $answers = $data['subanswers'];
     $questions = $data['subquestions'];
     $questioncount = 0;
     $answercount = 0;
     foreach ($questions as $key => $question) {
         $trimmedquestion = trim($question);
         $trimmedanswer = trim($answers[$key]);
         if ($trimmedquestion != '') {
             $questioncount++;
         }
         if ($trimmedanswer != '' || $trimmedquestion != '') {
             $answercount++;
         }
         if ($trimmedquestion != '' && $trimmedanswer == '') {
             $errors['subanswers[' . $key . ']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
         }
     }
     $numberqanda = new stdClass();
     $numberqanda->q = 2;
     $numberqanda->a = 3;
     if ($questioncount < 1) {
         $errors['subquestions[0]'] = get_string('notenoughqsandas', 'qtype_match', $numberqanda);
     }
     if ($questioncount < 2) {
         $errors['subquestions[1]'] = get_string('notenoughqsandas', 'qtype_match', $numberqanda);
     }
     if ($answercount < 3) {
         $errors['subanswers[2]'] = get_string('notenoughqsandas', 'qtype_match', $numberqanda);
     }
     return $errors;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:34,代码来源:edit_match_form.php

示例3: validation

 function validation($data, $files)
 {
     global $QTYPES;
     $errors = parent::validation($data, $files);
     // Check the answers.
     $answercount = 0;
     $maxgrade = false;
     $answers = $data['answer'];
     foreach ($answers as $key => $answer) {
         $trimmedanswer = trim($answer);
         if ($trimmedanswer != '') {
             $answercount++;
             if (!(is_numeric($trimmedanswer) || $trimmedanswer == '*')) {
                 $errors["answer[{$key}]"] = get_string('answermustbenumberorstar', 'qtype_numerical');
             }
             if ($data['fraction'][$key] == 1) {
                 $maxgrade = true;
             }
         } else {
             if ($data['fraction'][$key] != 0 || !html_is_blank($data['feedback'][$key]['text'])) {
                 $errors["answer[{$key}]"] = get_string('answermustbenumberorstar', 'qtype_numerical');
                 $answercount++;
             }
         }
     }
     if ($answercount == 0) {
         $errors['answer[0]'] = get_string('notenoughanswers', 'qtype_numerical');
     }
     if ($maxgrade == false) {
         $errors['fraction[0]'] = get_string('fractionsnomax', 'question');
     }
     $QTYPES['numerical']->validate_numerical_options($data, $errors);
     return $errors;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:34,代码来源:edit_numerical_form.php

示例4: validation

 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $answers = $data['answer'];
     $answercount = 0;
     $maxgrade = false;
     foreach ($answers as $key => $answer) {
         $trimmedanswer = trim($answer);
         if ($trimmedanswer !== '') {
             $answercount++;
             if ($data['fraction'][$key] == 1) {
                 $maxgrade = true;
             }
         } else {
             if ($data['fraction'][$key] != 0 || !html_is_blank($data['feedback'][$key]['text'])) {
                 $errors["answer[{$key}]"] = get_string('answermustbegiven', 'qtype_shortanswer');
                 $answercount++;
             }
         }
     }
     if ($answercount == 0) {
         $errors['answer[0]'] = get_string('notenoughanswers', 'qtype_shortanswer', 1);
     }
     if ($maxgrade == false) {
         $errors['fraction[0]'] = get_string('fractionsnomax', 'question');
     }
     return $errors;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:28,代码来源:edit_shortanswer_form.php

示例5:

 function set_data($question)
 {
     if (empty($question->name)) {
         $question->name = get_string("random", "quiz");
     }
     parent::set_data($question);
 }
开发者ID:veritech,项目名称:pare-project,代码行数:7,代码来源:edit_random_form.php

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

示例7: data_preprocessing

 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     if (empty($question->options)) {
         return $question;
     }
     $question->responseformat = $question->options->responseformat;
     $question->responsefieldlines = $question->options->responsefieldlines;
     $question->attachments = $question->options->attachments;
     $question->boardsize = $question->options->boardsize;
     //Set backimage details, and configure a draft area to accept any uploaded pictures
     //all this and this whole method does, is to load existing files into a filearea
     //so it is not called when creating a new question, only when editing an existing one
     //best to use file_get_submitted_draft_itemid - because copying questions gets weird otherwise
     //$draftitemid =$question->options->backimage;
     $draftitemid = file_get_submitted_draft_itemid('backimage');
     file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_poodllrecording', 'backimage', !empty($question->id) ? (int) $question->id : null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
     $question->backimage = $draftitemid;
     $draftid = file_get_submitted_draft_itemid('graderinfo');
     $question->graderinfo = array();
     $question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
     $question->graderinfo['format'] = $question->options->graderinfoformat;
     $question->graderinfo['itemid'] = $draftid;
     return $question;
 }
开发者ID:laiello,项目名称:poodll.poodll2,代码行数:25,代码来源:edit_poodllrecording_form.php

示例8: data_preprocessing

    protected function data_preprocessing($question) {
        $question = parent::data_preprocessing($question);

        if (empty($question->options)) {
            return $question;
        }

        $question->responseformat = $question->options->responseformat;
        $question->responsefieldlines = $question->options->responsefieldlines;
        $question->attachments = $question->options->attachments;

        $draftid = file_get_submitted_draft_itemid('graderinfo');
        $question->graderinfo = array();
        $question->graderinfo['text'] = file_prepare_draft_area(
            $draftid,           // draftid
            $this->context->id, // context
            'qtype_essay',      // component
            'graderinfo',       // filarea
            !empty($question->id) ? (int) $question->id : null, // itemid
            $this->fileoptions, // options
            $question->options->graderinfo // text
        );
        $question->graderinfo['format'] = $question->options->graderinfoformat;
        $question->graderinfo['itemid'] = $draftid;
        $question->responselimitpolicy = $question->options->responselimitpolicy;
        $question->wordlimit = $question->options->wordlimit;
        $question->charlimit = $question->options->charlimit;

        return $question;
    }
开发者ID:nickkoeppen,项目名称:moodle,代码行数:30,代码来源:edit_essay_form.php

示例9: validation

 function validation($data)
 {
     $errors = parent::validation($data);
     $answers = $data['subanswers'];
     $questions = $data['subquestions'];
     $questioncount = 0;
     foreach ($questions as $key => $question) {
         $trimmedquestion = trim($question);
         $trimmedanswer = trim($answers[$key]);
         if (!empty($trimmedanswer) && !empty($trimmedquestion)) {
             $questioncount++;
         }
         if (!empty($trimmedquestion) && empty($trimmedanswer)) {
             $errors['subanswers[' . $key . ']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
         }
     }
     if ($questioncount == 0) {
         $errors['subquestions[0]'] = get_string('notenoughquestions', 'qtype_match', 3);
         $errors['subquestions[1]'] = get_string('notenoughquestions', 'qtype_match', 3);
         $errors['subquestions[2]'] = get_string('notenoughquestions', 'qtype_match', 3);
     } elseif ($questioncount == 1) {
         $errors['subquestions[1]'] = get_string('notenoughquestions', 'qtype_match', 3);
         $errors['subquestions[2]'] = get_string('notenoughquestions', 'qtype_match', 3);
     } elseif ($questioncount == 2) {
         $errors['subquestions[2]'] = get_string('notenoughquestions', 'qtype_match', 3);
     }
     return $errors;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:28,代码来源:edit_match_form.php

示例10: validation

 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $answers = $data['answer'];
     $answercount = 0;
     $totalfraction = 0;
     $maxfraction = -1;
     foreach ($answers as $key => $answer) {
         //check no of choices
         $trimmedanswer = trim($answer);
         if (!empty($trimmedanswer)) {
             $answercount++;
         }
         //check grades
         if ($answer != '') {
             if ($data['fraction'][$key] > 0) {
                 $totalfraction += $data['fraction'][$key];
             }
             if ($data['fraction'][$key] > $maxfraction) {
                 $maxfraction = $data['fraction'][$key];
             }
         }
     }
     if ($answercount == 0) {
         $errors['answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 1);
     }
     $totalfraction = round($totalfraction, 2);
     if ($totalfraction != 1) {
         $totalfraction = $totalfraction * 100;
         $errors['fraction[0]'] = get_string('errfractionsaddwrong', 'qtype_multichoice', $totalfraction);
     }
     return $errors;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:33,代码来源:edit_missingtype_form.php

示例11: reset

 function set_data($question)
 {
     if (!empty($question->options) && !empty($question->options->answers)) {
         $answer = reset($question->options->answers);
         $question->feedback = $answer->feedback;
     }
     $question->penalty = 0;
     parent::set_data($question);
 }
开发者ID:kai707,项目名称:ITSA-backup,代码行数:9,代码来源:edit_essay_form.php

示例12:

 function set_data($question)
 {
     if (empty($question->name)) {
         $question->name = get_string("randomsamatch", "quiz");
     }
     if (empty($question->questiontext)) {
         $question->questiontext = get_string("randomsamatchintro", "quiz");
     }
     parent::set_data($question);
 }
开发者ID:veritech,项目名称:pare-project,代码行数:10,代码来源:edit_randomsamatch_form.php

示例13:

 function set_data($question)
 {
     if (!empty($question->options->trueanswer)) {
         $trueanswer = $question->options->answers[$question->options->trueanswer];
         $question->correctanswer = $trueanswer->fraction != 0;
         $question->feedbacktrue = $trueanswer->feedback;
         $question->feedbackfalse = $question->options->answers[$question->options->falseanswer]->feedback;
     }
     parent::set_data($question);
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:10,代码来源:edit_truefalse_form.php

示例14: reset

 function set_data($question)
 {
     if (!empty($question->options)) {
         $question->essay = $question->options->essay;
         $question->maxbytes = $question->options->maxbytes;
         if (!empty($question->options->answers)) {
             $answer = reset($question->options->answers);
             $question->feedback = $answer->feedback;
         }
     }
     $question->penalty = 0;
     parent::set_data($question);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:13,代码来源:edit_imagedit_form.php

示例15: data_preprocessing

 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     if (empty($question->options)) {
         return $question;
     }
     $question->responseformat = $question->options->responseformat;
     $question->responsefieldlines = $question->options->responsefieldlines;
     $question->attachments = $question->options->attachments;
     $draftid = file_get_submitted_draft_itemid('graderinfo');
     $question->graderinfo = array();
     $question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
     $question->graderinfo['format'] = $question->options->graderinfoformat;
     $question->graderinfo['itemid'] = $draftid;
     return $question;
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:16,代码来源:edit_poodllrecording_form.php


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