If you assign a test online, you can restrict the time, test duration and the number of attempts. In the Assign tab, select the checkboxes: