FunctionScore: Fix 'avg' score mode to correctly implement weighted mean.

closes #8992
closes #9004