public function get_matching_answer($value, $multiplier) {
        if (is_null($value) || $value === '') {
            return null;
        }

        if (!is_null($multiplier)) {
            $scaledvalue = $value * $multiplier;
        } else {
            $scaledvalue = $value;
        }
        foreach ($this->answers as $answer) {
            if ($answer->within_tolerance($scaledvalue)) {
                $answer->unitisright = !is_null($multiplier);
                return $answer;
            } else if ($answer->within_tolerance($value)) {
                $answer->unitisright = false;
                return $answer;
            }
        }

        return null;
    }
public function get_matching_answer($value, $multiplier) {
        if (is_null($value) || $value === '') {
            return null;
        }

        if (!is_null($multiplier)) {
            $scaledvalue = $value * $multiplier;
        } else {
            $scaledvalue = $value;
        }
        foreach ($this->answers as $answer) {
            if ($answer->within_tolerance($scaledvalue)) {
                $answer->unitisright = !is_null($multiplier);
                return $answer;
            } else if ($answer->within_tolerance($value)) {
                $answer->unitisright = false;
                return $answer;
            }
        }

        return null;
    }
public function get_matching_answer ( $ value , $ multiplier ) { if ( is_null ( $ value ) || $ value === '' ) { return null ; } if ( ! is_null ( $ multiplier ) ) { $ scaledvalue = $ value * $ multiplier ; } else { $ scaledvalue = $ value ; } foreach ( $ this -> answers as $ answer ) { if ( $ answer -> within_tolerance ( $ scaledvalue ) ) { $ answer -> unitisright = ! is_null ( $ multiplier ) ; return $ answer ; } else if ( $ answer -> within_tolerance ( $ value ) ) { $ answer -> unitisright = false ; return $ answer ; } } return null ; }
Get an answer that contains the feedback and fraction that should be
awarded for this response.
@param number $value the numerical value of a response.
@param number $multiplier for the unit the student gave, if any. When no
unit was given, or an unrecognised unit was given, $multiplier will be null.
@return question_answer the matching answer.
Get an answer that contains the feedback and fraction that should be awarded for this response .