original_string: public function can_view_grades($groupid = null) {
          // Permissions check.
          if (!has_any_capability(array('mod/assign:viewgrades', 'mod/assign:grade'), $this->context)) {
              return false;
          }
          // Checks for the edge case when user belongs to no groups and groupmode is sep.
          if ($this->get_course_module()->effectivegroupmode == SEPARATEGROUPS) {
              if ($groupid === null) {
                  $groupid = groups_get_activity_allowed_groups($this->get_course_module());
              }
              $groupflag = has_capability('moodle/site:accessallgroups', $this->get_context());
              $groupflag = $groupflag || !empty($groupid);
              return (bool)$groupflag;
          }
          return true;
      }
code: public function can_view_grades($groupid = null) {
          // Permissions check.
          if (!has_any_capability(array('mod/assign:viewgrades', 'mod/assign:grade'), $this->context)) {
              return false;
          }
          // Checks for the edge case when user belongs to no groups and groupmode is sep.
          if ($this->get_course_module()->effectivegroupmode == SEPARATEGROUPS) {
              if ($groupid === null) {
                  $groupid = groups_get_activity_allowed_groups($this->get_course_module());
              }
              $groupflag = has_capability('moodle/site:accessallgroups', $this->get_context());
              $groupflag = $groupflag || !empty($groupid);
              return (bool)$groupflag;
          }
          return true;
      }
code_tokens: public function can_view_grades ( $ groupid = null ) { // Permissions check. if ( ! has_any_capability ( array ( 'mod/assign:viewgrades' , 'mod/assign:grade' ) , $ this -> context ) ) { return false ; } // Checks for the edge case when user belongs to no groups and groupmode is sep. if ( $ this -> get_course_module ( ) -> effectivegroupmode == SEPARATEGROUPS ) { if ( $ groupid === null ) { $ groupid = groups_get_activity_allowed_groups ( $ this -> get_course_module ( ) ) ; } $ groupflag = has_capability ( 'moodle/site:accessallgroups' , $ this -> get_context ( ) ) ; $ groupflag = $ groupflag || ! empty ( $ groupid ) ; return ( bool ) $ groupflag ; } return true ; }
docstring: Does this user have view grade or grade permission for this assignment?
  
  @param mixed $groupid int|null when is set to a value, use this group instead calculating it
  @return bool
docstring_tokens: Does this user have view grade or grade permission for this assignment?