pid variable needs to be set before being assigned to chapter_parent

The order of these was correct in original PR, but got switched around on manual merge https://github.com/pressbooks/pressbooks/commit/8f04041938c708f3f01dd99dddb5fee0923e265a

this reverts to the order in original PR