MDL-38128 mod_assign: Fixing count teams and submissions with status

We should restrict the groups to the activity active group. Also
improving performance caching get_submission_group() results.