Removed code duplication in StudentgroupsController.