protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) {

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

        // Get course grade to pass.
        $courseitem = $this->get_course_gradetopass($course->get_id());

        // Get the user grade.
        $usergrade = $this->get_user_grade($courseitem['courseitemid'], $userenrol->userid);

        if ($usergrade >= $courseitem['gradetopass']) {
            return 0;
        }

        return 1;
    }