I have always had the problem that the grades table was extremely wide because each column had to be as wide as the name of the assignment. I now found the solution: rotate the table headings by 90 degrees. I saw this done in phpmyadmin. It is easy: the table heading simply needs to be enclosed in
<div style="text-align: right; writing-mode: tb-rl;"> ..... </div>
The table headings are set in /course/grades.php in lines 85 and 90. To make things look nicer I also changed the print_table function in lib/weblib.php in line 1089 to use valign="bottom" for table headings. Finally I had to make gradient.jpg in my theme folder a bit higher in order not to get repeated gradients in the now quite high table heading. Screenshot is attached.