This is a summary and continuation of the discussion from this review. I (Hora) created a function which returns the grade distribution as a percentage for a given assignment, a function which even with eager loading can make a lot of database queries. Since the graphs will tentatively be displayed in the dashboard, often the first page students will see, the question is whether we should cache grade distribution data and how.
Severin had suggested for the creation of a new model (for example AssignmentStats) which can have a column for each type of graph required. In the case of the grade distribution, we could have a column called ‘grade_distribution’ which stores a CSV list of the grade distribution data for the assignment. He further suggested that the graphs initially load as empty container boxes with spinners to indicate loading, and use XHRs to get the required data to generate the graph. Each graph could also have a Refresh link that will re-calculate (and re-cache) the distribution data if the instructor wishes to see the most up-to-date information.
Karen had suggested that we cache the actual generated graph, but Bluff (the graphing API we selected) uses HTML canvas tags to display the graphs and it doesn’t look like there’s a way to save the graphs.
I think Severin’s suggestion is great, and I think it would make sense to update the cached data every time a mark is denoted as complete. I also like the ideas of having a Refresh link that an instructor can use to update the data and using XHRs to get the data. My suggested plan of attack is for Kurtis and I to write the code for generating some of the graphs to see exactly how that would fit into the existing code, then to add caching and make appropriate modifications where necessary to take advantage of it. As long as we don’t release a stable version of MarkUs before we finish the caching, there probably won’t be any problems with some slow-loading graphs. Does that sound like a good idea? Or should I get to work on caching first, and then on generating graphs? Any other comments or suggestions?