Skip to content

Instantly share code, notes, and snippets.

@dpalou
Last active August 2, 2018 09:23
Show Gist options
  • Save dpalou/aa7ff4484a9246ca7f0a6795850df520 to your computer and use it in GitHub Desktop.
Save dpalou/aa7ff4484a9246ca7f0a6795850df520 to your computer and use it in GitHub Desktop.
var that = this;
// Create a class that "inherits" from CoreCourseActivityPrefetchHandlerBase.
function AddonModCertificateModulePrefetchHandler() {
that.CoreCourseActivityPrefetchHandlerBase.call(this, that.TranslateService, that.CoreAppProvider, that.CoreUtilsProvider,
that.CoreCourseProvider, that.CoreFilepoolProvider, that.CoreSitesProvider, that.CoreDomUtilsProvider);
this.name = "AddonModCertificateModulePrefetchHandler";
this.modName = "certificate";
this.component = "AddonModCertificate";
this.updatesNames = /^configuration$|^.*files$|^entries$/;
}
AddonModCertificateModulePrefetchHandler.prototype = Object.create(this.CoreCourseActivityPrefetchHandlerBase.prototype);
AddonModCertificateModulePrefetchHandler.prototype.constructor = AddonModCertificateModulePrefetchHandler;
// Override the prefetch call.
AddonModCertificateModulePrefetchHandler.prototype.prefetch = function(module, courseId, single, dirPath) {
return this.prefetchPackage(module, courseId, single, prefetchCertificate);
};
function prefetchCertificate(module, courseId, single, siteId) {
// Perform all the WS calls.
// You can access most of the app providers using that.ClassName. E.g. that.CoreWSProvider.call().
}
// Register the handler.
this.CoreCourseModulePrefetchDelegate.registerHandler(new AddonModCertificateModulePrefetchHandler());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment