smarterer/leaderboard — pull request #1 by anandthakker (2014-11-17 01:15:17+00:00)
Title: Update for API Documentation Reorg

Overall aim was to verify, clean up, and thoroughly document this sample code and make it as accessible as possible. (All the more so because probably many devs are coming from Java or .NET, and a from-scratch sample in one of those was out of scope).

Three parts to my attempt here, in increasing order of size:
1. Add some documentation.
The example is pretty simple and was already documented, so this was pretty straightforward, just filling in a bit more detail.
2. Rearrange
I've tried to reorganize `leaderboard.py` into roughly the order that the application logic flows. Also consolidated `update_badges()` from `util.py` into `leaderboard.py`. Idea here is to simplify navigating the example as much as possible, so that a totally unfamiliar dev can (basically) just read `leaderboard.py` from top to bottom and it'll make sense.
3. Add a 'profile page' feature. Originally, the example would only hit the Smarterer API when the user, having gone through test questions, navigated to the leaderboard, at which point the app would grab the user's badge info and store it into the db. I rejiggered this so that the user sees the saved Leaderboard score and their most up to date actual test score on their profile page, and can choose if/when to update the leaderboard. Rationale was simply to make the use of the API more frequent and prominent in the example.