A teacher has apologized for assigning students to write captions for photos of freed slaves and to 'make it funny'