original_string: public function validation($data, $files) {
          $errors = parent::validation($data, $files);
  
          // check the phases borders are valid
          if ($data['submissionstart'] > 0 and $data['submissionend'] > 0 and $data['submissionstart'] >= $data['submissionend']) {
              $errors['submissionend'] = get_string('submissionendbeforestart', 'mod_workshop');
          }
          if ($data['assessmentstart'] > 0 and $data['assessmentend'] > 0 and $data['assessmentstart'] >= $data['assessmentend']) {
              $errors['assessmentend'] = get_string('assessmentendbeforestart', 'mod_workshop');
          }
  
          // check the phases do not overlap
          if (max($data['submissionstart'], $data['submissionend']) > 0 and max($data['assessmentstart'], $data['assessmentend']) > 0) {
              $phasesubmissionend = max($data['submissionstart'], $data['submissionend']);
              $phaseassessmentstart = min($data['assessmentstart'], $data['assessmentend']);
              if ($phaseassessmentstart == 0) {
                  $phaseassessmentstart = max($data['assessmentstart'], $data['assessmentend']);
              }
              if ($phasesubmissionend > 0 and $phaseassessmentstart > 0 and $phaseassessmentstart < $phasesubmissionend) {
                  foreach (array('submissionend', 'submissionstart', 'assessmentstart', 'assessmentend') as $f) {
                      if ($data[$f] > 0) {
                          $errors[$f] = get_string('phasesoverlap', 'mod_workshop');
                          break;
                      }
                  }
              }
          }
  
          // Check that the submission grade pass is a valid number.
          if (!empty($data['submissiongradepass'])) {
              $submissiongradefloat = unformat_float($data['submissiongradepass'], true);
              if ($submissiongradefloat === false) {
                  $errors['submissiongradepass'] = get_string('err_numeric', 'form');
              } else {
                  if ($submissiongradefloat > $data['grade']) {
                      $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']);
                  }
              }
          }
  
          // Check that the grade pass is a valid number.
          if (!empty($data['gradinggradepass'])) {
              $gradepassfloat = unformat_float($data['gradinggradepass'], true);
              if ($gradepassfloat === false) {
                  $errors['gradinggradepass'] = get_string('err_numeric', 'form');
              } else {
                  if ($gradepassfloat > $data['gradinggrade']) {
                      $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']);
                  }
              }
          }
  
          if (!$data['submissiontypetextavailable'] && !$data['submissiontypefileavailable']) {
              // One submission type must be available.
              $errors['submissiontypes'] = get_string('nosubmissiontype', 'workshop');
          }
  
          return $errors;
      }
code: public function validation($data, $files) {
          $errors = parent::validation($data, $files);
  
          // check the phases borders are valid
          if ($data['submissionstart'] > 0 and $data['submissionend'] > 0 and $data['submissionstart'] >= $data['submissionend']) {
              $errors['submissionend'] = get_string('submissionendbeforestart', 'mod_workshop');
          }
          if ($data['assessmentstart'] > 0 and $data['assessmentend'] > 0 and $data['assessmentstart'] >= $data['assessmentend']) {
              $errors['assessmentend'] = get_string('assessmentendbeforestart', 'mod_workshop');
          }
  
          // check the phases do not overlap
          if (max($data['submissionstart'], $data['submissionend']) > 0 and max($data['assessmentstart'], $data['assessmentend']) > 0) {
              $phasesubmissionend = max($data['submissionstart'], $data['submissionend']);
              $phaseassessmentstart = min($data['assessmentstart'], $data['assessmentend']);
              if ($phaseassessmentstart == 0) {
                  $phaseassessmentstart = max($data['assessmentstart'], $data['assessmentend']);
              }
              if ($phasesubmissionend > 0 and $phaseassessmentstart > 0 and $phaseassessmentstart < $phasesubmissionend) {
                  foreach (array('submissionend', 'submissionstart', 'assessmentstart', 'assessmentend') as $f) {
                      if ($data[$f] > 0) {
                          $errors[$f] = get_string('phasesoverlap', 'mod_workshop');
                          break;
                      }
                  }
              }
          }
  
          // Check that the submission grade pass is a valid number.
          if (!empty($data['submissiongradepass'])) {
              $submissiongradefloat = unformat_float($data['submissiongradepass'], true);
              if ($submissiongradefloat === false) {
                  $errors['submissiongradepass'] = get_string('err_numeric', 'form');
              } else {
                  if ($submissiongradefloat > $data['grade']) {
                      $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']);
                  }
              }
          }
  
          // Check that the grade pass is a valid number.
          if (!empty($data['gradinggradepass'])) {
              $gradepassfloat = unformat_float($data['gradinggradepass'], true);
              if ($gradepassfloat === false) {
                  $errors['gradinggradepass'] = get_string('err_numeric', 'form');
              } else {
                  if ($gradepassfloat > $data['gradinggrade']) {
                      $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']);
                  }
              }
          }
  
          if (!$data['submissiontypetextavailable'] && !$data['submissiontypefileavailable']) {
              // One submission type must be available.
              $errors['submissiontypes'] = get_string('nosubmissiontype', 'workshop');
          }
  
          return $errors;
      }
