bug-fix: get_next_participant malformed sql

- the sql to get the next available participant was malformed
- use temporary tables to simplify the process and correct
  the use of the left join to the assignment table