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);
    }
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);
    }
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 ) ; }
Adjust the fraction based on whether the unit was correct.
@param number $fraction
@param bool $unitisright
@return number
Adjust the fraction based on whether the unit was correct .