public static function instance($categoryid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_COURSECAT, $categoryid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_COURSECAT, 'instanceid' => $categoryid))) {
            if ($category = $DB->get_record('course_categories', array('id' => $categoryid), 'id,parent', $strictness)) {
                if ($category->parent) {
                    $parentcontext = context_coursecat::instance($category->parent);
                    $record = context::insert_context_record(CONTEXT_COURSECAT, $category->id, $parentcontext->path);
                } else {
                    $record = context::insert_context_record(CONTEXT_COURSECAT, $category->id, '/'.SYSCONTEXTID, 0);
                }
            }
        }

        if ($record) {
            $context = new context_coursecat($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }
public static function instance($categoryid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_COURSECAT, $categoryid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_COURSECAT, 'instanceid' => $categoryid))) {
            if ($category = $DB->get_record('course_categories', array('id' => $categoryid), 'id,parent', $strictness)) {
                if ($category->parent) {
                    $parentcontext = context_coursecat::instance($category->parent);
                    $record = context::insert_context_record(CONTEXT_COURSECAT, $category->id, $parentcontext->path);
                } else {
                    $record = context::insert_context_record(CONTEXT_COURSECAT, $category->id, '/'.SYSCONTEXTID, 0);
                }
            }
        }

        if ($record) {
            $context = new context_coursecat($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }
public static function instance ( $ categoryid , $ strictness = MUST_EXIST ) { global $ DB ; if ( $ context = context :: cache_get ( CONTEXT_COURSECAT , $ categoryid ) ) { return $ context ; } if ( ! $ record = $ DB -> get_record ( 'context' , array ( 'contextlevel' => CONTEXT_COURSECAT , 'instanceid' => $ categoryid ) ) ) { if ( $ category = $ DB -> get_record ( 'course_categories' , array ( 'id' => $ categoryid ) , 'id,parent' , $ strictness ) ) { if ( $ category -> parent ) { $ parentcontext = context_coursecat :: instance ( $ category -> parent ) ; $ record = context :: insert_context_record ( CONTEXT_COURSECAT , $ category -> id , $ parentcontext -> path ) ; } else { $ record = context :: insert_context_record ( CONTEXT_COURSECAT , $ category -> id , '/' . SYSCONTEXTID , 0 ) ; } } } if ( $ record ) { $ context = new context_coursecat ( $ record ) ; context :: cache_add ( $ context ) ; return $ context ; } return false ; }
Returns course category context instance.

@static
@param int $categoryid id from {course_categories} table
@param int $strictness
@return context_coursecat context instance
Returns course category context instance .