public static function factory($params) {
        global $CFG, $COMPLETION_CRITERIA_TYPES;

        if (!isset($params['criteriatype']) || !isset($COMPLETION_CRITERIA_TYPES[$params['criteriatype']])) {
            print_error('invalidcriteriatype', 'completion');
        }

        $class = 'completion_criteria_'.$COMPLETION_CRITERIA_TYPES[$params['criteriatype']];
        require_once($CFG->dirroot.'/completion/criteria/'.$class.'.php');

        return new $class($params, false);
    }
public static function factory($params) {
        global $CFG, $COMPLETION_CRITERIA_TYPES;

        if (!isset($params['criteriatype']) || !isset($COMPLETION_CRITERIA_TYPES[$params['criteriatype']])) {
            print_error('invalidcriteriatype', 'completion');
        }

        $class = 'completion_criteria_'.$COMPLETION_CRITERIA_TYPES[$params['criteriatype']];
        require_once($CFG->dirroot.'/completion/criteria/'.$class.'.php');

        return new $class($params, false);
    }
public static function factory ( $ params ) { global $ CFG , $ COMPLETION_CRITERIA_TYPES ; if ( ! isset ( $ params [ 'criteriatype' ] ) || ! isset ( $ COMPLETION_CRITERIA_TYPES [ $ params [ 'criteriatype' ] ] ) ) { print_error ( 'invalidcriteriatype' , 'completion' ) ; } $ class = 'completion_criteria_' . $ COMPLETION_CRITERIA_TYPES [ $ params [ 'criteriatype' ] ] ; require_once ( $ CFG -> dirroot . '/completion/criteria/' . $ class . '.php' ) ; return new $ class ( $ params , false ) ; }
Factory method for creating correct class object

@param array $params associative arrays varname=>value
@return completion_criteria
Factory method for creating correct class object