protected function get_course_gradetopass($courseid) {
        if (!isset($this->coursesgradetopass[$courseid])) {
            // Get course grade_item.
            $courseitem = \grade_item::fetch_course_item($courseid);

            $ci = array();
            $ci['courseitemid'] = $courseitem->id;

            if ($courseitem->gradetype == GRADE_TYPE_VALUE && grade_floats_different($courseitem->gradepass, 0.0)) {
                $ci['gradetopass'] = $courseitem->gradepass;
            } else {
                $ci['gradetopass'] = null;
            }
            $this->coursesgradetopass[$courseid] = $ci;
        }

        return $this->coursesgradetopass[$courseid];
    }