<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_for_duplicate_assignments(participant):
 """Check that the assignment_id of the participant is unique. If it isnt the older participants will be failed. """

    participants = models.Participant.query.filter_by(
        assignment_id=participant.assignment_id
    ).all()
    duplicates = [
        p for p in participants if (p.id != participant.id and p.status == "working")
    ]
    for d in duplicates:
        q.enqueue(worker_function, "AssignmentAbandoned", None, d.id)