DASSL / Gradebook

Open-source product to provide a practical means for instructors to record student attendance and assessment
Other
8 stars 4 forks source link

Web server fails to check if DB queries return a result (MW) #52

Open wildtayne opened 7 years ago

wildtayne commented 7 years ago

To echo my comment from #50:

I think we may want to consider how the REST functions behave when no data is returned. Currently, /attendance sends a 500 error if no attendance records are available, which causes an error to be displayed on the client. This is not correct, as no attendance records existing for a section is not an exceptional situation. I think it makes more sense to send a different code for no data (maybe 204) and have the client display a message that no records exist in the attendance grid area. I think this is the ideal behavior for all of the current REST functions except for /login, which is correctly sending a 401 error.

My proposed solution would be to have each query be checked for a the result (result.rows.length < minimum cardinality) and then send a 204 code to the client, potentially with a message the client can display. On the client side, this should appear more as a 'no data' message or similar, rather than a popup error. For example, If no years are returned by getInstructorYears() for an instructor, /years should send 204 - No years found to the client, and the years dropdown box should display no years.