protected function load() {

        // The instance constructor could be already loaded with the full course object. Using shortname
        // because it is a required course field.
        if (empty($this->course->shortname)) {
            $this->course = get_course($this->course->id);
        }

        $this->coursecontext = $this->get_context();

        $this->now = time();

        // Get the course users, including users assigned to student and teacher roles at an higher context.
        $cache = \cache::make_from_params(\cache_store::MODE_REQUEST, 'core_analytics', 'rolearchetypes');

        // Flag the instance as loaded.
        $this->loaded = true;

        if (!$studentroles = $cache->get('student')) {
            $studentroles = array_keys(get_archetype_roles('student'));
            $cache->set('student', $studentroles);
        }
        $this->studentids = $this->get_user_ids($studentroles);

        if (!$teacherroles = $cache->get('teacher')) {
            $teacherroles = array_keys(get_archetype_roles('editingteacher') + get_archetype_roles('teacher'));
            $cache->set('teacher', $teacherroles);
        }
        $this->teacherids = $this->get_user_ids($teacherroles);
    }