Calculation the "completion state for an activity and user" (internal_get_state method in completionlib.php) cheks grade state only if completiongradeitemnumber was set to cm.
But $cm->completiongradeitemnumber is null when activity completion settings are:
- Require grade - false
- Require passing grade - true
So, we expext completionstate == COMPLETION_COMPLETE_PASS (2) or COMPLETION_COMPLETE_FAIL (3), but we take always only COMPLETION_COMPLETE (1)
The problem occured when we using availability condition "completion" and waiting passed modules to give availability to user. Modules are always just COMPLETION_COMPLETE and never goes to COMPLETION_COMPLETE_PASS.