China has passed an education law that seeks to cut the twin pressures of homework and off-site tutoring in core subjects.