Inactive students mean median

Inactive students should not be included when calculating the mean and
the median of the students' marks for an assignment.

This also improves the performance of the method, as it no longer
queries for a list of ActiveRecords (without eagerly loading the
associations as the current code does) objects but only a list of
integers.

This fixes #1551 partially fixes #1467.

Tested:
- rspec
- rake test:unit
- rake test:functionals
- local server eyeballing
Space inside { missing.<br>Space inside } missing.