Thanks Renaut - so looking at what you had suggested I now realise I was not identifying the specific user so it was picking up the availability for me! Duh!
It was a super easy fix:
I changed
$modinfo = get_fast_modinfo($course);
to
$modinfo = get_fast_modinfo($course, $studentid);
Thanks for getting me on the right track!