I could be wrong, but I believe each attempt at a quiz with randomly selected questions chooses a new random set of questions. (I am certain it works that way with questions selected from question groups in classic quizzes, but I have not yet tested the random selection of item bank questions in new quizzes yet.)
I do not believe that there is a feature that directly allows completion of additional assignments to unlock a new attempt at the same quiz. However, there is a way to make the equivalent happen.
In module 1 include the quiz that determines what will be assigned in module 2. Set the quiz as a module requirement in module 1, and set completion of module 1 as a prerequisite for module 2. (I assume you are using Mastery paths to assign the module 2 activities, since you specify they were not assigned before the quiz.)
In module 2, set a module requirement to require activities to be completed in order, and end the module with something that everyone needs to see or submit. Set a module requirement for that final activity. Students will not be able to meet that requirement, until they do everything that mastery paths will insert before that requirement. (Surprisingly, it turns out that it will not matter that those activities will not be module requirements: https://community.canvaslms.com/t5/Question-Forum/require-sequential-order-is-too-restrictive/m-p/40... )
Set module 2 as a prerequisite for module 3. Create a copy of the quiz in module 1, and put it in module 3. Call it "second attempt" or something similar. Students will not be able to access this second attempt until they have finished everything assigned in module 2.
In the assignments tab, create an assignment group. Put both the first and second attempt at the quiz in the same assignment group. From the three dot menu on the assignment group title select edit, and then on the pop-up menu select drop the lowest (1) score. Students will now see their first and second score on the quiz, and only the highest of the two will count.