original_string: public function grading_disabled($userid, $checkworkflow=true) {
          global $CFG;
          if ($checkworkflow && $this->get_instance()->markingworkflow) {
              $grade = $this->get_user_grade($userid, false);
              $validstates = $this->get_marking_workflow_states_for_current_user();
              if (!empty($grade) && !empty($grade->workflowstate) && !array_key_exists($grade->workflowstate, $validstates)) {
                  return true;
              }
          }
          $gradinginfo = grade_get_grades($this->get_course()->id,
                                          'mod',
                                          'assign',
                                          $this->get_instance()->id,
                                          array($userid));
          if (!$gradinginfo) {
              return false;
          }
  
          if (!isset($gradinginfo->items[0]->grades[$userid])) {
              return false;
          }
          $gradingdisabled = $gradinginfo->items[0]->grades[$userid]->locked ||
                             $gradinginfo->items[0]->grades[$userid]->overridden;
          return $gradingdisabled;
      }
code: public function grading_disabled($userid, $checkworkflow=true) {
          global $CFG;
          if ($checkworkflow && $this->get_instance()->markingworkflow) {
              $grade = $this->get_user_grade($userid, false);
              $validstates = $this->get_marking_workflow_states_for_current_user();
              if (!empty($grade) && !empty($grade->workflowstate) && !array_key_exists($grade->workflowstate, $validstates)) {
                  return true;
              }
          }
          $gradinginfo = grade_get_grades($this->get_course()->id,
                                          'mod',
                                          'assign',
                                          $this->get_instance()->id,
                                          array($userid));
          if (!$gradinginfo) {
              return false;
          }
  
          if (!isset($gradinginfo->items[0]->grades[$userid])) {
              return false;
          }
          $gradingdisabled = $gradinginfo->items[0]->grades[$userid]->locked ||
                             $gradinginfo->items[0]->grades[$userid]->overridden;
          return $gradingdisabled;
      }
code_tokens: public function grading_disabled ( $ userid , $ checkworkflow = true ) { global $ CFG ; if ( $ checkworkflow && $ this -> get_instance ( ) -> markingworkflow ) { $ grade = $ this -> get_user_grade ( $ userid , false ) ; $ validstates = $ this -> get_marking_workflow_states_for_current_user ( ) ; if ( ! empty ( $ grade ) && ! empty ( $ grade -> workflowstate ) && ! array_key_exists ( $ grade -> workflowstate , $ validstates ) ) { return true ; } } $ gradinginfo = grade_get_grades ( $ this -> get_course ( ) -> id , 'mod' , 'assign' , $ this -> get_instance ( ) -> id , array ( $ userid ) ) ; if ( ! $ gradinginfo ) { return false ; } if ( ! isset ( $ gradinginfo -> items [ 0 ] -> grades [ $ userid ] ) ) { return false ; } $ gradingdisabled = $ gradinginfo -> items [ 0 ] -> grades [ $ userid ] -> locked || $ gradinginfo -> items [ 0 ] -> grades [ $ userid ] -> overridden ; return $ gradingdisabled ; }
docstring: Determine if this users grade can be edited.
  
  @param int $userid - The student userid
  @param bool $checkworkflow - whether to include a check for the workflow state.
  @return bool $gradingdisabled
docstring_tokens: Determine if this users grade can be edited .