public function validate() {
        global $DB;
        $params = array_keys($this->params);
        $method = ($this->method == BADGE_CRITERIA_AGGREGATION_ALL);
        $singleparam = (count($params) == 1);

        foreach ($params as $param) {
            // Perform check if there only one parameter with any type of aggregation,
            // Or there are more than one parameter with aggregation ALL.
            if (($singleparam || $method) && !$DB->record_exists('cohort', array('id' => $param))) {
                return array(false, get_string('error:invalidparamcohort', 'badges'));
            }
        }

        return array(true, '');
    }
public function validate() {
        global $DB;
        $params = array_keys($this->params);
        $method = ($this->method == BADGE_CRITERIA_AGGREGATION_ALL);
        $singleparam = (count($params) == 1);

        foreach ($params as $param) {
            // Perform check if there only one parameter with any type of aggregation,
            // Or there are more than one parameter with aggregation ALL.
            if (($singleparam || $method) && !$DB->record_exists('cohort', array('id' => $param))) {
                return array(false, get_string('error:invalidparamcohort', 'badges'));
            }
        }

        return array(true, '');
    }
public function validate ( ) { global $ DB ; $ params = array_keys ( $ this -> params ) ; $ method = ( $ this -> method == BADGE_CRITERIA_AGGREGATION_ALL ) ; $ singleparam = ( count ( $ params ) == 1 ) ; foreach ( $ params as $ param ) { // Perform check if there only one parameter with any type of aggregation, // Or there are more than one parameter with aggregation ALL. if ( ( $ singleparam || $ method ) && ! $ DB -> record_exists ( 'cohort' , array ( 'id' => $ param ) ) ) { return array ( false , get_string ( 'error:invalidparamcohort' , 'badges' ) ) ; } } return array ( true , '' ) ; }
Checks criteria for any major problems.

@return array A list containing status and an error message (if any).
Checks criteria for any major problems .