Course completion mark is not removed if you later fail a quiz.
Steps to recreate in Moodle 3.2;
1. Create a quiz on a course with following settings;
in quiz settings use grading method "Highest grade"
set grade to pass 5.00
Attempts allowed: Unlimited.
Under "Activity completion" set completion tracking to "show activity complete when conditions are met" and put checkmark to "Student must receive a grade to complete this activity" and "Require passing grade"
create two (2) true/false questions.
set maximum grade to 10.0.
2. Complete the quiz with a student x with grade 5.0 so it passes the "grade the pass" requirement.
3. Turn on the course completion;
"Condition: Activity completion" and select quiz -> save
4. Check out that the student x gets the course completion mark on the "course completion" report for quiz and course.
5. Check that the student x get the activity completion mark for the quiz on "Activity completion" -report.
6. After that change in the quiz settings "Grading method" to "last attempt" and save
7. Make the quiz as student X with grade 0.00
8. Make sure cron is ran several times
9. Check that on the "Activity completion" -report there is no checkmark for the student X on the quiz-row.
10. Now check "course completion" -report, see how there is no check mark for the student x on the quiz but he/she still has the course completion mark even though he/she have failed the quiz.
So the problem is that the course completion mark doesn't go away when you fail the quiz even though the course is complete only after the quiz is marked complete which it isn't anymore.