public function is_valid_sample($sampleid, \core_analytics\analysable $analysable, $fortraining = true) {

        $course = $this->retrieve('course', $sampleid);

        $now = time();

        // No courses without start date, no finished courses, no predictions before start - 1 week nor
        // predictions for courses that started more than 1 week ago.
        if (!$course->startdate || (!empty($course->enddate) && $course->enddate < $now) ||
                $course->startdate - WEEKSECS > $now || $course->startdate + WEEKSECS < $now) {
            return false;
        }
        return true;
    }