original_string: public function can_edit_submission($userid, $graderid = 0) {
          global $USER;
  
          if (empty($graderid)) {
              $graderid = $USER->id;
          }
  
          $instance = $this->get_instance();
          if ($userid == $graderid &&
              $instance->teamsubmission &&
              $instance->preventsubmissionnotingroup &&
              $this->get_submission_group($userid) == false) {
              return false;
          }
  
          if ($userid == $graderid) {
              if ($this->submissions_open($userid) &&
                      has_capability('mod/assign:submit', $this->context, $graderid)) {
                  // User can edit their own submission.
                  return true;
              } else {
                  // We need to return here because editothersubmission should never apply to a users own submission.
                  return false;
              }
          }
  
          if (!has_capability('mod/assign:editothersubmission', $this->context, $graderid)) {
              return false;
          }
  
          $cm = $this->get_course_module();
          if (groups_get_activity_groupmode($cm) == SEPARATEGROUPS) {
              $sharedgroupmembers = $this->get_shared_group_members($cm, $graderid);
              return in_array($userid, $sharedgroupmembers);
          }
          return true;
      }
code: public function can_edit_submission($userid, $graderid = 0) {
          global $USER;
  
          if (empty($graderid)) {
              $graderid = $USER->id;
          }
  
          $instance = $this->get_instance();
          if ($userid == $graderid &&
              $instance->teamsubmission &&
              $instance->preventsubmissionnotingroup &&
              $this->get_submission_group($userid) == false) {
              return false;
          }
  
          if ($userid == $graderid) {
              if ($this->submissions_open($userid) &&
                      has_capability('mod/assign:submit', $this->context, $graderid)) {
                  // User can edit their own submission.
                  return true;
              } else {
                  // We need to return here because editothersubmission should never apply to a users own submission.
                  return false;
              }
          }
  
          if (!has_capability('mod/assign:editothersubmission', $this->context, $graderid)) {
              return false;
          }
  
          $cm = $this->get_course_module();
          if (groups_get_activity_groupmode($cm) == SEPARATEGROUPS) {
              $sharedgroupmembers = $this->get_shared_group_members($cm, $graderid);
              return in_array($userid, $sharedgroupmembers);
          }
          return true;
      }
code_tokens: public function can_edit_submission ( $ userid , $ graderid = 0 ) { global $ USER ; if ( empty ( $ graderid ) ) { $ graderid = $ USER -> id ; } $ instance = $ this -> get_instance ( ) ; if ( $ userid == $ graderid && $ instance -> teamsubmission && $ instance -> preventsubmissionnotingroup && $ this -> get_submission_group ( $ userid ) == false ) { return false ; } if ( $ userid == $ graderid ) { if ( $ this -> submissions_open ( $ userid ) && has_capability ( 'mod/assign:submit' , $ this -> context , $ graderid ) ) { // User can edit their own submission. return true ; } else { // We need to return here because editothersubmission should never apply to a users own submission. return false ; } } if ( ! has_capability ( 'mod/assign:editothersubmission' , $ this -> context , $ graderid ) ) { return false ; } $ cm = $ this -> get_course_module ( ) ; if ( groups_get_activity_groupmode ( $ cm ) == SEPARATEGROUPS ) { $ sharedgroupmembers = $ this -> get_shared_group_members ( $ cm , $ graderid ) ; return in_array ( $ userid , $ sharedgroupmembers ) ; } return true ; }
docstring: Capability check to make sure this grader can edit this submission.
  
  @param int $userid - The user whose submission is to be edited
  @param int $graderid (optional) - The user who will do the editing (default to $USER->id).
  @return bool
docstring_tokens: Capability check to make sure this grader can edit this submission .