'Updates 5 of the 6 existing problems to limit their visibility by content group.
Publishes the modified units.'

def link_problems_to_content_groups_and_publish(self):

    container_page = self.go_to_unit_page()
    enrollment_group = 'enrollment_track_group'
    def set_visibility(problem_index, groups, group_partition='content_group'):
        problem = container_page.xblocks[problem_index]
        problem.edit_visibility()
        visibility_dialog = XBlockVisibilityEditorView(self.browser, problem.locator)
        partition_name = (visibility_dialog.ENROLLMENT_TRACK_PARTITION if (group_partition == enrollment_group) else visibility_dialog.CONTENT_GROUP_PARTITION)
        visibility_dialog.select_groups_in_partition_scheme(partition_name, groups)
    set_visibility(1, [self.content_group_a])
    set_visibility(2, [self.content_group_b])
    set_visibility(3, [VERIFIED_TRACK], enrollment_group)
    set_visibility(4, [AUDIT_TRACK], enrollment_group)
    set_visibility(5, [self.content_group_a, self.content_group_b])
    container_page.publish_action.click()
