This is the standard trick of adding a redundant WHERE clause to a
subquery to help the database realise that it does not have to inspect
so many rows.
It seems that sometimes trying to process an overdue quiz attempt can
throw an exception. In that case, we need to catch it and report it
nicely, and then carry on processing the rest of the attempts, rather
than just killing the whole of cron processing.
Also, there may be garbage quiz attempts where the associated quiz or
course has been deleted. Skip those too.
If the timelimit or timeclose of a quiz are 0, this means 'no
restriction', rather than '1970' or '0 seconds'. We need to handle these
special cases correctly in the code that looks for quiz attempts that
might be in the wrong state.
This commit just changes the white-space, but does not change any of the
actual code. This is so that the commit I am about to make, which will
change the code, will be easier to understand.