Well, I wouldn't be the energetic one for something that deep as the OP's plan, but, it could easily be done by spawning an NPC by each of the caster classes home GM (as an example). Those npc's, all with the same name (multi-spawned), like,
GM_Spell_Teacher. Then put the master script (under that name), in global, using
if($class eq "Druid"), or
if($class eq "Cleric"), and so on, and so on. That's just my brain on coffee.....