Ensure LMS passes correct group_id when querying content

TNL-23
I find these long views easier to read when the variable declarations are at the top of the method.