Permalink
Browse files

Merge branch 'MDL-30167_21' of git://github.com/timhunt/moodle into M…

…OODLE_21_STABLE
  • Loading branch information...
2 parents 830969c + 4493fe9 commit 71a215991d29cb098352bb94dc0910ba3435ae9c @stronk7 stronk7 committed Nov 16, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 question/type/numerical/questiontype.php
@@ -641,16 +641,17 @@ public function apply_units($response, $separateunit = null) {
$numberstring = $matches[0];
if ($this->unitsbefore) {
- $unit = substr($response, 0, -strlen($numberstring));
+ // substr returns false when it means '', so cast back to string.
+ $unit = (string) substr($response, 0, -strlen($numberstring));
} else {
- $unit = substr($response, strlen($numberstring));
+ $unit = (string) substr($response, strlen($numberstring));
}
if (!is_null($separateunit)) {
$unit = $separateunit;
}
- if ($unit && $this->is_known_unit($unit)) {
+ if ($this->is_known_unit($unit)) {
$multiplier = 1 / $this->units[$unit];
} else {
$multiplier = null;

0 comments on commit 71a2159

Please sign in to comment.