Adds content state comparison functionality to autosave interval#95
Adds content state comparison functionality to autosave interval#95rider-griffin wants to merge 1 commit into
Conversation
|
@rider-griffin Have you considered to compute, store and compare checksums of the state objects instead of comparing them property by property? |
|
@otacke |
|
@rider-griffin I wasn't thinking of something fancy like SHA where a simple hash could work and I don't think that there'll be a problem with property order, but I get your point. |
28e32f6 to
9705f84
Compare
The Issue
Because nested sub-contents do not trigger their respective XAPI verbs, which in turn trigger save events, we have tuned down out autosave interval on our server to be extremely frequent to prevent the loss of user data and progress. This is undesirable, as:
Solution
By taking advantage of the existing auto-save functionality, user data can be saved conditionally by comparing the current state of the content with a previous state of the content. If the user has in any way interacted with the content, then the user data should be set and a previous state should be assigned for the next comparison. If the states are equal and unchanged, then the setting of user data does not need to be performed. The scope of the state comparison function is as follows:
deepEqalgorithm, which recursively compares two objects and determines if they are equivalent.H5P.setUserDatafunction handles states) but can compare complex objects such as circular ones.Because the autosave will rely upon a state difference, the interval then becomes less honest. The cons of this implementation are that the algorithm will have to compare states based on the autosave interval, therefore increasing computational requirements given an extremely small interval and extremely large and nested state object. The pros, however, are: