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


PHP quiz_access_manager::validate_settings_form_fields方法代码示例

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


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

示例1: validation

 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // Check open and close times are consistent.
     if ($data['timeopen'] != 0 && $data['timeclose'] != 0 && $data['timeclose'] < $data['timeopen']) {
         $errors['timeclose'] = get_string('closebeforeopen', 'quiz');
     }
     // Check that the grace period is not too short.
     if ($data['overduehandling'] == 'graceperiod') {
         $graceperiodmin = get_config('quiz', 'graceperiodmin');
         if ($data['graceperiod'] <= $graceperiodmin) {
             $errors['graceperiod'] = get_string('graceperiodtoosmall', 'quiz', format_time($graceperiodmin));
         }
     }
     // Check the boundary value is a number or a percentage, and in range.
     $i = 0;
     while (!empty($data['feedbackboundaries'][$i])) {
         $boundary = trim($data['feedbackboundaries'][$i]);
         if (strlen($boundary) > 0) {
             if ($boundary[strlen($boundary) - 1] == '%') {
                 $boundary = trim(substr($boundary, 0, -1));
                 if (is_numeric($boundary)) {
                     $boundary = $boundary * $data['grade'] / 100.0;
                 } else {
                     $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
                 }
             } else {
                 if (!is_numeric($boundary)) {
                     $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
                 }
             }
         }
         if (is_numeric($boundary) && $boundary <= 0 || $boundary >= $data['grade']) {
             $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
         }
         if (is_numeric($boundary) && $i > 0 && $boundary >= $data['feedbackboundaries'][$i - 1]) {
             $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrororder', 'quiz', $i + 1);
         }
         $data['feedbackboundaries'][$i] = $boundary;
         $i += 1;
     }
     $numboundaries = $i;
     // Check there is nothing in the remaining unused fields.
     if (!empty($data['feedbackboundaries'])) {
         for ($i = $numboundaries; $i < count($data['feedbackboundaries']); $i += 1) {
             if (!empty($data['feedbackboundaries'][$i]) && trim($data['feedbackboundaries'][$i]) != '') {
                 $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
             }
         }
     }
     for ($i = $numboundaries + 1; $i < count($data['feedbacktext']); $i += 1) {
         if (!empty($data['feedbacktext'][$i]['text']) && trim($data['feedbacktext'][$i]['text']) != '') {
             $errors["feedbacktext[{$i}]"] = get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
         }
     }
     // Any other rule plugins.
     $errors = quiz_access_manager::validate_settings_form_fields($errors, $data, $files, $this);
     return $errors;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:59,代码来源:mod_form.php

示例2: validation

 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // Check open and close times are consistent.
     if ($data['timeopen'] != 0 && $data['timeclose'] != 0 && $data['timeclose'] < $data['timeopen']) {
         $errors['timeclose'] = get_string('closebeforeopen', 'quiz');
     }
     // Check that the grace period is not too short.
     if ($data['overduehandling'] == 'graceperiod') {
         $graceperiodmin = get_config('quiz', 'graceperiodmin');
         if ($data['graceperiod'] <= $graceperiodmin) {
             $errors['graceperiod'] = get_string('graceperiodtoosmall', 'quiz', format_time($graceperiodmin));
         }
     }
     if (array_key_exists('completion', $data) && $data['completion'] == COMPLETION_TRACKING_AUTOMATIC) {
         $completionpass = isset($data['completionpass']) ? $data['completionpass'] : $this->current->completionpass;
         // Show an error if require passing grade was selected and the grade to pass was set to 0.
         if ($completionpass && (empty($data['gradepass']) || grade_floatval($data['gradepass']) == 0)) {
             if (isset($data['completionpass'])) {
                 $errors['completionpassgroup'] = get_string('gradetopassnotset', 'quiz');
             } else {
                 $errors['gradepass'] = get_string('gradetopassmustbeset', 'quiz');
             }
         }
     }
     // Check the boundary value is a number or a percentage, and in range.
     $i = 0;
     while (!empty($data['feedbackboundaries'][$i])) {
         $boundary = trim($data['feedbackboundaries'][$i]);
         if (strlen($boundary) > 0) {
             if ($boundary[strlen($boundary) - 1] == '%') {
                 $boundary = trim(substr($boundary, 0, -1));
                 if (is_numeric($boundary)) {
                     $boundary = $boundary * $data['grade'] / 100.0;
                 } else {
                     $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
                 }
             } else {
                 if (!is_numeric($boundary)) {
                     $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
                 }
             }
         }
         if (is_numeric($boundary) && $boundary <= 0 || $boundary >= $data['grade']) {
             $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
         }
         if (is_numeric($boundary) && $i > 0 && $boundary >= $data['feedbackboundaries'][$i - 1]) {
             $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrororder', 'quiz', $i + 1);
         }
         $data['feedbackboundaries'][$i] = $boundary;
         $i += 1;
     }
     $numboundaries = $i;
     // Check there is nothing in the remaining unused fields.
     if (!empty($data['feedbackboundaries'])) {
         for ($i = $numboundaries; $i < count($data['feedbackboundaries']); $i += 1) {
             if (!empty($data['feedbackboundaries'][$i]) && trim($data['feedbackboundaries'][$i]) != '') {
                 $errors["feedbackboundaries[{$i}]"] = get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
             }
         }
     }
     for ($i = $numboundaries + 1; $i < count($data['feedbacktext']); $i += 1) {
         if (!empty($data['feedbacktext'][$i]['text']) && trim($data['feedbacktext'][$i]['text']) != '') {
             $errors["feedbacktext[{$i}]"] = get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
         }
     }
     // Any other rule plugins.
     $errors = quiz_access_manager::validate_settings_form_fields($errors, $data, $files, $this);
     return $errors;
 }
开发者ID:janeklb,项目名称:moodle,代码行数:70,代码来源:mod_form.php


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