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

PHP question_utils类代码示例

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

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



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

示例1: is_same_response

 /** This function is used by the question engine to prevent regrading of
  *  unchanged submissions.
  *
  * @param array $prevresponse
  * @param array $newresponse
  * @return boolean
  */
 public function is_same_response(array $prevresponse, array $newresponse)
 {
     if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer') || !question_utils::arrays_same_at_key_integer($prevresponse, $newresponse, 'rating')) {
         return false;
     }
     return true;
 }
开发者ID:pac,项目名称:CodeRunner,代码行数:14,代码来源:question.php


示例2: quiz_question_tostring

/**
 * Creates a textual representation of a question for display.
 *
 * @param object $question A question object from the database questions table
 * @param bool $showicon If true, show the question's icon with the question. False by default.
 * @param bool $showquestiontext If true (default), show question text after question name.
 *       If false, show only question name.
 * @param bool $return If true (default), return the output. If false, print it.
 */
function quiz_question_tostring($question, $showicon = false, $showquestiontext = true, $return = true)
{
    global $COURSE;
    $result = '';
    $result .= '<span class="questionname">';
    if ($showicon) {
        $result .= print_question_icon($question, true);
        echo ' ';
    }
    $result .= shorten_text(format_string($question->name), 200) . '</span>';
    if ($showquestiontext) {
        $questiontext = question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false));
        $questiontext = shorten_text($questiontext, 200);
        $result .= '<span class="questiontext">';
        if (!empty($questiontext)) {
            $result .= s($questiontext);
        } else {
            $result .= '<span class="error">';
            $result .= get_string('questiontextisempty', 'quiz');
            $result .= '</span>';
        }
        $result .= '</span>';
    }
    if ($return) {
        return $result;
    } else {
        echo $result;
    }
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:38,代码来源:editlib.php


示例3: validate_manual_mark

 /**
  * Validate the manual mark for a question.
  * @param unknown $currentmark the user input (e.g. '1,0', '1,0' or 'invalid'.
  * @return string any errors with the value, or '' if it is OK.
  */
 public function validate_manual_mark($currentmark)
 {
     if ($currentmark === null || $currentmark === '') {
         return '';
     }
     $mark = question_utils::clean_param_mark($currentmark);
     if ($mark === null) {
         return get_string('manualgradeinvalidformat', 'question');
     }
     $maxmark = $this->get_max_mark();
     if ($mark > $maxmark * $this->get_max_fraction() || $mark < $maxmark * $this->get_min_fraction()) {
         return get_string('manualgradeoutofrange', 'question');
     }
     return '';
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:questionattempt.php


示例4: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     foreach ($this->places as $place => $notused) {
         $fieldname = $this->field($place);
         if (!question_utils::arrays_same_at_key_integer($prevresponse, $newresponse, $fieldname)) {
             return false;
         }
     }
     return true;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:10,代码来源:questionbase.php


示例5: number_answer

 /**
  * @param int $num The number, starting at 0.
  * @param string $style The style to render the number in. One of the
  * options returned by {@link qtype_multichoice:;get_numbering_styles()}.
  * @return string the number $num in the requested style.
  */
 public static function number_answer($num, $style)
 {
     switch ($style) {
         case 'abc':
             $number = chr(ord('a') + $num);
             break;
         case 'ABCD':
             $number = chr(ord('A') + $num);
             break;
         case '123':
             $number = $num + 1;
             break;
         case 'iii':
             $number = question_utils::int_to_roman($num + 1);
             break;
         case 'IIII':
             $number = strtoupper(question_utils::int_to_roman($num + 1));
             break;
         case 'none':
             return '';
         default:
             return 'ERR';
     }
     return "({$number})";
 }
开发者ID:kikkomep,项目名称:moodle.omero-qtypes,代码行数:31,代码来源:renderer.php


示例6: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer')) {
         return false;
     }
     if ($this->has_separate_unit_field()) {
         return question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'unit');
     }
     return true;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:10,代码来源:question.php


