You can have two loops that are both activated by the same variable or have an outer loop with Task1 as nReps that contains the instructions routine followed by a trials loop.
For alternating rather than random allocation I use group assignment in Qualtrics but you can also use my web app. https://moryscarter.com/vespr/pavlovia.php