place generating a submission in a transaction

this also does a little bit of refactoring around generating quiz submissions
and how we determine the end_at date

fixes CNVS-17232

test plan:
  - as a teacher
    - create a quiz
    - make sure you can successfully take the quiz

    - create a quiz
    - take a quiz
    - leave the quiz before finishing
    - return and 'resume quiz'
    - make sure that you can successfully resume the quiz

    - create a quiz
    - add extension for a user to give extra time or attempt

    - as a student with an extension
    - make sure you can successfully take the quiz

  - important! Logic has been updated here and needs
    a good check for regressions on the test plan in:
    https://gerrit.instructure.com/#/c/40609

Change-Id: I3ead6adf866ac8aa155b7104b2819e03b124bb53
Reviewed-on: https://gerrit.instructure.com/45261
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Taylor <rtaylor@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>