public static function build($params) {
        global $CFG;

        require_once($CFG->libdir . '/badgeslib.php');

        $types = badges_list_criteria(false);

        if (!isset($params['criteriatype']) || !isset($types[$params['criteriatype']])) {
            print_error('error:invalidcriteriatype', 'badges');
        }

        $class = 'award_criteria_' . $types[$params['criteriatype']];
        require_once($CFG->dirroot . '/badges/criteria/' . $class . '.php');

        return new $class($params);
    }