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


PHP question_utils::clean_param_mark方法代码示例

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


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

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

示例2: test_clean_param_mark

 public function test_clean_param_mark()
 {
     $this->assertNull(question_utils::clean_param_mark(null));
     $this->assertNull(question_utils::clean_param_mark('frog'));
     $this->assertSame('', question_utils::clean_param_mark(''));
     $this->assertSame(0.0, question_utils::clean_param_mark('0'));
     $this->assertSame(1.5, question_utils::clean_param_mark('1.5'));
     $this->assertSame(1.5, question_utils::clean_param_mark('1,5'));
     $this->assertSame(-1.5, question_utils::clean_param_mark('-1.5'));
     $this->assertSame(-1.5, question_utils::clean_param_mark('-1,5'));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:11,代码来源:questionutils_test.php

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

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


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