First of all creat the students groups following the instructions: How to create a full student group.

In the page of creation of any activity or resource, you will find the Restrict access section. Clic on Add restriction button.

Click on Group button.

Dropdown the Group menu and select the desired group.

Keep in mind if more than one group is selected, you have to select the any option.

After save changes, the activity or the resource will be accessible only for the group o groups selected.