示例7: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse) {
     foreach ($this->order as $key => $notused) {
         $fieldname = $this->field($key);
         if (!question_utils::arrays_same_at_key($prevresponse, $newresponse, $fieldname)) {
             return false;
         }
     }
     return true;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:9,代码来源:question.php


示例8: get_submitted_var

    /**
     * Get a particular parameter from the current request. A wrapper round
     * {@link optional_param()}, except that the results is returned without
     * slashes.
     * @param string $name the paramter name.
     * @param int $type one of the standard PARAM_... constants, or one of the
     *      special extra constands defined by this class.
     * @param array $postdata (optional, only inteded for testing use) take the
     *      data from this array, instead of from $_POST.
     * @return mixed the requested value.
     */
    public function get_submitted_var($name, $type, $postdata = null) {
        switch ($type) {
            case self::PARAM_MARK:
                // Special case to work around PARAM_FLOAT converting '' to 0.
                return question_utils::clean_param_mark($this->get_submitted_var($name, PARAM_RAW_TRIMMED, $postdata));

            case self::PARAM_FILES:
                return $this->process_response_files($name, $name, $postdata);

            case self::PARAM_RAW_FILES:
                $var = $this->get_submitted_var($name, PARAM_RAW, $postdata);
                return $this->process_response_files($name, $name . ':itemid', $postdata, $var);

            default:
                if (is_null($postdata)) {
                    $var = optional_param($name, null, $type);
                } else if (array_key_exists($name, $postdata)) {
                    $var = clean_param($postdata[$name], $type);
                } else {
                    $var = null;
                }

                return $var;
        }
    }
开发者ID:Burick,项目名称:moodle,代码行数:36,代码来源:questionattempt.php


示例9: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     foreach ($this->get_parameters() as $param) {
         if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer_' . $param)) {
             return false;
         }
     }
     return true;
 }
开发者ID:ndunand,项目名称:moodle-qtype_multinumerical,代码行数:9,代码来源:question.php


示例10: modify_questionresults_duringquiz

 /**
  * Updating output to include a graph of multiple choice answer possibilities
  * with the percentage of students that answered that option
  *
  * @param \mod_activequiz\activequiz_question $question The realtime quiz question
  * @param array                               $attempts An array of \mod_activequiz\activequiz_attempt classes
  * @param string                              $output The current output from getting the results
  * @return string Return the updated output to be passed to the client
  */
 public function modify_questionresults_duringquiz($question, $attempts, $output)
 {
     global $DB;
     // store the possible answersid as the key of the array, and then a count
     //  for the number of times it was answered
     $answers = array();
     $dbanswers = array();
     foreach ($attempts as $attempt) {
         /** @var \mod_activequiz\activequiz_attempt $attempt */
         // only count attempts where they have "responded"
         if ($attempt->responded == 0) {
             continue;
         }
         $quba = $attempt->get_quba();
         $slot = $attempt->get_question_slot($question);
         $qa = $quba->get_question_attempt($slot);
         // now get question definition
         $questiondef = $qa->get_question();
         // if dbanswers is empty get them from the question definition (as this will be the same for all attempts for this slot
         // also save a db query
         if (empty($dbanswers)) {
             $dbanswers = $questiondef->answers;
         }
         // single and multi answers are handled differently for steps
         if ($questiondef instanceof \qtype_multichoice_single_question) {
             $this->update_answers_single($answers, $qa, $questiondef);
         } else {
             if ($questiondef instanceof \qtype_multichoice_multi_question) {
                 $this->update_answers_multi($answers, $qa, $questiondef);
             } else {
             }
         }
     }
     $xaxis = array();
     foreach ($dbanswers as $dbanswer) {
         $xaxis[$dbanswer->id] = \question_utils::to_plain_text($dbanswer->answer, $dbanswer->answerformat);
     }
     $newoutput = $this->add_chart($output, $xaxis, $answers);
     return $newoutput;
 }