code_tokens: public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; // check the phases borders are valid if ( $ data [ 'submissionstart' ] > 0 and $ data [ 'submissionend' ] > 0 and $ data [ 'submissionstart' ] >= $ data [ 'submissionend' ] ) { $ errors [ 'submissionend' ] = get_string ( 'submissionendbeforestart' , 'mod_workshop' ) ; } if ( $ data [ 'assessmentstart' ] > 0 and $ data [ 'assessmentend' ] > 0 and $ data [ 'assessmentstart' ] >= $ data [ 'assessmentend' ] ) { $ errors [ 'assessmentend' ] = get_string ( 'assessmentendbeforestart' , 'mod_workshop' ) ; } // check the phases do not overlap if ( max ( $ data [ 'submissionstart' ] , $ data [ 'submissionend' ] ) > 0 and max ( $ data [ 'assessmentstart' ] , $ data [ 'assessmentend' ] ) > 0 ) { $ phasesubmissionend = max ( $ data [ 'submissionstart' ] , $ data [ 'submissionend' ] ) ; $ phaseassessmentstart = min ( $ data [ 'assessmentstart' ] , $ data [ 'assessmentend' ] ) ; if ( $ phaseassessmentstart == 0 ) { $ phaseassessmentstart = max ( $ data [ 'assessmentstart' ] , $ data [ 'assessmentend' ] ) ; } if ( $ phasesubmissionend > 0 and $ phaseassessmentstart > 0 and $ phaseassessmentstart < $ phasesubmissionend ) { foreach ( array ( 'submissionend' , 'submissionstart' , 'assessmentstart' , 'assessmentend' ) as $ f ) { if ( $ data [ $ f ] > 0 ) { $ errors [ $ f ] = get_string ( 'phasesoverlap' , 'mod_workshop' ) ; break ; } } } } // Check that the submission grade pass is a valid number. if ( ! empty ( $ data [ 'submissiongradepass' ] ) ) { $ submissiongradefloat = unformat_float ( $ data [ 'submissiongradepass' ] , true ) ; if ( $ submissiongradefloat === false ) { $ errors [ 'submissiongradepass' ] = get_string ( 'err_numeric' , 'form' ) ; } else { if ( $ submissiongradefloat > $ data [ 'grade' ] ) { $ errors [ 'submissiongradepass' ] = get_string ( 'gradepassgreaterthangrade' , 'grades' , $ data [ 'grade' ] ) ; } } } // Check that the grade pass is a valid number. if ( ! empty ( $ data [ 'gradinggradepass' ] ) ) { $ gradepassfloat = unformat_float ( $ data [ 'gradinggradepass' ] , true ) ; if ( $ gradepassfloat === false ) { $ errors [ 'gradinggradepass' ] = get_string ( 'err_numeric' , 'form' ) ; } else { if ( $ gradepassfloat > $ data [ 'gradinggrade' ] ) { $ errors [ 'gradinggradepass' ] = get_string ( 'gradepassgreaterthangrade' , 'grades' , $ data [ 'gradinggrade' ] ) ; } } } if ( ! $ data [ 'submissiontypetextavailable' ] && ! $ data [ 'submissiontypefileavailable' ] ) { // One submission type must be available. $ errors [ 'submissiontypes' ] = get_string ( 'nosubmissiontype' , 'workshop' ) ; } return $ errors ; }
docstring: Validates the form input
  
  @param array $data submitted data
  @param array $files submitted files
  @return array eventual errors indexed by the field name
docstring_tokens: Validates the form input