Make `aplus:exercise-loaded` into a cancellable event
The current event is send here https://github.com/apluslms/a-plus/blob/d10087a658dfffdcfa0d7626dad16016e41372dd/exercise/static/exercise/chapter.js#L65-L66
To support JavaScript plugins and to help removing data-aplus-ajax special variable, the event should be made cancellable. This means, the code should look something like
const event_data = {
bubbles: true,
cancelable: true,
detail: {
type: type,
},
};
if (this.dom_element.dispatchEvent(
new CustomEvent("aplus:exercise-loaded", event_data))
) {
// aplus:exercise-loaded was not cancelled, proceed with the default action
$.augmentSubmitButton($(".exercise-column"));
this.dom_element.dispatchEvent(
new CustomEvent("aplus:exercise-ready", event_data));
}
Todo:
- [ ] make event cancellable
- [ ] schedule deprecation of data-aplus-ajax (is documented in https://apluslms.github.io/protocols/aplus-material-v1/)
- [ ] update the protocol documentation in https://apluslms.github.io/protocols/aplus-js-v1/
Can you elaborate in which specific use cases would this be useful?
Hey, fun. 5 year old technical "issue" without a clear user goal. I guess this could be just closed, if it didn't come up in past years...
I guess the origianl goal was to remove variable data-aplus-ajax.
From the linked doc page (which I have no idea if it's at all up to date):
data-aplus-ajax (pending deprecation). Stops A+ from binding to the submit event of the exercise form and adding group selection and so on. May be used when the course JavaScript takes care of that.
And I have no idea if that original idea to change the exercise API is a good or not.