當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。