This commit patches a problem with course group enrollment ACL in a closed course. ref #377.

Moved the case "group_id" to run with case "cgroup_id".
The table `course_group_audience` doesn't have a field of `period_id` so I joined the `course_audience` table to get the period ID.