original_string: public static function can_edit_bulk_completion($courseorid, $cm = null) {
          if ($cm) {
              return $cm->uservisible && has_capability('moodle/course:manageactivities', $cm->context);
          }
          $coursecontext = context_course::instance(is_object($courseorid) ? $courseorid->id : $courseorid);
          if (has_capability('moodle/course:manageactivities', $coursecontext)) {
              return true;
          }
          $modinfo = get_fast_modinfo($courseorid);
          foreach ($modinfo->cms as $mod) {
              if ($mod->uservisible && has_capability('moodle/course:manageactivities', $mod->context)) {
                  return true;
              }
          }
          return false;
      }
code: public static function can_edit_bulk_completion($courseorid, $cm = null) {
          if ($cm) {
              return $cm->uservisible && has_capability('moodle/course:manageactivities', $cm->context);
          }
          $coursecontext = context_course::instance(is_object($courseorid) ? $courseorid->id : $courseorid);
          if (has_capability('moodle/course:manageactivities', $coursecontext)) {
              return true;
          }
          $modinfo = get_fast_modinfo($courseorid);
          foreach ($modinfo->cms as $mod) {
              if ($mod->uservisible && has_capability('moodle/course:manageactivities', $mod->context)) {
                  return true;
              }
          }
          return false;
      }
code_tokens: public static function can_edit_bulk_completion ( $ courseorid , $ cm = null ) { if ( $ cm ) { return $ cm -> uservisible && has_capability ( 'moodle/course:manageactivities' , $ cm -> context ) ; } $ coursecontext = context_course :: instance ( is_object ( $ courseorid ) ? $ courseorid -> id : $ courseorid ) ; if ( has_capability ( 'moodle/course:manageactivities' , $ coursecontext ) ) { return true ; } $ modinfo = get_fast_modinfo ( $ courseorid ) ; foreach ( $ modinfo -> cms as $ mod ) { if ( $ mod -> uservisible && has_capability ( 'moodle/course:manageactivities' , $ mod -> context ) ) { return true ; } } return false ; }
docstring: Checks if current user can edit activity completion
  
  @param int|stdClass $courseorid
  @param \cm_info|null $cm if specified capability for a given coursemodule will be check,
  if not specified capability to edit at least one activity is checked.
docstring_tokens: Checks if current user can edit activity completion