original_string: public function adjust_raw_grade($rawgrade, $rawmin, $rawmax) {
          if (is_null($rawgrade)) {
              return null;
          }
  
          if ($this->gradetype == GRADE_TYPE_VALUE) { // Dealing with numerical grade
  
              if ($this->grademax < $this->grademin) {
                  return null;
              }
  
              if ($this->grademax == $this->grademin) {
                  return $this->grademax; // no range
              }
  
              // Standardise score to the new grade range
              // NOTE: skip if the activity provides a manual rescaling option.
              $manuallyrescale = (component_callback_exists('mod_' . $this->itemmodule, 'rescale_activity_grades') !== false);
              if (!$manuallyrescale && ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
                  $rawgrade = grade_grade::standardise_score($rawgrade, $rawmin, $rawmax, $this->grademin, $this->grademax);
              }
  
              // Apply other grade_item factors
              $rawgrade *= $this->multfactor;
              $rawgrade += $this->plusfactor;
  
              return $this->bounded_grade($rawgrade);
  
          } else if ($this->gradetype == GRADE_TYPE_SCALE) { // Dealing with a scale value
              if (empty($this->scale)) {
                  $this->load_scale();
              }
  
              if ($this->grademax < 0) {
                  return null; // scale not present - no grade
              }
  
              if ($this->grademax == 0) {
                  return $this->grademax; // only one option
              }
  
              // Convert scale if needed
              // NOTE: skip if the activity provides a manual rescaling option.
              $manuallyrescale = (component_callback_exists('mod_' . $this->itemmodule, 'rescale_activity_grades') !== false);
              if (!$manuallyrescale && ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
                  // This should never happen because scales are locked if they are in use.
                  $rawgrade = grade_grade::standardise_score($rawgrade, $rawmin, $rawmax, $this->grademin, $this->grademax);
              }
  
              return $this->bounded_grade($rawgrade);
  
  
          } else if ($this->gradetype == GRADE_TYPE_TEXT or $this->gradetype == GRADE_TYPE_NONE) { // no value
              // somebody changed the grading type when grades already existed
              return null;
  
          } else {
              debugging("Unknown grade type");
              return null;
          }
      }
code: public function adjust_raw_grade($rawgrade, $rawmin, $rawmax) {
          if (is_null($rawgrade)) {
              return null;
          }
  
          if ($this->gradetype == GRADE_TYPE_VALUE) { // Dealing with numerical grade
  
              if ($this->grademax < $this->grademin) {
                  return null;
              }
  
              if ($this->grademax == $this->grademin) {
                  return $this->grademax; // no range
              }
  
              // Standardise score to the new grade range
              // NOTE: skip if the activity provides a manual rescaling option.
              $manuallyrescale = (component_callback_exists('mod_' . $this->itemmodule, 'rescale_activity_grades') !== false);
              if (!$manuallyrescale && ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
                  $rawgrade = grade_grade::standardise_score($rawgrade, $rawmin, $rawmax, $this->grademin, $this->grademax);
              }
  
              // Apply other grade_item factors
              $rawgrade *= $this->multfactor;
              $rawgrade += $this->plusfactor;
  
              return $this->bounded_grade($rawgrade);
  
          } else if ($this->gradetype == GRADE_TYPE_SCALE) { // Dealing with a scale value
              if (empty($this->scale)) {
                  $this->load_scale();
              }
  
              if ($this->grademax < 0) {
                  return null; // scale not present - no grade
              }
  
              if ($this->grademax == 0) {
                  return $this->grademax; // only one option
              }
  
              // Convert scale if needed
              // NOTE: skip if the activity provides a manual rescaling option.
              $manuallyrescale = (component_callback_exists('mod_' . $this->itemmodule, 'rescale_activity_grades') !== false);
              if (!$manuallyrescale && ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
                  // This should never happen because scales are locked if they are in use.
                  $rawgrade = grade_grade::standardise_score($rawgrade, $rawmin, $rawmax, $this->grademin, $this->grademax);
              }
  
              return $this->bounded_grade($rawgrade);
  
  
          } else if ($this->gradetype == GRADE_TYPE_TEXT or $this->gradetype == GRADE_TYPE_NONE) { // no value
              // somebody changed the grading type when grades already existed
              return null;
  
          } else {
              debugging("Unknown grade type");
              return null;
          }
      }
code_tokens: public function adjust_raw_grade ( $ rawgrade , $ rawmin , $ rawmax ) { if ( is_null ( $ rawgrade ) ) { return null ; } if ( $ this -> gradetype == GRADE_TYPE_VALUE ) { // Dealing with numerical grade if ( $ this -> grademax < $ this -> grademin ) { return null ; } if ( $ this -> grademax == $ this -> grademin ) { return $ this -> grademax ; // no range } // Standardise score to the new grade range // NOTE: skip if the activity provides a manual rescaling option. $ manuallyrescale = ( component_callback_exists ( 'mod_' . $ this -> itemmodule , 'rescale_activity_grades' ) !== false ) ; if ( ! $ manuallyrescale && ( $ rawmin != $ this -> grademin or $ rawmax != $ this -> grademax ) ) { $ rawgrade = grade_grade :: standardise_score ( $ rawgrade , $ rawmin , $ rawmax , $ this -> grademin , $ this -> grademax ) ; } // Apply other grade_item factors $ rawgrade *= $ this -> multfactor ; $ rawgrade += $ this -> plusfactor ; return $ this -> bounded_grade ( $ rawgrade ) ; } else if ( $ this -> gradetype == GRADE_TYPE_SCALE ) { // Dealing with a scale value if ( empty ( $ this -> scale ) ) { $ this -> load_scale ( ) ; } if ( $ this -> grademax < 0 ) { return null ; // scale not present - no grade } if ( $ this -> grademax == 0 ) { return $ this -> grademax ; // only one option } // Convert scale if needed // NOTE: skip if the activity provides a manual rescaling option. $ manuallyrescale = ( component_callback_exists ( 'mod_' . $ this -> itemmodule , 'rescale_activity_grades' ) !== false ) ; if ( ! $ manuallyrescale && ( $ rawmin != $ this -> grademin or $ rawmax != $ this -> grademax ) ) { // This should never happen because scales are locked if they are in use. $ rawgrade = grade_grade :: standardise_score ( $ rawgrade , $ rawmin , $ rawmax , $ this -> grademin , $ this -> grademax ) ; } return $ this -> bounded_grade ( $ rawgrade ) ; } else if ( $ this -> gradetype == GRADE_TYPE_TEXT or $ this -> gradetype == GRADE_TYPE_NONE ) { // no value // somebody changed the grading type when grades already existed return null ; } else { debugging ( "Unknown grade type" ) ; return null ; } }
docstring: Given a float grade value or integer grade scale, applies a number of adjustment based on
  grade_item variables and returns the result.
  
  @param float $rawgrade The raw grade value
  @param float $rawmin original rawmin
  @param float $rawmax original rawmax
  @return mixed
docstring_tokens: Given a float grade value or integer grade scale applies a number of adjustment based on grade_item variables and returns the result .