Convert courses array to hash