public static function list_templates($competencyid, $onlyvisible) {
        global $DB;

        $sql = 'SELECT tpl.*
                  FROM {' . template::TABLE . '} tpl
                  JOIN {' . self::TABLE . '} tplcomp
                    ON tplcomp.templateid = tpl.id
                 WHERE tplcomp.competencyid = ? ';
        $params = array($competencyid);

        if ($onlyvisible) {
            $sql .= ' AND tpl.visible = ?';
            $params[] = 1;
        }

        $sql .= ' ORDER BY tpl.id ASC';

        $results = $DB->get_records_sql($sql, $params);

        $instances = array();
        foreach ($results as $result) {
            array_push($instances, new template(0, $result));
        }

        return $instances;
    }
public static function list_templates($competencyid, $onlyvisible) {
        global $DB;

        $sql = 'SELECT tpl.*
                  FROM {' . template::TABLE . '} tpl
                  JOIN {' . self::TABLE . '} tplcomp
                    ON tplcomp.templateid = tpl.id
                 WHERE tplcomp.competencyid = ? ';
        $params = array($competencyid);

        if ($onlyvisible) {
            $sql .= ' AND tpl.visible = ?';
            $params[] = 1;
        }

        $sql .= ' ORDER BY tpl.id ASC';

        $results = $DB->get_records_sql($sql, $params);

        $instances = array();
        foreach ($results as $result) {
            array_push($instances, new template(0, $result));
        }

        return $instances;
    }
public static function list_templates ( $ competencyid , $ onlyvisible ) { global $ DB ; $ sql = 'SELECT tpl.*
                  FROM {' . template :: TABLE . '} tpl
                  JOIN {' . self :: TABLE . '} tplcomp
                    ON tplcomp.templateid = tpl.id
                 WHERE tplcomp.competencyid = ? ' ; $ params = array ( $ competencyid ) ; if ( $ onlyvisible ) { $ sql .= ' AND tpl.visible = ?' ; $ params [ ] = 1 ; } $ sql .= ' ORDER BY tpl.id ASC' ; $ results = $ DB -> get_records_sql ( $ sql , $ params ) ; $ instances = array ( ) ; foreach ( $ results as $ result ) { array_push ( $ instances , new template ( 0 , $ result ) ) ; } return $ instances ; }
List the templates using a competency.

@param int $competencyid The competency id
@param bool $onlyvisible If true, only count visible templates using this competency.
@return array[competency]
List the templates using a competency .