protected function activity_type_completed_by(\cm_info $activity, $starttime, $endtime, $student = false) {

        $fieldname = $this->get_timeclose_field();
        if (!$fieldname) {
            // This activity type do not have its own availability control.
            return null;
        }

        $this->fill_instance_data($activity);
        $instance = $this->instancedata[$activity->instance];

        if (!$instance->{$fieldname}) {
            return null;
        }

        if ($starttime < $instance->{$fieldname} && $endtime >= $instance->{$fieldname}) {
            return true;
        }

        return false;
    }