original_string: public function validate_grading_element($elementvalue) {
          $criteria = $this->get_controller()->get_definition()->guide_criteria;
          if (!isset($elementvalue['criteria']) || !is_array($elementvalue['criteria']) ||
              count($elementvalue['criteria']) < count($criteria)) {
              return false;
          }
          // Reset validation errors.
          $this->validationerrors = null;
          foreach ($criteria as $id => $criterion) {
              if (!isset($elementvalue['criteria'][$id]['score'])
                      || $criterion['maxscore'] < $elementvalue['criteria'][$id]['score']
                      || !is_numeric($elementvalue['criteria'][$id]['score'])
                      || $elementvalue['criteria'][$id]['score'] < 0) {
                  $this->validationerrors[$id]['score'] = $elementvalue['criteria'][$id]['score'];
              }
          }
          if (!empty($this->validationerrors)) {
              return false;
          }
          return true;
      }
code: public function validate_grading_element($elementvalue) {
          $criteria = $this->get_controller()->get_definition()->guide_criteria;
          if (!isset($elementvalue['criteria']) || !is_array($elementvalue['criteria']) ||
              count($elementvalue['criteria']) < count($criteria)) {
              return false;
          }
          // Reset validation errors.
          $this->validationerrors = null;
          foreach ($criteria as $id => $criterion) {
              if (!isset($elementvalue['criteria'][$id]['score'])
                      || $criterion['maxscore'] < $elementvalue['criteria'][$id]['score']
                      || !is_numeric($elementvalue['criteria'][$id]['score'])
                      || $elementvalue['criteria'][$id]['score'] < 0) {
                  $this->validationerrors[$id]['score'] = $elementvalue['criteria'][$id]['score'];
              }
          }
          if (!empty($this->validationerrors)) {
              return false;
          }
          return true;
      }
code_tokens: public function validate_grading_element ( $ elementvalue ) { $ criteria = $ this -> get_controller ( ) -> get_definition ( ) -> guide_criteria ; if ( ! isset ( $ elementvalue [ 'criteria' ] ) || ! is_array ( $ elementvalue [ 'criteria' ] ) || count ( $ elementvalue [ 'criteria' ] ) < count ( $ criteria ) ) { return false ; } // Reset validation errors. $ this -> validationerrors = null ; foreach ( $ criteria as $ id => $ criterion ) { if ( ! isset ( $ elementvalue [ 'criteria' ] [ $ id ] [ 'score' ] ) || $ criterion [ 'maxscore' ] < $ elementvalue [ 'criteria' ] [ $ id ] [ 'score' ] || ! is_numeric ( $ elementvalue [ 'criteria' ] [ $ id ] [ 'score' ] ) || $ elementvalue [ 'criteria' ] [ $ id ] [ 'score' ] < 0 ) { $ this -> validationerrors [ $ id ] [ 'score' ] = $ elementvalue [ 'criteria' ] [ $ id ] [ 'score' ] ; } } if ( ! empty ( $ this -> validationerrors ) ) { return false ; } return true ; }
docstring: Validates that guide is fully completed and contains valid grade on each criterion
  
  @param array $elementvalue value of element as came in form submit
  @return boolean true if the form data is validated and contains no errors
docstring_tokens: Validates that guide is fully completed and contains valid grade on each criterion