Is your connection to your database happening through SCORM or are you reliant on another way to communicate? You said you are using a text file to communicate which database to send the message to. Is this text file just a single String? How does this get fired from just a Matching component?
I would highly recommend creating a component from scratch that handles all these requirements. If the class ID can be retrieved through SCORM it will be able to read it automatically and you could cross reference which Database ID this relates to in the component. I assume you would need to update the component every year when a new year ground of students joins but this should be fairly easy to maintain.