Nested for each statement - evaluation form reminder. Any ideas?

Nested for each statement - evaluation form reminder. Any ideas?

Hi there.  I have a course management app. Delegates are enrolled on a course, which has a number of events. After each event delegates complete an evaluation form. I want to create a function that checks who hasn't completed their evaluation form and sends them an email to give them a gentle nudge

There are five tables I'm working with - Delegates, Enrolments, Courses, Events and Evaluations. What I had in mind was to create a list of all the expected Delegate - Event combinations, then to create a similar list from the Evaluations table and subtract one from the other, identifying where people should have submitted an evaluation, but haven't.

The second list should be quite easy, it;s the first I'm struggling with - essentially how to say 'For each event see which delegates should be attending and store that value within a list'. Here's my current best effort

void Chaseups.EvalChase()
{
    ListEvents = List();
    for each record in Events
    {
        ThisCourse  =  Courses  [ID == record.Course_Reference];
        ThisEnrolment  =  Enrolments  [Easy_Reference == ThisCourse.ID];
        for each r in Delegates
        {
            TempList = List();
            if (((r.ID  ==  ThisEnrolment.Delegate)  &&  (ThisEnrolment.Easy_Reference  =  ThisCourse.ID))  &&  (ThisCourse.ID  ==  record.Course_Reference))
            {
                TempList.add(record.Easy_Reference + r.Surname);
            }
            ListEvents.addall(TempList);
        }
    }
    info ListEvents;
}

All help gratefully received!

Many thanks
Tom