learningequality/ka-lite — pull request #329 by bcipolli (2013-07-30 21:26:33+00:00)
Title: Improved error detection and handling through [Exercise/Video]Log API calls

This addresses #325, #326, and #297 (the higher impact part).

Behavior Changes:
* A single, unified message when progress is not tracked / displayed, due to either:
* No user is logged in (either intentionally or accidentally (see #326))
* An admin is logged in
* Show that warning message on pages where progress is loaded and shown (i.e. your progress is not showing because you're not logged in). Includes topic pages with videos / exercises on them, and the knowledge map (2nd level) (did not show previously)
* Show this message even when pages are cached ( #297 )
* Show messages if saving / loading fails for any unexpected reason.

Code Changes:
* Make sure APIs handle any possible exception (i.e. never return HTML when JSON is expected, wrap all errors in an expected, reportable json format).
* Make sure APIs are strict about accepting data--return errors anytime anything fails.
* All AJAX requests should handle HTTP errors (via a callback method), and display messages to the user when appropriate.

Testing:
* I manually tested all relevant cases, in all relevant scenarios:
* Video & Exercise pages properly save progress, properly report all warnings and exceptions for different cases (even if logged out through a session timeout)
* Relevant topic pages and knowledge map properly show warning messages