A man who attacked a Muslim state representative outside a prayer service in Connecticut has pleaded guilty to attempted sexual assault and other crimes.