By adding a new optional param to quiz_prepare_and_start_new_attempt() it can be used by the surrounding code to create an attempt for anybody else (different from current $USER) quiz attempt API should let you create an attempt for a different user