hypothesis / lms

LTI app for integrating with learning management systems
BSD 2-Clause "Simplified" License
45 stars 14 forks source link

Initially order null columns last in dashboard activity tables #6381

Closed acelaya closed 1 month ago

acelaya commented 1 month ago

This PR uses the logic introduced in https://github.com/hypothesis/frontend-shared/pull/1587 to make columns with value null be initially ordered last, and move first when the order direction changes.

Additionally, it refactors OrderableActivityTable to move the decision on what's the initial order direction for every column to every individual activity table.

https://github.com/hypothesis/lms/assets/2719332/9a85da0f-10f3-4b7b-93c1-3fe619f3de51

Testing steps

Any table where the user's last activity is null, should allow to test this behavior.

It can also be faked by making sure some null students names are returned, by applying this diff, replacing <some-value> with the display name of some student in your local dev database:

diff --git a/lms/views/dashboard/api/assignment.py b/lms/views/dashboard/api/assignment.py
index 444a6f45e..bb0e2aa8b 100644
--- a/lms/views/dashboard/api/assignment.py
+++ b/lms/views/dashboard/api/assignment.py
@@ -60,7 +60,7 @@ class AssignmentViews:
                 students.append(
                     APIStudent(
                         id=user.user_id,
-                        display_name=s["display_name"],
+                        display_name=None if s["display_name"] == "<some-value>" else s["display_name"],
                         annotation_metrics=AnnotationMetrics(
                             annotations=s["annotations"],
                             replies=s["replies"],