public static function move_up_competency($id) {
        static::require_enabled();
        $current = new competency($id);

        // First we do a permissions check.
        require_capability('moodle/competency:competencymanage', $current->get_context());

        $sortorder = $current->get('sortorder');
        if ($sortorder == 0) {
            return false;
        }

        $sortorder = $sortorder - 1;
        $current->set('sortorder', $sortorder);

        $filters = array('parentid' => $current->get('parentid'),
                         'competencyframeworkid' => $current->get('competencyframeworkid'),
                         'sortorder' => $sortorder);
        $children = self::list_competencies($filters, 'id');
        foreach ($children as $needtoswap) {
            $needtoswap->set('sortorder', $sortorder + 1);
            $needtoswap->update();
        }

        // OK - all set.
        $result = $current->update();

        return $result;
    }
public static function move_up_competency($id) {
        static::require_enabled();
        $current = new competency($id);

        // First we do a permissions check.
        require_capability('moodle/competency:competencymanage', $current->get_context());

        $sortorder = $current->get('sortorder');
        if ($sortorder == 0) {
            return false;
        }

        $sortorder = $sortorder - 1;
        $current->set('sortorder', $sortorder);

        $filters = array('parentid' => $current->get('parentid'),
                         'competencyframeworkid' => $current->get('competencyframeworkid'),
                         'sortorder' => $sortorder);
        $children = self::list_competencies($filters, 'id');
        foreach ($children as $needtoswap) {
            $needtoswap->set('sortorder', $sortorder + 1);
            $needtoswap->update();
        }

        // OK - all set.
        $result = $current->update();

        return $result;
    }
public static function move_up_competency ( $ id ) { static :: require_enabled ( ) ; $ current = new competency ( $ id ) ; // First we do a permissions check. require_capability ( 'moodle/competency:competencymanage' , $ current -> get_context ( ) ) ; $ sortorder = $ current -> get ( 'sortorder' ) ; if ( $ sortorder == 0 ) { return false ; } $ sortorder = $ sortorder - 1 ; $ current -> set ( 'sortorder' , $ sortorder ) ; $ filters = array ( 'parentid' => $ current -> get ( 'parentid' ) , 'competencyframeworkid' => $ current -> get ( 'competencyframeworkid' ) , 'sortorder' => $ sortorder ) ; $ children = self :: list_competencies ( $ filters , 'id' ) ; foreach ( $ children as $ needtoswap ) { $ needtoswap -> set ( 'sortorder' , $ sortorder + 1 ) ; $ needtoswap -> update ( ) ; } // OK - all set. $ result = $ current -> update ( ) ; return $ result ; }
Reorder this competency.

Requires moodle/competency:competencymanage capability at the system context.

@param int $id The id of the competency to move.
@return boolean
Reorder this competency .