adaptlearning / adapt-contrib-xapi

TinCan/xAPI extension for the Adapt Framework
GNU General Public License v3.0
12 stars 28 forks source link

sendState should behave asynchronously #134

Open cahirodoherty-learningpool opened 3 weeks ago

cahirodoherty-learningpool commented 3 weeks ago

Subject of the issue/enhancement/features

We have a custom plugin that forces submit of multiple components in one functional batch (In essence:

        componentView.onSubmitClicked();
      });

)

When it comes to handling a large volume of components, we have found that this effectively creates a race condition and the state that comes back may actually not be the last state sent, thus cutting off some question values when the state is loaded again on subsequent views.

I believe setting an await on https://github.com/adaptlearning/adapt-contrib-xapi/blob/master/js/XAPI.js#L1082 should help us out in this regard

cahirodoherty-learningpool commented 3 weeks ago

@oliverfoster Any thoughts on this?

oliverfoster commented 2 weeks ago

The state is concurrently read in once and updated multiple times?

How is an old state read in after an update is sent? What is the exact mechanism / order of flow?

Strategically, it's best usually to add a "last updated" timestamp on the state. Such that only states that are newer than the local/previous are accepted as updates and retries are attempted on conflict.

cahirodoherty-learningpool commented 1 week ago

Basically its a one-button submit for all components:

onSubmit() {
    _.each(this.componentViews, (componentView) => {
        componentView.onSubmitClicked();
    });
}
oliverfoster commented 1 week ago

Yes, I don't understand where a state is being read in and in conflict. I see that submitting multiple questions at the same time would rapidly send statements.