public function get_all_activities($activitytype) {

        // Using is set because we set it to false if there are no activities.
        if (!isset($this->courseactivities[$activitytype])) {
            $modinfo = get_fast_modinfo($this->get_course_data(), -1);
            $instances = $modinfo->get_instances_of($activitytype);

            if ($instances) {
                $this->courseactivities[$activitytype] = array();
                foreach ($instances as $instance) {
                    // By context.
                    $this->courseactivities[$activitytype][$instance->context->id] = $instance;
                }
            } else {
                $this->courseactivities[$activitytype] = false;
            }
        }

        return $this->courseactivities[$activitytype];
    }