开发者ID:agarnav,项目名称:moodle-mod_activequiz,代码行数:49,代码来源:multichoice.php


示例11: is_same_response

    public function is_same_response(array $prevresponse, array $newresponse) {
        if (!question_utils::arrays_same_at_key_missing_is_blank(
                $prevresponse, $newresponse, 'answer')) {
            return false;
        }

        if ($this->unitdisplay == qtype_numerical::UNITSELECT) {
            return question_utils::arrays_same_at_key_missing_is_blank(
                $prevresponse, $newresponse, 'unit');
        }

        return false;
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:13,代码来源:question.php


示例12: summarise_manual_comment

 /**
  * @return string a summary of a manual comment action.
  * @param unknown_type $step
  */
 protected function summarise_manual_comment($step)
 {
     $a = new stdClass();
     if ($step->has_behaviour_var('comment')) {
         $a->comment = shorten_text(html_to_text($this->format_comment($step->get_behaviour_var('comment')), 0, false), 200);
     } else {
         $a->comment = '';
     }
     $mark = question_utils::clean_param_mark($step->get_behaviour_var('mark'));
     if (is_null($mark) || $mark === '') {
         return get_string('commented', 'question', $a->comment);
     } else {
         $a->mark = $mark / $step->get_behaviour_var('maxmark') * $this->qa->get_max_mark();
         return get_string('manuallygraded', 'question', $a);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:behaviourbase.php


示例13: render_question_text_plain

 /**
  * @param object $question question data.
  * @return string HTML of question text, ready for display.
  */
 protected function render_question_text_plain($question, $showimages = true)
 {
     global $OUTPUT;
     if ($showimages) {
         $text = question_rewrite_question_preview_urls($question->questiontext, $question->id, $question->contextid, 'question', 'questiontext', $question->id, $this->context->id, 'quiz_statistics');
     } else {
         $text = $question->questiontext;
     }
     $questiontext = question_utils::to_plain_text($text, $question->questiontextformat, array('noclean' => true, 'para' => false, 'overflowdiv' => true));
     return '&nbsp;&nbsp;&nbsp;' . $questiontext;
 }
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:15,代码来源:report.php


示例14: quiz_question_tostring

/**
 * Creates a textual representation of a question for display.
 *
 * @param object $question A question object from the database questions table
 * @param bool $showicon If true, show the question's icon with the question. False by default.
 * @param bool $showquestiontext If true (default), show question text after question name.
 *       If false, show only question name.
 * @return string
 */
function quiz_question_tostring($question, $showicon = false, $showquestiontext = true)
{
    $result = '';
    $name = shorten_text(format_string($question->name), 200);
    if ($showicon) {
        $name .= print_question_icon($question) . ' ' . $name;
    }
    $result .= html_writer::span($name, 'questionname');
    if ($showquestiontext) {
        $questiontext = question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false));
        $questiontext = shorten_text($questiontext, 200);
        if ($questiontext) {
            $result .= ' ' . html_writer::span(s($questiontext), 'questiontext');
        }
    }
    return $result;
}
开发者ID:aleph-n,项目名称:lms.aaenl,代码行数:26,代码来源:locallib.php


示例15: get_possible_responses

 public function get_possible_responses($questiondata)
 {
     if ($questiondata->options->single) {
         $responses = array();
         foreach ($questiondata->options->answers as $aid => $answer) {
             $responses[$aid] = new question_possible_response(question_utils::to_plain_text($answer->answer, $answer->answerformat), $answer->fraction);
         }
         $responses[null] = question_possible_response::no_response();
         return array($questiondata->id => $responses);
     } else {
         $parts = array();
         foreach ($questiondata->options->answers as $aid => $answer) {
             $parts[$aid] = array($aid => new question_possible_response(question_utils::to_plain_text($answer->answer, $answer->answerformat), $answer->fraction));
         }
         return $parts;
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:17,代码来源:questiontype.php


示例16: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     return question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer');
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:4,代码来源:question.php


示例17: offlinequiz_question_tostring

/**
 * Creates a textual representation of a question for display.
 *
 * @param object $question A question object from the database questions table
 * @param bool $showicon If true, show the question's icon with the question. False by default.
 * @param bool $showquestiontext If true (default), show question text after question name.
 *       If false, show only question name.
 * @param bool $return If true (default), return the output. If false, print it.
 */
function offlinequiz_question_tostring($question, $showicon = false, $showquestiontext = true, $return = true, $shorttitle = false)
{
    global $COURSE;
    $result = '';
    $formatoptions = new stdClass();
    $formatoptions->noclean = true;
    $formatoptions->para = false;
    $questiontext = strip_tags(question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false)));
    $questiontitle = strip_tags(format_text($question->name, $question->questiontextformat, $formatoptions, $COURSE->id));
    $result .= '<span class="questionname" title="' . $questiontitle . '">';
    if ($shorttitle && strlen($questiontitle) > 25) {
        $questiontitle = shorten_text($questiontitle, 25, false, '...');
    }
    if ($showicon) {
        $result .= print_question_icon($question, true);
        echo ' ';
    }
    if ($shorttitle) {
        $result .= $questiontitle;
    } else {
        $result .= shorten_text(format_string($question->name), 200) . '</span>';
    }
    if ($showquestiontext) {
        $result .= '<span class="questiontext" title="' . $questiontext . '">';
        $questiontext = shorten_text($questiontext, 200);
        if (!empty($questiontext)) {
            $result .= $questiontext;
        } else {
            $result .= '<span class="error">';
            $result .= get_string('questiontextisempty', 'offlinequiz');
            $result .= '</span>';
        }
        $result .= '</span>';
    }
    if ($return) {
        return $result;
    } else {
        echo $result;
    }
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:49,代码来源:locallib.php


示例18: html_to_text

 /**
  * Convert some part of the question text to plain text. This might be used,
  * for example, by get_response_summary().
  * @param string $text The HTML to reduce to plain text.
  * @param int $format the FORMAT_... constant.
  * @return string the equivalent plain text.
  */
 public function html_to_text($text, $format)
 {
     return question_utils::to_plain_text($text, $format);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:11,代码来源:questionbase.php


示例19: is_manual_grade_in_range

 /**
  * Validate that the manual grade submitted for a particular question is in range.
  * @param int $qubaid the question_usage id.
  * @param int $slot the slot number within the usage.
  * @return bool whether the submitted data is in range.
  */
 public static function is_manual_grade_in_range($qubaid, $slot)
 {
     $prefix = 'q' . $qubaid . ':' . $slot . '_';
     $mark = question_utils::optional_param_mark($prefix . '-mark');
     $maxmark = optional_param($prefix . '-maxmark', null, PARAM_FLOAT);
     $minfraction = optional_param($prefix . ':minfraction', null, PARAM_FLOAT);
     $maxfraction = optional_param($prefix . ':maxfraction', null, PARAM_FLOAT);
     return is_null($mark) || $mark >= $minfraction * $maxmark && $mark <= $maxfraction * $maxmark;
 }
开发者ID:mongo0se,项目名称:moodle,代码行数:15,代码来源:lib.php


示例20: is_same_prt_input

 protected function is_same_prt_input($index, $prtinput1, $prtinput2)
 {
     foreach ($this->prts[$index]->get_required_variables(array_keys($this->inputs)) as $name) {
         if (!question_utils::arrays_same_at_key_missing_is_blank($prtinput1, $prtinput2, $name)) {
             return false;
         }
     }
     return true;
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:9,代码来源:question.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP quiz类代码示例发布时间:2022-05-23
下一篇:
PHP question_usage_by_activity类代码示例发布时间: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