Fix for quiz that needs grading not properly retrieved

Hi guys,
thanks for maintaining this great plugin. It was easy to read even though I have little knowledge of the quiz code. It would be a nice feature to have in Moodle core, it makes sense to me that every teachers want to know what they need to grade without browsing everywhere.

The current quiz SQL request doesn't work on postgres (GROUP BY error) + it looks like it is broken to me. For example there is a questionattemptid == quizattemptid.

As I am not keen with big SQL request containing different JOIN, SUBSELECT, MAX etc... I had a look to Tim Hunt's student grading report for quiz (in Moodle.org plugin repository) which retrieves the quiz attempts that need to be graded. 

I created this pull request for you to be alerted as the Github issue tracker is not enabled.  Obviously this pull request is more serving of bug report, you don't want to merge it in this state as it doesn't "fit" with the coding of this plugin.

Thanks again,
Jerome