public static function instance($course, ?\context $context = null) {

        $courseid = $course;
        if (!is_scalar($courseid)) {
            $courseid = $course->id;
        }

        if (self::$cachedid === $courseid) {
            return self::$cachedinstance;
        }

        $cachedinstance = new \core_analytics\course($course, $context);
        self::$cachedinstance = $cachedinstance;
        self::$cachedid = (int)$courseid;
        return self::$cachedinstance;
    }
public static function instance($course, ?\context $context = null) {

        $courseid = $course;
        if (!is_scalar($courseid)) {
            $courseid = $course->id;
        }

        if (self::$cachedid === $courseid) {
            return self::$cachedinstance;
        }

        $cachedinstance = new \core_analytics\course($course, $context);
        self::$cachedinstance = $cachedinstance;
        self::$cachedid = (int)$courseid;
        return self::$cachedinstance;
    }
public static function instance ( $ course , ? \ context $ context = null ) { $ courseid = $ course ; if ( ! is_scalar ( $ courseid ) ) { $ courseid = $ course -> id ; } if ( self :: $ cachedid === $ courseid ) { return self :: $ cachedinstance ; } $ cachedinstance = new \ core_analytics \ course ( $ course , $ context ) ; self :: $ cachedinstance = $ cachedinstance ; self :: $ cachedid = ( int ) $ courseid ; return self :: $ cachedinstance ; }
Returns an analytics course instance.

Lazy load of course data, students and teachers.

@param int|\stdClass $course Course object or course id
@param \context|null $context
@return \core_analytics\course
Returns an analytics course instance .