How to publish and unpublish content depending on the type of user?
Publishing and unpublishing is not the way to go.

Step 1) 

Install the Node Access module and give access to each node or content type accordingly, this way people can't share direct links with other users that have a different role. 

Step 2)

What you need is to create 3 different view blocks

One for anonymous which lists primaria/docentes &amp; secundaria/docentes nodes.

One for primary which lists all the primaria/docentes nodes

One for secondary which lists all the secundaria/docentes/kit nodes. 


  Hopefully node access module lets you filter your view by node access.
  Otherwise, you'll need to make the "kit", "primaria" and "secundaria"
  be a different content types so then you can filter by content type in
  your view.


Use view's access to role and select the role you want to be able to see the view. (see picture below)



Then you place all 3 view blocks wherever you need them (home page perhaps?) and since you have the view access by role, they will only see 1 view (the one they have access to).