public function count_course_user_data($user_id = null) {
        global $DB;

        $sql = '
    SELECT
        COUNT(1)
    FROM
        {course_completion_crit_compl}
    WHERE
        course = ?
        ';

        $params = array($this->course_id);

        // Limit data to a single user if an ID is supplied
        if ($user_id) {
            $sql .= ' AND userid = ?';
            $params[] = $user_id;
        }

        return $DB->get_field_sql($sql, $params);
    }
public function count_course_user_data($user_id = null) {
        global $DB;

        $sql = '
    SELECT
        COUNT(1)
    FROM
        {course_completion_crit_compl}
    WHERE
        course = ?
        ';

        $params = array($this->course_id);

        // Limit data to a single user if an ID is supplied
        if ($user_id) {
            $sql .= ' AND userid = ?';
            $params[] = $user_id;
        }

        return $DB->get_field_sql($sql, $params);
    }
public function count_course_user_data ( $ user_id = null ) { global $ DB ; $ sql = '
    SELECT
        COUNT(1)
    FROM
        {course_completion_crit_compl}
    WHERE
        course = ?
        ' ; $ params = array ( $ this -> course_id ) ; // Limit data to a single user if an ID is supplied if ( $ user_id ) { $ sql .= ' AND userid = ?' ; $ params [ ] = $ user_id ; } return $ DB -> get_field_sql ( $ sql , $ params ) ; }
Determines how much course completion data exists for a course. This is used when
deciding whether completion information should be 'locked' in the completion
settings form and activity completion settings.

@param int $user_id Optionally only get course completion data for a single user
@return int The number of users who have completion data stored for this
course, 0 if none
Determines how much course completion data exists for a course . This is used when deciding whether completion information should be locked in the completion settings form and activity completion settings .