original_string: public function validate_grading_element($elementvalue) {
          $criteria = $this->get_controller()->get_definition()->rubric_criteria;
          if (!isset($elementvalue['criteria']) || !is_array($elementvalue['criteria']) || sizeof($elementvalue['criteria']) < sizeof($criteria)) {
              return false;
          }
          foreach ($criteria as $id => $criterion) {
              if (!isset($elementvalue['criteria'][$id]['levelid'])
                      || !array_key_exists($elementvalue['criteria'][$id]['levelid'], $criterion['levels'])) {
                  return false;
              }
          }
          return true;
      }
code: public function validate_grading_element($elementvalue) {
          $criteria = $this->get_controller()->get_definition()->rubric_criteria;
          if (!isset($elementvalue['criteria']) || !is_array($elementvalue['criteria']) || sizeof($elementvalue['criteria']) < sizeof($criteria)) {
              return false;
          }
          foreach ($criteria as $id => $criterion) {
              if (!isset($elementvalue['criteria'][$id]['levelid'])
                      || !array_key_exists($elementvalue['criteria'][$id]['levelid'], $criterion['levels'])) {
                  return false;
              }
          }
          return true;
      }
code_tokens: public function validate_grading_element ( $ elementvalue ) { $ criteria = $ this -> get_controller ( ) -> get_definition ( ) -> rubric_criteria ; if ( ! isset ( $ elementvalue [ 'criteria' ] ) || ! is_array ( $ elementvalue [ 'criteria' ] ) || sizeof ( $ elementvalue [ 'criteria' ] ) < sizeof ( $ criteria ) ) { return false ; } foreach ( $ criteria as $ id => $ criterion ) { if ( ! isset ( $ elementvalue [ 'criteria' ] [ $ id ] [ 'levelid' ] ) || ! array_key_exists ( $ elementvalue [ 'criteria' ] [ $ id ] [ 'levelid' ] , $ criterion [ 'levels' ] ) ) { return false ; } } return true ; }
docstring: Validates that rubric 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 rubric is fully completed and contains valid grade on each criterion