Back in December, I blogged about performance issues related to the first version of the grades table. Two of my concerns were that the table was difficult to navigate because all of the students were shown on a single page and that the table took a long time to load or save. Since then, the grades table has undergone a bunch of changes, in an attempt to improve performance. Pagination was implemented to reduce the number of students displayed on a page, which made the table load faster. The “Save” button for the table was removed and the grades are now automatically saved as they are being entered. A drop-down list of alphabetical categories was added to make it easier for an instructor to jump to a page containing a particular set of students. All of these changes really improved the table view itself.
But, there was still one problem: when the number of students was large and when the number of questions was large, creating a grade entry form took a very long time! This is because of all the objects that were being created when the form was created. For example, say an instructor was creating a grade entry form with
q questions and there were
s students. Then, when the GradeEntryForm was being created, (
s) Grades and
s GradeEntryStudents were also being created, all in one shot. The important thing to realize is that for a table like this, all of these objects will have to be created at some point. How else can you store the grades for all the students, for all the questions, and release the grades for a particular student? However, the key thing is to create these objects in a clever way. The solution was to create GradeEntryStudents and Grades as needed, instead of when the GradeEntryForm is being created. This means that creating the form itself takes very little time! When the grades table is first loaded, the GradeEntryStudents and Grades objects do not actually exist. They are created as the user enters the grades. For example, if the user enters a grade for “Joe Smith”, we pass the Student ID and the GradeEntryItem ID to the controller. The controller then checks to see if the corresponding GradeEntryStudent exists. If it doesn’t exist, we then create it. Next, we check if the Grade for this GradeEntryItem exists. If it doesn’t exist, we create it. Otherwise, we update it. The user doesn’t even really notice these objects are being created as they are entering the grades! So now, GradeEntryForm creation and the table view itself have been improved!