MDL-17248 fixed incorrect sum when scales involved; merged from MOODLE_19_STABLE...