MDL-37993 quiz activity completion: complete when all attempts used

One can have the quiz marked complete when all attempts are exhausted
or when a passing grade is achieved.
MDL-37993 quiz completion: fix some issues with the previous code.