original_string: public function can_add_instance($courseid) {
          global $CFG;
          require_once($CFG->dirroot . '/cohort/lib.php');
          $coursecontext = context_course::instance($courseid);
          if (!has_capability('moodle/course:enrolconfig', $coursecontext) or !has_capability('enrol/cohort:config', $coursecontext)) {
              return false;
          }
          return cohort_get_available_cohorts($coursecontext, 0, 0, 1) ? true : false;
      }
code: public function can_add_instance($courseid) {
          global $CFG;
          require_once($CFG->dirroot . '/cohort/lib.php');
          $coursecontext = context_course::instance($courseid);
          if (!has_capability('moodle/course:enrolconfig', $coursecontext) or !has_capability('enrol/cohort:config', $coursecontext)) {
              return false;
          }
          return cohort_get_available_cohorts($coursecontext, 0, 0, 1) ? true : false;
      }
code_tokens: public function can_add_instance ( $ courseid ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/cohort/lib.php' ) ; $ coursecontext = context_course :: instance ( $ courseid ) ; if ( ! has_capability ( 'moodle/course:enrolconfig' , $ coursecontext ) or ! has_capability ( 'enrol/cohort:config' , $ coursecontext ) ) { return false ; } return cohort_get_available_cohorts ( $ coursecontext , 0 , 0 , 1 ) ? true : false ; }
docstring: Given a courseid this function returns true if the user is able to enrol or configure cohorts.
  AND there are cohorts that the user can view.
  
  @param int $courseid
  @return bool
docstring_tokens: Given a courseid this function returns true if the user is able to enrol or configure cohorts . AND there are cohorts that the user can view .