An improved version is attached.
It has been tested on my server.
There is a new control setting to enable in the course.conf file (or system wide) to turn on the 2-round process:
$lti_check_prior = 1;
- It defaults to being off.
See https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5002#p15255