It depends on exactly what you are doing, the nature of the class, and what it is for.  The first step is to determine the extent of your involvement.  If you are simply entering their responses-- that's not much different that someone trying to help a person with a disability.  If you are doing the work for them and they are claiming the credit, then it could be illegal, depending on the reason for the online class.  If the online class is for course credit through a university, then it would be as you noted "unethical," but not necessarily illegal.  If the online class was for some type of governmental certification (as for a state license), then it could be considered a criminal offense of making an illegal entry in a governmental record or tampering with a governmental record.  So, if you are helping someone claim a certain status with a government entity, you may want to reconsider your involvement, since you could also be charged as a party to the offense.