original_string: public function apply_unit_penalty($fraction, $unitisright) {
          if ($unitisright) {
              return $fraction;
          }
  
          if ($this->unitgradingtype == qtype_numerical::UNITGRADEDOUTOFMARK) {
              $fraction -= $this->unitpenalty * $fraction;
          } else if ($this->unitgradingtype == qtype_numerical::UNITGRADEDOUTOFMAX) {
              $fraction -= $this->unitpenalty;
          }
          return max($fraction, 0);
      }
code: public function apply_unit_penalty($fraction, $unitisright) {
          if ($unitisright) {
              return $fraction;
          }
  
          if ($this->unitgradingtype == qtype_numerical::UNITGRADEDOUTOFMARK) {
              $fraction -= $this->unitpenalty * $fraction;
          } else if ($this->unitgradingtype == qtype_numerical::UNITGRADEDOUTOFMAX) {
              $fraction -= $this->unitpenalty;
          }
          return max($fraction, 0);
      }
code_tokens: public function apply_unit_penalty ( $ fraction , $ unitisright ) { if ( $ unitisright ) { return $ fraction ; } if ( $ this -> unitgradingtype == qtype_numerical :: UNITGRADEDOUTOFMARK ) { $ fraction -= $ this -> unitpenalty * $ fraction ; } else if ( $ this -> unitgradingtype == qtype_numerical :: UNITGRADEDOUTOFMAX ) { $ fraction -= $ this -> unitpenalty ; } return max ( $ fraction , 0 ) ; }
docstring: Adjust the fraction based on whether the unit was correct.
  @param number $fraction
  @param bool $unitisright
  @return number
docstring_tokens: Adjust the fraction based on whether the unit was correct .